Commit 9a4d9388 authored by Roman Shaposhnik's avatar Roman Shaposhnik

* making .mov files generated by ffmpeg compatible with Apple software.

Originally committed as revision 2937 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent d9d7653e
...@@ -278,8 +278,8 @@ static int mov_write_audio_tag(ByteIOContext *pb, MOVTrack* track) ...@@ -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 /* TODO: Currently hard-coded to 16-bit, there doesn't seem
to be a good way to get number of bits of audio */ to be a good way to get number of bits of audio */
put_be16(pb, 0x10); /* Reserved */ put_be16(pb, 0x10); /* Reserved */
put_be16(pb, 0xfffe); /* compression ID (= 0) */ put_be16(pb, 0); /* compression ID (= 0) */
put_be16(pb, 0xac); /* packet size (= 0) */ put_be16(pb, 0); /* packet size (= 0) */
put_be16(pb, track->timescale); /* Time scale */ put_be16(pb, track->timescale); /* Time scale */
put_be16(pb, 0); /* Reserved */ put_be16(pb, 0); /* Reserved */
...@@ -453,17 +453,18 @@ static int mov_write_video_tag(ByteIOContext *pb, MOVTrack* track) ...@@ -453,17 +453,18 @@ static int mov_write_video_tag(ByteIOContext *pb, MOVTrack* track)
put_be16(pb, track->enc->height); /* Video height */ put_be16(pb, track->enc->height); /* Video height */
put_be32(pb, 0x00480000); /* Reserved */ put_be32(pb, 0x00480000); /* Reserved */
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_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_be32(pb, 0); /* Reserved */ put_be32(pb, 0); /* Reserved */
put_be16(pb, 0x18); /* Reserved */ put_be16(pb, 0x18); /* Reserved */
put_be16(pb, 0xffff); /* Reserved */ put_be16(pb, 0xffff); /* Reserved */
if(track->enc->codec_id == CODEC_ID_MPEG4) if(track->enc->codec_id == CODEC_ID_MPEG4)
...@@ -562,44 +563,52 @@ static int mov_write_vmhd_tag(ByteIOContext *pb) ...@@ -562,44 +563,52 @@ static int mov_write_vmhd_tag(ByteIOContext *pb)
return 0x14; 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) static int mov_write_hdlr_tag(ByteIOContext *pb, MOVTrack* track)
{ {
char *str; char *descr, *hdlr, *hdlr_type;
int pos = url_ftell(pb); 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_be32(pb, 0); /* size */
put_tag(pb, "hdlr"); put_tag(pb, "hdlr");
put_be32(pb, 0); /* Version & flags */ put_be32(pb, 0); /* Version & flags */
if (track->mode == MODE_MOV) put_tag(pb, hdlr); /* handler */
put_tag(pb, "mhlr"); /* handler */ put_tag(pb, hdlr_type); /* handler type */
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_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_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) if(track->enc->codec_type == CODEC_TYPE_VIDEO)
str = "VideoHandler"; mov_write_vmhd_tag(pb);
else else
str = "SoundHandler"; mov_write_smhd_tag(pb);
put_byte(pb, strlen(str)); /* string counter */ if (track->mode == MODE_MOV) /* FIXME: Why do it for MODE_MOV only ? */
put_buffer(pb, str, strlen(str)); mov_write_hdlr_tag(pb, NULL);
mov_write_dinf_tag(pb);
mov_write_stbl_tag(pb, track);
return updateSize(pb, pos); return updateSize(pb, pos);
} }
...@@ -961,6 +970,9 @@ static int mov_write_packet(AVFormatContext *s, int stream_index, ...@@ -961,6 +970,9 @@ static int mov_write_packet(AVFormatContext *s, int stream_index,
else if(enc->codec_id == CODEC_ID_PCM_ALAW) { else if(enc->codec_id == CODEC_ID_PCM_ALAW) {
samplesInChunk = size/enc->channels; 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 { else {
samplesInChunk = 1; samplesInChunk = 1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment