[FFmpeg-devel] [PATCH] avformat/mxfenc: support XAVC long gop

Baptiste Coudurier baptiste.coudurier at gmail.com
Tue May 14 01:33:29 EEST 2019


Hi Thomas

> On May 13, 2019, at 3:11 PM, Thomas Mundt <tmundt75 at gmail.com> wrote:
> 
> Hi Baptiste,
> 
> Am Fr., 10. Mai 2019 um 17:51 Uhr schrieb Baptiste Coudurier <
> baptiste.coudurier at gmail.com>:
> 
>> ---
>> libavformat/Makefile |   2 +-
>> libavformat/avc.c    | 188 ++++++++++++++++++++++++++++++++++++++
>> libavformat/avc.h    |  15 +++
>> libavformat/hevc.c   |  36 +-------
>> libavformat/mxf.h    |   1 +
>> libavformat/mxfenc.c | 213 ++++++++++++++++++++++++++++++++++---------
>> 6 files changed, 374 insertions(+), 81 deletions(-)
>> [...]
> 
> +static const MXFLocalTagPair mxf_avc_subdescriptor_local_tags[] = {
>> +    { 0x8100,
>> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x04,0x06,0x10,0x00,0x00}},
>> /* SubDescriptors */
>> +    { 0x8200,
>> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x0E,0x04,0x01,0x06,0x06,0x01,0x0E,0x00,0x00}},
>> /* AVC Decoding Delay */
>> +    { 0x8201,
>> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x0E,0x04,0x01,0x06,0x06,0x01,0x0A,0x00,0x00}},
>> /* AVC Profile */
>> +    { 0x8202,
>> {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x0E,0x04,0x01,0x06,0x06,0x01,0x0D,0x00,0x00}},
>> /* AVC Level */
>> +};
>> +
>> [...]
>> +static void mxf_write_avc_subdesc(AVFormatContext *s, AVStream *st)
>> +{
>> +    AVIOContext *pb = s->pb;
>> +    int64_t pos;
>> +
>> +    avio_write(pb, mxf_avc_subdescriptor_key, 16);
>> +    klv_encode_ber4_length(pb, 0);
>> +    pos = avio_tell(pb);
>> +
>> +    mxf_write_local_tag(pb, 16, 0x3C0A);
>> +    mxf_write_uuid(pb, AVCSubDescriptor, 0);
>> +
>> +    mxf_write_local_tag(pb, 1, 0x8200);
>> +    avio_w8(pb, 0xFF); // AVC Decoding Delay, unknown
>> +
>> +    mxf_write_local_tag(pb, 1, 0x8201);
>> +    avio_w8(pb, st->codecpar->profile); // AVC Profile
>> +
>> +    mxf_write_local_tag(pb, 1, 0x8202);
>> +    avio_w8(pb, st->codecpar->level); // AVC Level
>> +
>> +    mxf_update_klv_size(s->pb, pos);
>> +}
>> 
> 
> Other MXF muxers, e.g. bmxlib, also write the avc profile constraint tag
> when the avc subdescriptor is used. At least MediaInfo detects intra coded
> files as long gop otherwise.

I prefer not writing optional values unless actually required by actual decoders.
I think MediaInfo should be fixed in this case, it is obviously wrong.

> FFmpeg crashes with this patch when I try to remux AVC Intra files without
> SPS/PPS header.
> Tested on Windows 7. Compiled with msys2/gcc7.3.0 x86-32bit.
> Command: ffmpeg -i AVCI100_Test.mxf -c:v copy out.mxf
> Test file:
> https://www.mediafire.com/file/n0oi50u39yi3qpr/AVCI100_Test.mxf/file <https://www.mediafire.com/file/n0oi50u39yi3qpr/AVCI100_Test.mxf/file>

Strange, why doesn’t gcc emit a warning for SPS might be initialized in this case…
Fixed in an updated patch.

— 
Baptiste



More information about the ffmpeg-devel mailing list