diff options
author | Roman Shaposhnik <roman@shaposhnik.org> | 2004-03-28 02:17:06 +0000 |
---|---|---|
committer | Roman Shaposhnik <roman@shaposhnik.org> | 2004-03-28 02:17:06 +0000 |
commit | 9a4d93887442dad5e0b7156fe1995651f13947d1 (patch) | |
tree | aa0309a31a3d735f9e7ebf5f450361f48728d3b6 /libavformat/movenc.c | |
parent | d9d7653e394cda0e3df5234723407f088aed0a26 (diff) | |
download | ffmpeg-9a4d93887442dad5e0b7156fe1995651f13947d1.tar.gz |
* making .mov files generated by ffmpeg compatible with Apple software.
Originally committed as revision 2937 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r-- | libavformat/movenc.c | 76 |
1 files changed, 44 insertions, 32 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index cc809b649f..b78ca60c4e 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -278,8 +278,8 @@ static int mov_write_audio_tag(ByteIOContext *pb, MOVTrack* track) /* TODO: Currently hard-coded to 16-bit, there doesn't seem to be a good way to get number of bits of audio */ put_be16(pb, 0x10); /* Reserved */ - put_be16(pb, 0xfffe); /* compression ID (= 0) */ - put_be16(pb, 0xac); /* packet size (= 0) */ + put_be16(pb, 0); /* compression ID (= 0) */ + put_be16(pb, 0); /* packet size (= 0) */ put_be16(pb, track->timescale); /* Time scale */ put_be16(pb, 0); /* Reserved */ @@ -453,17 +453,18 @@ static int mov_write_video_tag(ByteIOContext *pb, MOVTrack* track) put_be16(pb, track->enc->height); /* Video height */ put_be32(pb, 0x00480000); /* Reserved */ put_be32(pb, 0x00480000); /* Reserved */ + put_be32(pb, 0); /* Data size (= 0) */ + put_be16(pb, 1); /* Frame count (= 1) */ + put_be32(pb, 0); /* Reserved */ put_be32(pb, 0); /* Reserved */ put_be32(pb, 0); /* Reserved */ put_be32(pb, 0); /* Reserved */ put_be32(pb, 0); /* Reserved */ put_be32(pb, 0); /* Reserved */ - - put_be16(pb, 0); /* Reserved */ - put_be32(pb, 0); /* Reserved */ put_be32(pb, 0); /* Reserved */ put_be32(pb, 0); /* Reserved */ + put_be16(pb, 0x18); /* Reserved */ put_be16(pb, 0xffff); /* Reserved */ if(track->enc->codec_id == CODEC_ID_MPEG4) @@ -562,44 +563,52 @@ static int mov_write_vmhd_tag(ByteIOContext *pb) return 0x14; } -static int mov_write_minf_tag(ByteIOContext *pb, MOVTrack* track) -{ - int pos = url_ftell(pb); - put_be32(pb, 0); /* size */ - put_tag(pb, "minf"); - if(track->enc->codec_type == CODEC_TYPE_VIDEO) - mov_write_vmhd_tag(pb); - else - mov_write_smhd_tag(pb); - mov_write_dinf_tag(pb); - mov_write_stbl_tag(pb, track); - return updateSize(pb, pos); -} - static int mov_write_hdlr_tag(ByteIOContext *pb, MOVTrack* track) { - char *str; + char *descr, *hdlr, *hdlr_type; int pos = url_ftell(pb); + + if (!track) { /* no media --> data handler */ + hdlr = "dhlr"; + hdlr_type = "url "; + descr = "DataHandler"; + } else { + hdlr = (track->mode == MODE_MOV) ? "mhlr" : "\0\0\0\0"; + if (track->enc->codec_type == CODEC_TYPE_VIDEO) { + hdlr_type = "vide"; + descr = "VideoHandler"; + } else { + hdlr_type = "soun"; + descr = "SoundHandler"; + } + } + put_be32(pb, 0); /* size */ put_tag(pb, "hdlr"); put_be32(pb, 0); /* Version & flags */ - if (track->mode == MODE_MOV) - put_tag(pb, "mhlr"); /* handler */ - else - put_be32(pb, 0); /* reserved */ - if(track->enc->codec_type == CODEC_TYPE_VIDEO) - put_tag(pb, "vide"); /* handler type */ - else - put_tag(pb, "soun"); /* handler type */ + put_tag(pb, hdlr); /* handler */ + put_tag(pb, hdlr_type); /* handler type */ put_be32(pb ,0); /* reserved */ put_be32(pb ,0); /* reserved */ put_be32(pb ,0); /* reserved */ + put_byte(pb, strlen(descr)); /* string counter */ + put_buffer(pb, descr, strlen(descr)); /* handler description */ + return updateSize(pb, pos); +} + +static int mov_write_minf_tag(ByteIOContext *pb, MOVTrack* track) +{ + int pos = url_ftell(pb); + put_be32(pb, 0); /* size */ + put_tag(pb, "minf"); if(track->enc->codec_type == CODEC_TYPE_VIDEO) - str = "VideoHandler"; + mov_write_vmhd_tag(pb); else - str = "SoundHandler"; - put_byte(pb, strlen(str)); /* string counter */ - put_buffer(pb, str, strlen(str)); + mov_write_smhd_tag(pb); + if (track->mode == MODE_MOV) /* FIXME: Why do it for MODE_MOV only ? */ + mov_write_hdlr_tag(pb, NULL); + mov_write_dinf_tag(pb); + mov_write_stbl_tag(pb, track); return updateSize(pb, pos); } @@ -961,6 +970,9 @@ static int mov_write_packet(AVFormatContext *s, int stream_index, else if(enc->codec_id == CODEC_ID_PCM_ALAW) { samplesInChunk = size/enc->channels; } + else if(enc->codec_id == CODEC_ID_PCM_S16BE || enc->codec_id == CODEC_ID_PCM_S16LE) { + samplesInChunk = size/(2*enc->channels); + } else { samplesInChunk = 1; } |