aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/movenc.c
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2008-01-28 15:22:07 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2008-01-28 15:22:07 +0000
commita23c9c4a50834ab8ea580d798c0301019611628e (patch)
treec6d90eec3c99074d2e086992b459972e223b51b8 /libavformat/movenc.c
parentd334c7c2379e8b60c3939eaf12bd44bb74c8a0d0 (diff)
downloadffmpeg-a23c9c4a50834ab8ea580d798c0301019611628e.tar.gz
correctly and only set standard stsd fourcc for mp4/3gp
Originally committed as revision 11650 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r--libavformat/movenc.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 46610c89a8..e283908440 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -474,10 +474,27 @@ static int mov_write_avid_tag(ByteIOContext *pb, MOVTrack *track)
return 0;
}
-static int mov_find_video_codec_tag(AVFormatContext *s, MOVTrack *track)
+static const AVCodecTag codec_3gp_tags[] = {
+ { CODEC_ID_H263, MKTAG('s','2','6','3') },
+ { CODEC_ID_H264, MKTAG('a','v','c','1') },
+ { CODEC_ID_MPEG4, MKTAG('m','p','4','v') },
+ { CODEC_ID_AAC, MKTAG('m','p','4','a') },
+ { CODEC_ID_AMR_NB, MKTAG('s','a','m','r') },
+ { CODEC_ID_AMR_WB, MKTAG('s','a','w','b') },
+};
+
+static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
{
int tag = track->enc->codec_tag;
- if (!tag) {
+ if (track->mode == MODE_MP4 || track->mode == MODE_PSP) {
+ if (!codec_get_tag(ff_mp4_obj_type, track->enc->codec_id))
+ return 0;
+ if (track->enc->codec_id == CODEC_ID_H264) tag = MKTAG('a','v','c','1');
+ else if (track->enc->codec_type == CODEC_TYPE_VIDEO) tag = MKTAG('m','p','4','v');
+ else if (track->enc->codec_type == CODEC_TYPE_AUDIO) tag = MKTAG('m','p','4','a');
+ } else if (track->mode == MODE_3GP || track->mode == MODE_3G2) {
+ tag = codec_get_tag(codec_3gp_tags, track->enc->codec_id);
+ } else if (!tag) { // do not override tag for mov
if (track->enc->codec_id == CODEC_ID_DVVIDEO) {
if (track->enc->height == 480) { /* NTSC */
if (track->enc->pix_fmt == PIX_FMT_YUV422P)
@@ -492,15 +509,9 @@ static int mov_find_video_codec_tag(AVFormatContext *s, MOVTrack *track)
else
tag = MKTAG('d', 'v', 'p', 'p');
}
- } else if (track->enc->codec_id == CODEC_ID_H263) {
- if (track->mode == MODE_MOV)
- tag = MKTAG('h', '2', '6', '3');
- else
- tag = MKTAG('s', '2', '6', '3');
} else {
+ if (track->enc->codec_type == CODEC_TYPE_VIDEO) {
tag = codec_get_tag(codec_movvideo_tags, track->enc->codec_id);
- }
- }
// if no mac fcc found, try with Microsoft tags
if (!tag) {
tag = codec_get_tag(codec_bmp_tags, track->enc->codec_id);
@@ -508,16 +519,8 @@ static int mov_find_video_codec_tag(AVFormatContext *s, MOVTrack *track)
av_log(s, AV_LOG_INFO, "Warning, using MS style video codec tag, the file may be unplayable!\n");
}
}
- assert(tag);
- return tag;
-}
-
-static int mov_find_audio_codec_tag(AVFormatContext *s, MOVTrack *track)
-{
- int tag = track->enc->codec_tag;
- if (!tag) {
+ } else if (track->enc->codec_type == CODEC_TYPE_AUDIO) {
tag = codec_get_tag(codec_movaudio_tags, track->enc->codec_id);
- }
// if no mac fcc found, try with Microsoft tags
if (!tag) {
int ms_tag = codec_get_tag(codec_wav_tags, track->enc->codec_id);
@@ -526,7 +529,9 @@ static int mov_find_audio_codec_tag(AVFormatContext *s, MOVTrack *track)
av_log(s, AV_LOG_INFO, "Warning, using MS style audio codec tag, the file may be unplayable!\n");
}
}
- assert(tag);
+ }
+ }
+ }
return tag;
}
@@ -1458,8 +1463,12 @@ static int mov_write_header(AVFormatContext *s)
track->enc = st->codec;
track->language = ff_mov_iso639_to_lang(st->language, mov->mode != MODE_MOV);
track->mode = mov->mode;
+ track->tag = mov_find_codec_tag(s, track);
+ if (!track->tag) {
+ av_log(s, AV_LOG_ERROR, "track %d: could not find tag for codec\n", i);
+ return -1;
+ }
if(st->codec->codec_type == CODEC_TYPE_VIDEO){
- track->tag = mov_find_video_codec_tag(s, track);
track->timescale = st->codec->time_base.den;
av_set_pts_info(st, 64, 1, st->codec->time_base.den);
if (track->timescale > 100000)
@@ -1468,7 +1477,6 @@ static int mov_write_header(AVFormatContext *s)
"file may not be playable by quicktime. Specify a shorter timebase\n"
"or choose different container.\n");
}else if(st->codec->codec_type == CODEC_TYPE_AUDIO){
- track->tag = mov_find_audio_codec_tag(s, track);
track->timescale = st->codec->sample_rate;
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
if(!st->codec->frame_size){