diff options
author | James Almer <jamrial@gmail.com> | 2019-11-27 14:15:34 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2019-12-21 11:57:28 -0300 |
commit | 58ac7608160b4fd3f696f07cd68f5e340f0f6832 (patch) | |
tree | e5cc5ca1e9ee59d1cf72b2101aece73f82352c9b /libavformat/movenc.c | |
parent | 1fcbaa37e641315842824b58c72bce6807262f0d (diff) | |
download | ffmpeg-58ac7608160b4fd3f696f07cd68f5e340f0f6832.tar.gz |
avformat/movenc: write the major brand also as the first compatible brand
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r-- | libavformat/movenc.c | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 126b64d984..c13578e13f 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -4741,27 +4741,11 @@ static int mov_write_mdat_tag(AVIOContext *pb, MOVMuxContext *mov) return 0; } -/* TODO: This needs to be more general */ -static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) +static void mov_write_ftyp_tag_internal(AVIOContext *pb, AVFormatContext *s, + int has_h264, int has_video, int write_minor) { MOVMuxContext *mov = s->priv_data; - int64_t pos = avio_tell(pb); - int has_h264 = 0, has_video = 0; int minor = 0x200; - int i; - - for (i = 0; i < s->nb_streams; i++) { - AVStream *st = s->streams[i]; - if (is_cover_image(st)) - continue; - if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) - has_video = 1; - if (st->codecpar->codec_id == AV_CODEC_ID_H264) - has_h264 = 1; - } - - avio_wb32(pb, 0); /* size */ - ffio_wfourcc(pb, "ftyp"); if (mov->major_brand && strlen(mov->major_brand) >= 4) ffio_wfourcc(pb, mov->major_brand); @@ -4788,11 +4772,36 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) else ffio_wfourcc(pb, "qt "); - avio_wb32(pb, minor); + if (write_minor) + avio_wb32(pb, minor); +} - if (mov->mode == MODE_MOV) - ffio_wfourcc(pb, "qt "); - else if (mov->mode == MODE_ISM) { +static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) +{ + MOVMuxContext *mov = s->priv_data; + int64_t pos = avio_tell(pb); + int has_h264 = 0, has_video = 0; + int i; + + for (i = 0; i < s->nb_streams; i++) { + AVStream *st = s->streams[i]; + if (is_cover_image(st)) + continue; + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) + has_video = 1; + if (st->codecpar->codec_id == AV_CODEC_ID_H264) + has_h264 = 1; + } + + avio_wb32(pb, 0); /* size */ + ffio_wfourcc(pb, "ftyp"); + + // Write major brand + mov_write_ftyp_tag_internal(pb, s, has_h264, has_video, 1); + // Write the major brand as the first compatible brand as well + mov_write_ftyp_tag_internal(pb, s, has_h264, has_video, 0); + + if (mov->mode == MODE_ISM) { ffio_wfourcc(pb, "piff"); } else if (!(mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)) { ffio_wfourcc(pb, "isom"); @@ -4806,13 +4815,7 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) if (mov->flags & FF_MOV_FLAG_FRAGMENT && mov->mode != MODE_ISM) ffio_wfourcc(pb, "iso6"); - if (mov->mode == MODE_3GP) - ffio_wfourcc(pb, has_h264 ? "3gp6":"3gp4"); - else if (mov->mode & MODE_3G2) - ffio_wfourcc(pb, has_h264 ? "3g2b":"3g2a"); - else if (mov->mode == MODE_PSP) - ffio_wfourcc(pb, "MSNV"); - else if (mov->mode == MODE_MP4) + if (mov->mode == MODE_MP4) ffio_wfourcc(pb, "mp41"); if (mov->flags & FF_MOV_FLAG_DASH && mov->flags & FF_MOV_FLAG_GLOBAL_SIDX) |