[FFmpeg-cvslog] avformat/mo: Add experimental demuxing support for Opus in ISO BMFF (MP4).
ffmpeg | branch: master | Matthew Gregan | Thu Mar 16 14:17:21 2017 +1300| [3041b5d03ba3ea5be7f54be62ffa2a586d0fce43] | committer: Michael Niedermayer avformat/mo: Add experimental demuxing support for Opus in ISO BMFF (MP4). Based on the draft spec at http://vfrmaniac.fushizen.eu/contents/opus_in_isobmff.html Signed-off-by: Matthew Gregan Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3041b5d03ba3ea5be7f54be62ffa2a586d0fce43 --- libavformat/mov.c | 49 + 1 file changed, 49 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index f2296f8917..2995a009a8 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5264,6 +5264,54 @@ static int cenc_filter(MOVContext *c, MOVStreamContext *sc, int64_t index, uint8 return 0; } +static int mov_read_dops(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ +const int OPUS_SEEK_PREROLL_MS = 80; +AVStream *st; +size_t size; +int16_t pre_skip; + +if (c->fc->nb_streams < 1) +return 0; +st = c->fc->streams[c->fc->nb_streams-1]; + +if ((uint64_t)atom.size > (1<<30) || atom.size < 11) +return AVERROR_INVALIDDATA; + +/* Check OpusSpecificBox version. */ +if (avio_r8(pb) != 0) { +av_log(c->fc, AV_LOG_ERROR, "unsupported OpusSpecificBox version\n"); +return AVERROR_INVALIDDATA; +} + +/* OpusSpecificBox size plus magic for Ogg OpusHead header. */ +size = atom.size + 8; + +if (ff_alloc_extradata(st->codecpar, size)) +return AVERROR(ENOMEM); + +AV_WL32(st->codecpar->extradata, MKTAG('O','p','u','s')); +AV_WL32(st->codecpar->extradata + 4, MKTAG('H','e','a','d')); +AV_WB8(st->codecpar->extradata + 8, 1); /* OpusHead version */ +avio_read(pb, st->codecpar->extradata + 9, size - 9); + +/* OpusSpecificBox is stored in big-endian, but OpusHead is + little-endian; aside from the preceeding magic and version they're + otherwise currently identical. Data after output gain at offset 16 + doesn't need to be bytewapped. */ +pre_skip = AV_RB16(st->codecpar->extradata + 10); +AV_WL16(st->codecpar->extradata + 10, pre_skip); +AV_WL32(st->codecpar->extradata + 12, AV_RB32(st->codecpar->extradata + 12)); +AV_WL16(st->codecpar->extradata + 16, AV_RB16(st->codecpar->extradata + 16)); + +st->codecpar->initial_padding = pre_skip; +st->codecpar->seek_preroll = av_rescale_q(OPUS_SEEK_PREROLL_MS, + (AVRational){1, 1000}, + (AVRational){1, 48000}); + +return 0; +} + static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('A','C','L','R'), mov_read_aclr }, { MKTAG('A','P','R','G'), mov_read_avid }, @@ -5345,6 +5393,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('d','f','L','a'), mov_read_dfla }, { MKTAG('s','t','3','d'), mov_read_st3d }, /* stereoscopic 3D video box */ { MKTAG('s','v','3','d'), mov_read_sv3d }, /* spherical video box */ +{ MKTAG('d','O','p','s'), mov_read_dops }, { 0, NULL } }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/movenc: Add experimental muxing support for Opus in ISO BMFF (MP4).
ffmpeg | branch: master | Matthew Gregan | Thu Mar 16 14:17:12 2017 +1300| [0c4d2082961f23bb8d5b8f9e963bbecf4147d699] | committer: Michael Niedermayer avformat/movenc: Add experimental muxing support for Opus in ISO BMFF (MP4). Based on the draft spec at http://vfrmaniac.fushizen.eu/contents/opus_in_isobmff.html '-strict -2' is required to create files in this format. Signed-off-by: Matthew Gregan Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0c4d2082961f23bb8d5b8f9e963bbecf4147d699 --- libavformat/isom.c | 2 + libavformat/movenc.c | 137 --- 2 files changed, 131 insertions(+), 8 deletions(-) diff --git a/libavformat/isom.c b/libavformat/isom.c index 7da2700842..3a932dae08 100644 --- a/libavformat/isom.c +++ b/libavformat/isom.c @@ -59,6 +59,7 @@ const AVCodecTag ff_mp4_obj_type[] = { { AV_CODEC_ID_AC3 , 0xA5 }, { AV_CODEC_ID_EAC3, 0xA6 }, { AV_CODEC_ID_DTS , 0xA9 }, /* mp4ra.org */ +{ AV_CODEC_ID_OPUS, 0xAD }, /* mp4ra.org */ { AV_CODEC_ID_VP9 , 0xC0 }, /* nonstandard, update when there is a standard value */ { AV_CODEC_ID_FLAC, 0xC1 }, /* nonstandard, update when there is a standard value */ { AV_CODEC_ID_TSCC2 , 0xD0 }, /* nonstandard, camtasia uses it */ @@ -357,6 +358,7 @@ const AVCodecTag ff_codec_movaudio_tags[] = { { AV_CODEC_ID_EVRC,MKTAG('s', 'e', 'v', 'c') }, /* 3GPP2 */ { AV_CODEC_ID_SMV, MKTAG('s', 's', 'm', 'v') }, /* 3GPP2 */ { AV_CODEC_ID_FLAC,MKTAG('f', 'L', 'a', 'C') }, /* nonstandard */ +{ AV_CODEC_ID_OPUS,MKTAG('O', 'p', 'u', 's') }, /* mp4ra.org */ { AV_CODEC_ID_NONE, 0 }, }; diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 9280dc8d23..f511924fd7 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -677,6 +677,29 @@ static int mov_write_dfla_tag(AVIOContext *pb, MOVTrack *track) return update_size(pb, pos); } +static int mov_write_dops_tag(AVIOContext *pb, MOVTrack *track) +{ +int64_t pos = avio_tell(pb); +avio_wb32(pb, 0); +ffio_wfourcc(pb, "dOps"); +avio_w8(pb, 0); /* Version */ +if (track->par->extradata_size < 19) { +av_log(pb, AV_LOG_ERROR, "invalid extradata size\n"); +return AVERROR_INVALIDDATA; +} +/* extradata contains an Ogg OpusHead, other than byte-ordering and + OpusHead's preceeding magic/version, OpusSpecificBox is currently + identical. */ +avio_w8(pb, AV_RB8(track->par->extradata + 9)); /* OuputChannelCount */ +avio_wb16(pb, AV_RL16(track->par->extradata + 10)); /* PreSkip */ +avio_wb32(pb, AV_RL32(track->par->extradata + 12)); /* InputSampleRate */ +avio_wb16(pb, AV_RL16(track->par->extradata + 16)); /* OutputGain */ +/* Write the rest of the header out without byte-swapping. */ +avio_write(pb, track->par->extradata + 18, track->par->extradata_size - 18); + +return update_size(pb, pos); +} + static int mov_write_chan_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track) { uint32_t layout_tag, bitmap; @@ -986,19 +1009,26 @@ static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex avio_wb16(pb, 16); avio_wb16(pb, track->audio_vbr ? -2 : 0); /* compression ID */ } else { /* reserved for mp4/3gp */ -if (track->par->codec_id == AV_CODEC_ID_FLAC) { +if (track->par->codec_id == AV_CODEC_ID_FLAC || +track->par->codec_id == AV_CODEC_ID_OPUS) { avio_wb16(pb, track->par->channels); -avio_wb16(pb, track->par->bits_per_raw_sample); } else { avio_wb16(pb, 2); +} +if (track->par->codec_id == AV_CODEC_ID_FLAC) { +avio_wb16(pb, track->par->bits_per_raw_sample); +} else { avio_wb16(pb, 16); } avio_wb16(pb, 0); } avio_wb16(pb, 0); /* packet size (= 0) */ -avio_wb16(pb, track->par->sample_rate <= UINT16_MAX ? - track->par->sample_rate : 0); +if (track->par->codec_id == AV_CODEC_ID_OPUS) +avio_wb16(pb, 48000); +else +avio_wb16(pb, track->par->sample_rate <= UINT16_MAX ? + track->par->sample_rate : 0); avio_wb16(pb, 0); /* Reserved */ } @@ -1039,6 +1069,8 @@ static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex mov_write_wfex_tag(s, pb, tr
[FFmpeg-cvslog] avformat/movenc: Fix potential leak of sgpd_entries array.
ffmpeg | branch: master | Matthew Gregan | Wed Apr 12 14:12:17 2017 +1200| [b905ba5bc18c89c7fccd862179575562ef19] | committer: Michael Niedermayer avformat/movenc: Fix potential leak of sgpd_entries array. Signed-off-by: Matthew Gregan Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b905ba5bc18c89c7fccd862179575562ef19 --- libavformat/movenc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index e6a70bffc0..e6e2313c53 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2286,8 +2286,10 @@ static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track) } entries++; -if (!group) +if (!group) { +av_free(sgpd_entries); return 0; +} /* Write sgpd tag */ avio_wb32(pb, 24 + (group * 2)); /* size */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Add experimental muxing support for FLAC in ISO BMFF (MP4).
ffmpeg | branch: master | Matthew Gregan | Thu Oct 20 17:28:11 2016 +1300| [7dc4200c3828195ef33c8a6572891ecda5058cd6] | committer: James Almer Add experimental muxing support for FLAC in ISO BMFF (MP4). Based on the draft spec at https://git.xiph.org/?p=flac.git;a=blob;f=doc/isoflac.txt '-strict experimental' is required to create files in this format. Signed-off-by: Matthew Gregan Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7dc4200c3828195ef33c8a6572891ecda5058cd6 --- libavformat/isom.c | 2 ++ libavformat/movenc.c | 49 ++--- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/libavformat/isom.c b/libavformat/isom.c index 1fa46bd..cd0b0b7 100644 --- a/libavformat/isom.c +++ b/libavformat/isom.c @@ -60,6 +60,7 @@ const AVCodecTag ff_mp4_obj_type[] = { { AV_CODEC_ID_EAC3, 0xA6 }, { AV_CODEC_ID_DTS , 0xA9 }, /* mp4ra.org */ { AV_CODEC_ID_VP9 , 0xC0 }, /* nonstandard, update when there is a standard value */ +{ AV_CODEC_ID_FLAC, 0xC1 }, /* nonstandard, update when there is a standard value */ { AV_CODEC_ID_TSCC2 , 0xD0 }, /* nonstandard, camtasia uses it */ { AV_CODEC_ID_VORBIS , 0xDD }, /* nonstandard, gpac uses it */ { AV_CODEC_ID_DVD_SUBTITLE, 0xE0 }, /* nonstandard, see unsupported-embedded-subs-2.mp4 */ @@ -345,6 +346,7 @@ const AVCodecTag ff_codec_movaudio_tags[] = { { AV_CODEC_ID_WMAV2, MKTAG('W', 'M', 'A', '2') }, { AV_CODEC_ID_EVRC,MKTAG('s', 'e', 'v', 'c') }, /* 3GPP2 */ { AV_CODEC_ID_SMV, MKTAG('s', 's', 'm', 'v') }, /* 3GPP2 */ +{ AV_CODEC_ID_FLAC,MKTAG('f', 'L', 'a', 'C') }, /* nonstandard */ { AV_CODEC_ID_NONE, 0 }, }; diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 5452ff7..e75a5c5 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -33,6 +33,7 @@ #include "avc.h" #include "libavcodec/ac3_parser.h" #include "libavcodec/dnxhddata.h" +#include "libavcodec/flac.h" #include "libavcodec/get_bits.h" #include "libavcodec/put_bits.h" #include "libavcodec/vc1_common.h" @@ -655,6 +656,26 @@ static int mov_write_wfex_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra return update_size(pb, pos); } +static int mov_write_dfla_tag(AVIOContext *pb, MOVTrack *track) +{ +int64_t pos = avio_tell(pb); +avio_wb32(pb, 0); +ffio_wfourcc(pb, "dfLa"); +avio_w8(pb, 0); /* version */ +avio_wb24(pb, 0); /* flags */ + +/* Expect the encoder to pass a METADATA_BLOCK_TYPE_STREAMINFO. */ +if (track->par->extradata_size != FLAC_STREAMINFO_SIZE) +return AVERROR_INVALIDDATA; + +/* TODO: Write other METADATA_BLOCK_TYPEs if the encoder makes them available. */ +avio_w8(pb, 1 << 7 | FLAC_METADATA_TYPE_STREAMINFO); /* LastMetadataBlockFlag << 7 | BlockType */ +avio_wb24(pb, track->par->extradata_size); /* Length */ +avio_write(pb, track->par->extradata, track->par->extradata_size); /* BlockData[Length] */ + +return update_size(pb, pos); +} + static int mov_write_chan_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track) { uint32_t layout_tag, bitmap; @@ -964,8 +985,13 @@ static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex avio_wb16(pb, 16); avio_wb16(pb, track->audio_vbr ? -2 : 0); /* compression ID */ } else { /* reserved for mp4/3gp */ -avio_wb16(pb, 2); -avio_wb16(pb, 16); +if (track->par->codec_id == AV_CODEC_ID_FLAC) { +avio_wb16(pb, track->par->channels); +avio_wb16(pb, track->par->bits_per_raw_sample); +} else { +avio_wb16(pb, 2); +avio_wb16(pb, 16); +} avio_wb16(pb, 0); } @@ -1010,6 +1036,8 @@ static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex mov_write_extradata_tag(pb, track); else if (track->par->codec_id == AV_CODEC_ID_WMAPRO) mov_write_wfex_tag(s, pb, track); +else if (track->par->codec_id == AV_CODEC_ID_FLAC) +mov_write_dfla_tag(pb, track); else if (track->vos_len > 0) mov_write_glbl_tag(pb, track); @@ -1178,6 +1206,7 @@ static int mp4_get_codec_tag(AVFormatContext *s, MOVTrack *track) else if (track->par->codec_id == AV_CODEC_ID_DIRAC) tag = MKTAG('d','r','a','c'); else if (track->par->codec_id == AV_CODEC_ID_MOV_TEXT) tag = MKTAG('t',
[FFmpeg-cvslog] Add experimental demuxing support for FLAC in ISO BMFF (MP4).
ffmpeg | branch: master | Matthew Gregan | Fri Oct 21 16:10:43 2016 +1300| [2d73d25670ced04a7ef7e0936e340292816ef7db] | committer: James Almer Add experimental demuxing support for FLAC in ISO BMFF (MP4). Based on the draft spec at https://git.xiph.org/?p=flac.git;a=blob;f=doc/isoflac.txt Signed-off-by: Matthew Gregan Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2d73d25670ced04a7ef7e0936e340292816ef7db --- libavformat/mov.c | 39 +++ 1 file changed, 39 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 9cd0398..9bbb155 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -44,6 +44,7 @@ #include "libavutil/sha.h" #include "libavutil/timecode.h" #include "libavcodec/ac3tab.h" +#include "libavcodec/flac.h" #include "libavcodec/mpegaudiodecheader.h" #include "avformat.h" #include "internal.h" @@ -4742,6 +4743,43 @@ static int mov_read_saiz(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int mov_read_dfla(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ +AVStream *st; +int last, type, size, ret; +uint8_t buf[4]; + +if (c->fc->nb_streams < 1) +return 0; +st = c->fc->streams[c->fc->nb_streams-1]; + +if ((uint64_t)atom.size > (1<<30) || atom.size < 42) +return AVERROR_INVALIDDATA; + +/* Check FlacSpecificBox version. */ +if (avio_r8(pb) != 0) +return AVERROR_INVALIDDATA; + +avio_rb24(pb); /* Flags */ + +avio_read(pb, buf, sizeof(buf)); +flac_parse_block_header(buf, &last, &type, &size); + +if (type != FLAC_METADATA_TYPE_STREAMINFO || size != FLAC_STREAMINFO_SIZE) { +av_log(c->fc, AV_LOG_ERROR, "STREAMINFO must be first FLACMetadataBlock\n"); +return AVERROR_INVALIDDATA; +} + +ret = ff_get_extradata(c->fc, st->codecpar, pb, size); +if (ret < 0) +return ret; + +if (!last) +av_log(c->fc, AV_LOG_WARNING, "non-STREAMINFO FLACMetadataBlock(s) ignored\n"); + +return 0; +} + static int cenc_filter(MOVContext *c, MOVStreamContext *sc, uint8_t *input, int size) { uint32_t encrypted_bytes; @@ -4916,6 +4954,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('f','r','m','a'), mov_read_frma }, { MKTAG('s','e','n','c'), mov_read_senc }, { MKTAG('s','a','i','z'), mov_read_saiz }, +{ MKTAG('d','f','L','a'), mov_read_dfla }, { 0, NULL } }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/movenc: Restrict experimental VP9 support to MODE_MP4.
ffmpeg | branch: master | Matthew Gregan | Fri Nov 18 16:29:42 2016 +1300| [156fbbb562f36f6dcaf363fb3029834c28519dc7] | committer: James Almer avformat/movenc: Restrict experimental VP9 support to MODE_MP4. Signed-off-by: Matthew Gregan Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=156fbbb562f36f6dcaf363fb3029834c28519dc7 --- libavformat/movenc.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index e75a5c5..dc19838 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -5744,8 +5744,11 @@ static int mov_init(AVFormatContext *s) pix_fmt == AV_PIX_FMT_MONOWHITE || pix_fmt == AV_PIX_FMT_MONOBLACK; } -if (track->mode == MODE_MP4 && -track->par->codec_id == AV_CODEC_ID_VP9) { +if (track->par->codec_id == AV_CODEC_ID_VP9) { +if (track->mode != MODE_MP4) { +av_log(s, AV_LOG_ERROR, "VP9 only supported in MP4.\n"); +return AVERROR(EINVAL); +} if (s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { av_log(s, AV_LOG_ERROR, "VP9 in MP4 support is experimental, add " ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/mov: Enable stream parsing for VP9.
ffmpeg | branch: master | Matthew Gregan | Wed Sep 7 13:58:30 2016 +1200| [7b3bc365f9923e30a925f8dece4fddd127a54c5d] | committer: Ronald S. Bultje avformat/mov: Enable stream parsing for VP9. MP4 media containing VP9 using superframes (such as https://github.com/Netflix/vp9-dash/raw/master/DASH-Samples/Fountain_2997_0560kbps_640x480_4x3PAR.ivf_DashUnencrypted.ismv) does not decode correctly with the built-in VP9 decoder because superframes are passed to the decoder whole rather than split into individual frames. Signed-off-by: Matthew Gregan > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7b3bc365f9923e30a925f8dece4fddd127a54c5d --- libavformat/mov.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index a7595c5..6e80b93 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2161,6 +2161,7 @@ static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb, case AV_CODEC_ID_EAC3: case AV_CODEC_ID_MPEG1VIDEO: case AV_CODEC_ID_VC1: +case AV_CODEC_ID_VP9: st->need_parsing = AVSTREAM_PARSE_FULL; break; default: ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog