[FFmpeg-user] Setting Display Aspect Ratio of MXF/DV video

Marc Tarin ch0d4 at free.fr
Mon Apr 13 15:35:15 CEST 2015


Hi everyone.

First of all, let me apologize for this long message.

I have a DV video wrapped in an MXF container, fed to a workflow that
uses either FFmpeg or FFmbc to transcode videos. I have noticed
differences between the two tools when processing MXF/DV files.

The tests described below where run with an up to date FFmpeg release
from the debian multimedia repository:


$> ffprobe in.mxf
ffprobe version 2.6.1 Copyright (c) 2007-2015 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/x86_64-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libpulse --disable-mips32r2 --disable-mipsdspr1 --disable-mipsdspr2 --enable-libvidstab --enable-libzvbi --enable-avresample --disable-htmlpages --disable-podpages --enable-libutvideo --enable-libfdk-aac --enable-libx265 --enable-libiec61883 --enable-vaapi --enable-libdc1394 --disable-altivec --shlibdir=/usr/lib/x86_64-linux-gnu
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mxf, from 'in.mxf':
  Metadata:
    uid             : 0d1f60e1-9d8c-11e4-ad31-90e2ba22a666
    generation_uid  : 0d1f60e2-9d8c-11e4-955f-90e2ba22a666
    company_name    : Harris Corporation
    product_name    : Nexio MXFConverter
    product_version : 4.4.18.0
    application_platform: win32
    product_uid     : c03d2336-97c9-7410-9138-001111be66ea
    modification_date: 2015-01-16 11:12:12
    material_package_umid: 0x060A2B340101010501010D21130001005895FC809D7011E487B6002590D00BD4
    timecode        : 10:00:00:00
  Duration: 00:02:11.48, start: 0.000000, bitrate: 32257 kb/s
    Stream #0:0: Video: dvvideo, yuv420p, 720x576 [SAR 16:15 DAR 4:3], 25 fps, 25 tbr, 25 tbn, 25 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D1213216F0AEFD91B03387005A56EA790E2BA22A666
      file_package_name: Source Package
...


A bit of context: the input file is supposed to be broadcasted in
16:9, but as you can see it is reported as 4:3 by ffprobe.
In reality, because of editing errors source-side, some parts of the
video essence actually have a display aspect ratio of 4:3 and others
16:9...
Anyway, for an MXF file the aspect ratio is specified in the Essence
Descriptor of the Header Metadata, so I ran the following command:


$> ffmpeg -i in.mxf -vcodec copy -aspect "16:9" -an out_copy.mxf
...
Overriding aspect ratio with stream copy may produce invalid files
Output #0, mxf, to 'out_copy.mxf':
  Metadata:
    uid             : 0d1f60e1-9d8c-11e4-ad31-90e2ba22a666
    generation_uid  : 0d1f60e2-9d8c-11e4-955f-90e2ba22a666
    company_name    : Harris Corporation
    product_name    : Nexio MXFConverter
    product_version : 4.4.18.0
    application_platform: win32
    product_uid     : c03d2336-97c9-7410-9138-001111be66ea
    modification_date: 2015-01-16 11:12:12
    material_package_umid: 0x060A2B340101010501010D21130001005895FC809D7011E487B6002590D00BD4
    timecode        : 10:00:00:00
    encoder         : Lavf56.25.101
    Stream #0:0: Video: dvvideo, yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=2-31, 25 fps, 25 tbr, 25 tbn, 25 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D1213216F0AEFD91B03387005A56EA790E2BA22A666
      file_package_name: Source Package
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 3287 fps=641 q=-1.0 Lsize=  465116kB time=00:02:11.48 bitrate=28979.5kbits/s
video:462234kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.623313%


To no avail... ffmpeg says the DAR is 16:9, but it isn't. ffprobe shows
no information at the container level:


$> ffprobe out_copy.mxf
Input #0, mxf, from 'out_copy.mxf':
  Metadata:
    uid             : adab4424-2f25-4dc7-92ff-29bd000c0000
    generation_uid  : adab4424-2f25-4dc7-92ff-29bd000c0001
    company_name    : FFmpeg
    product_name    : OP1a Muxer
    product_version : 56.25.101
    product_uid     : adab4424-2f25-4dc7-92ff-29bd000c0002
    modification_date: 0-01-01 00:00:00
    material_package_umid: 0x060A2B340101010501010D0013834AFC529471341B834AFC00529471341B8300
    timecode        : 10:00:00:00
  Duration: 00:02:11.48, start: 0.000000, bitrate: 28979 kb/s
    Stream #0:0: Video: dvvideo, yuv420p, 720x576 [SAR 16:15 DAR 4:3], 25 fps, 25 tbr, 25 tbn, 25 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D0013834AFC529471341B834AFC00529471341B8301


Second step, instead of copying the essence, I re-encoded it, keeping
the DV format:


$> ffmpeg -i in.mxf -vcodec copy -aspect "16:9" -an out_dvvideo.mxf
...
Output #0, mxf, to 'out_dvvideo.mxf':
  Metadata:
    uid             : 0d1f60e1-9d8c-11e4-ad31-90e2ba22a666
    generation_uid  : 0d1f60e2-9d8c-11e4-955f-90e2ba22a666
    company_name    : Harris Corporation
    product_name    : Nexio MXFConverter
    product_version : 4.4.18.0
    application_platform: win32
    product_uid     : c03d2336-97c9-7410-9138-001111be66ea
    modification_date: 2015-01-16 11:12:12
    material_package_umid: 0x060A2B340101010501010D21130001005895FC809D7011E487B6002590D00BD4
    timecode        : 10:00:00:00
    encoder         : Lavf56.25.101
    Stream #0:0: Video: dvvideo, yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D1213216F0AEFD91B03387005A56EA790E2BA22A666
      file_package_name: Source Package
      encoder         : Lavc56.26.100 dvvideo
