[FFmpeg-user] ffmpeg-2.1 + setsar + setdar question

David Favor david at davidfavor.com
Thu Oct 31 16:23:57 CET 2013


Two items covered in this message.

1) Docs for setdar + setsar should be changed to reflect how
    ordering these filters produces different results.

2) Question about how to do video stream copy (maybe via filter)
    when the only operation is to strip/change SAR + DAR.

    So... is there something like '-vf copy' I'm missing?

    Thanks.

Versions of x264 + video dump attached at the end of this message.

I have this weird video which has - 720x406 [SAR 64757:64800 DAR 319:180] - which
causes 4:3 aspect ratio rather than 16:9 on most playback devices.

My goal is to rewrap the video stream (no transcode) to preserve quality.

First setsar + setdar work oddly.

The avinfo script just scrapes out Duration + Streams to make text more readable... so...
_______

Original shows [SAR 64757:64800 DAR 319:180]

David-Favor-iMac# avinfo broken.mp4
broken.mp4
    Duration: 00:42:19.96, start: 0.000000, bitrate: 938 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x406 [SAR 64757:64800 DAR 319:180], 810 kb/s, 23.98 fps, 23.98 tbr, 23976 
tbn, 47.95 tbc (default)
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 122 kb/s (default)
_______

Simple transcode changes this to the equally odd [SAR 1506:1507 DAR 542160:305921] which
surfaces why playback codecs are choosing 4:3 as neither SAR or DAR are sensible values.

ffmpeg -y -i broken.mp4 -c:a copy -c:v libx264 -crf 20 -preset:v veryfast -t 10 test1.mp4 2>/dev/null && avinfo test1.mp4
test1.mp4
    Duration: 00:00:10.01, start: 0.000000, bitrate: 1087 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x406 [SAR 1506:1507 DAR 542160:305921], 944 kb/s, SAR 64757:64800 DAR 
319:180, 23.98 fps, 23.98 tbr, 11988 tbn, 47.95 tbc (default)
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 136 kb/s (default)
______

It appears using the setsar + setdar filters are the only way to change this...

Here's some more oddity, as the order of setsar + setdar produce different results.
Not a big deal + this was confusing. Probably best to document that...

     setdar must come first, as setsar depends on DAR value
_____

This transcode should have stripped SAR + DAR... It did not... because
of order of setsar + setdar filters.

David-Favor-iMac# ffmpeg -y -i broken.mp4 -c:a copy -c:v libx264 -crf 20 -preset:v veryfast -vf setsar=sar=0 -vf setdar=dar=0 -t 10 test.mp4 
2>/dev/null && avinfo test.mp4
test.mp4
    Duration: 00:00:10.01, start: 0.000000, bitrate: 1087 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x406 [SAR 1:1 DAR 360:203], 944 kb/s, 23.98 fps, 23.98 tbr, 11988 tbn, 47.95 
tbc (default)
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 136 kb/s (default)
_____

This transcode worked! SAR + DAR are both stripped, so playback devices
decode via 720x406 size, so likely all will be well.

David-Favor-iMac# ffmpeg -y -i broken.mp4 -c:a copy -c:v libx264 -crf 20 -preset:v veryfast -vf setdar=dar=0 -vf setsar=sar=0 -t 10 test.mp4 
2>/dev/null && avinfo test.mp4
test.mp4
    Duration: 00:00:10.01, start: 0.000000, bitrate: 1087 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x406, 944 kb/s, 23.98 fps, 23.98 tbr, 11988 tbn, 47.95 tbc (default)
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 136 kb/s (default)
_____

Since a filter is the only way to strip/change SAR + DAR a transcode is required.

I find no filter to pass through video unchanged... What I'm asking for is a filter
to do the same as -c:v copy. Someone let me know if this exists.

Thanks.

_____

David-Favor-iMac# x264 -V
x264 2013-10-30-138-2245
(libswscale 2.5.101)
(libavformat 55.19.104)
built on Oct 31 2013, gcc: 4.8.2
configuration: --bit-depth=8 --chroma-format=all
x264 license: GPL version 2 or later
libswscale/libavformat license: nonfree and unredistributable
WARNING: This binary is unredistributable!

David-Favor-iMac# ffmpeg -i broken.mp4
ffmpeg version 2.1.0-2013-10-31-57660-g49287bb Copyright (c) 2000-2013 the FFmpeg developers
   built on Oct 31 2013 08:52:34 with gcc 4.8.2 (MacPots gcc48 4.8.2_0)
   configuration: --prefix=/david-favor-tools/osx-10.9 --enable-pic --enable-gpl --disable-debug --extra-cflags='-I 
/david-favor-tools/osx-10.9/include -I /opt/local/include' --extra-ldflags='-Wl,-rpath,/david-favor-tools/osx-10.9/lib -Wl,-rpath,/opt/local/lib -L 
/david-favor-tools/osx-10.9/lib -L /opt/local/lib' --enable-version3 --enable-shared --disable-static --enable-ffplay --enable-ffprobe 
--enable-ffserver --enable-runtime-cpudetect --enable-nonfree --enable-zlib --enable-bzlib --enable-openssl --enable-libmp3lame --enable-libfaac 
--enable-libvpx --enable-libtheora --enable-libvorbis --enable-libxvid --enable-libopus --enable-libopenjpeg --enable-libfreetype --enable-libx264 
--enable-postproc --enable-frei0r --enable-libopencore-amrnb --enable-libmodplug --enable-libass --enable-openssl
   libavutil      52. 48.100 / 52. 48.100
   libavcodec     55. 39.100 / 55. 39.100
   libavformat    55. 19.104 / 55. 19.104
   libavdevice    55.  5.100 / 55.  5.100
   libavfilter     3. 90.100 /  3. 90.100
   libswscale      2.  5.101 /  2.  5.101
   libswresample   0. 17.104 /  0. 17.104
   libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'broken.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : muxer
   Duration: 00:42:19.96, start: 0.000000, bitrate: 938 kb/s
     Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x406 [SAR 64757:64800 DAR 319:180], 810 kb/s, 23.98 fps, 23.98 tbr, 23976 
tbn, 47.95 tbc (default)
     Metadata:
       handler_name    : VideoHandler
     Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 122 kb/s (default)
     Metadata:
       handler_name    : SoundHandler

-- 
Love Living Well Doing What You Love?
http://DavidFavor.com/books can help!


More information about the ffmpeg-user mailing list