Stream mapping:
  Stream #0:0 -> #0:0 (dvvideo (native) -> dvvideo (native))
Press [q] to stop, [?] for help
frame= 3287 fps=373 q=0.0 Lsize=  465116kB time=00:02:11.48 bitrate=28979.5kbits/s
video:462234kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.623313%


This time, ffprobe also gets a DAR at the container level, but it is 4:3!
The output video still displays in the wrong format:


$> ffprobe out_dvvideo.mxf
Input #0, mxf, from 'out_dvvideo.mxf':
  Metadata:
    uid             : adab4424-2f25-4dc7-92ff-29bd000c0000
    generation_uid  : adab4424-2f25-4dc7-92ff-29bd000c0001
    company_name    : FFmpeg
    product_name    : OP1a Muxer
    product_version : 56.25.101
    product_uid     : adab4424-2f25-4dc7-92ff-29bd000c0002
    modification_date: 0-01-01 00:00:00
    material_package_umid: 0x060A2B340101010501010D00137D1E6C529471343F7D1E6C00529471343F7D00
    timecode        : 10:00:00:00
  Duration: 00:02:11.48, start: 0.000000, bitrate: 28979 kb/s
    Stream #0:0: Video: dvvideo, yuv420p, 720x576 [SAR 64:45 DAR 16:9], SAR 16:15 DAR 4:3, 25 fps, 25 tbr, 25 tbn, 25 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D00137D1E6C529471343F7D1E6C00529471343F7D01


Out of curiosity, I extracted essence from out_dvvideo.mxf:


$> ffmpeg -i out_dvvideo.mxf -vcodec copy out_dvvideo.dv
...
Input #0, mxf, from 'out_dvvideo.mxf':
  Metadata:
    uid             : adab4424-2f25-4dc7-92ff-29bd000c0000
    generation_uid  : adab4424-2f25-4dc7-92ff-29bd000c0001
    company_name    : FFmpeg
    product_name    : OP1a Muxer
    product_version : 56.25.101
    product_uid     : adab4424-2f25-4dc7-92ff-29bd000c0002
    modification_date: 0-01-01 00:00:00
    material_package_umid: 0x060A2B340101010501010D0013239D0E52947134EB239D0E0052947134EB2300
    timecode        : 10:00:00:00
  Duration: 00:02:11.48, start: 0.000000, bitrate: 28979 kb/s
    Stream #0:0: Video: dvvideo, yuv420p, 720x576 [SAR 64:45 DAR 16:9], SAR 16:15 DAR 4:3, 25 fps, 25 tbr, 25 tbn, 25 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D0013239D0E52947134EB239D0E0052947134EB2301
Output #0, dv, to 'out_dvvideo.dv':
  Metadata:
    uid             : adab4424-2f25-4dc7-92ff-29bd000c0000
    generation_uid  : adab4424-2f25-4dc7-92ff-29bd000c0001
    company_name    : FFmpeg
    product_name    : OP1a Muxer
    product_version : 56.25.101
    product_uid     : adab4424-2f25-4dc7-92ff-29bd000c0002
    modification_date: 0-01-01 00:00:00
    material_package_umid: 0x060A2B340101010501010D0013239D0E52947134EB239D0E0052947134EB2300
    timecode        : 10:00:00:00
    encoder         : Lavf56.25.101
    Stream #0:0: Video: dvvideo, yuv420p, 720x576 [SAR 16:15 DAR 4:3], q=2-31, 25 fps, 25 tbr, 25 tbn, 25 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D0013239D0E52947134EB239D0E0052947134EB2301
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 3287 fps=662 q=-1.0 Lsize=  462234kB time=00:02:11.48 bitrate=28800.0kbits/s
video:462234kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%


The extracted DV file is actually 16:9:


$> ffprobe out_dvvideo.dv
...
[dv @ 0xe3ca80] Estimating duration from bitrate, this may be inaccurate
Input #0, dv, from 'out_dvvideo.dv':
  Metadata:
    timecode        : 10:00:00:00
  Duration: 00:02:11.48, start: 0.000000, bitrate: 28800 kb/s
    Stream #0:0: Video: dvvideo, yuv420p, 720x576 [SAR 64:45 DAR 16:9], 28800 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc

$> ffprobe -show_frames out_dvvideo.dv | grep aspect | sort -u
[dv @ 0x2411a80] Estimating duration from bitrate, this may be inaccurate
Input #0, dv, from 'out_dvvideo.dv':
  Metadata:
    timecode        : 10:00:00:00
  Duration: 00:02:11.48, start: 0.000000, bitrate: 28800 kb/s
    Stream #0:0: Video: dvvideo, yuv420p, 720x576 [SAR 64:45 DAR 16:9], 28800 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
sample_aspect_ratio=64:45


At this point, my understanding is that the MXF container is always
assigned a display aspect ratio of 4:3, even when it should be
assigned 16:9.

I'll skip the output for the rest of my tests, but it turns out that
when streamcopying but remux-ing to MOV, AVI or MKV, I do get a file
with the expected 16:9 DAR.

FYI, using FFbmc-0.7rc8, compiled with default options, I still
can't remux the MXF to 16:9 as with MOV/AVI/MKV when streamcopying,
but if I reencode to dvvideo, I do get the expected 16:9 ratio.


Am I getting something wrong?


Regards


More information about the ffmpeg-user mailing list