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

David Favor david at davidfavor.com
Thu Oct 31 17:07:02 CET 2013


Carl Eugen Hoyos wrote:
> David Favor <david <at> davidfavor.com> writes:
> 
>> Question about how to do video stream copy (maybe via filter)
>> when the only operation is to strip/change SAR + DAR.
> 
> Use the command line option -aspect with -vcodec copy

This has no effect on SAR or DAR....

David-Favor-iMac# ffmpeg -y -i broken.mp4 -c:a copy -c:v copy -aspect 16:9 -t 10 test.mp4 2>/dev/null && avinfo test.mp4
test.mp4
    Duration: 00:00:10.09, start: 0.000000, bitrate: 1202 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x406 [SAR 64757:64800 DAR 319:180], 1060 kb/s, SAR 406:405 DAR 16:9, 23.98 
fps, 23.98 tbr, 23976 tbn, 47.95 tbc (default)
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 136 kb/s (default)

>> 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 
> 
>> 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 

This produces DAR 360:203 instead of DAR 720:406

David-Favor-iMac# ffmpeg -y -i broken.mp4 -c:a copy -c:v libx264 -crf 20 -preset:v veryfast -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 is even more broken...

David-Favor-iMac# ffmpeg -y -i broken.mp4 -c:a copy -c:v libx264 -crf 20 -preset:v veryfast -vf setdar=dar=720:496 -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 203:248 DAR 45:31], 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 also broken...

David-Favor-iMac# ffmpeg -y -i broken.mp4 -c:a copy -c:v libx264 -crf 20 -preset:v veryfast -vf setdar=dar=720:496 -vf setsar=sar=1:1 -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)

> These are equally broken in two ways:
> Don't use -vf setdar -vf setsar, either use one or the 
> other, in your case either:
> -vf setsar=sar=x/y (sorry, too lazy to calculate)
> or:
> -vf setdar=dar=4/3
> To set a display aspect ratio of 4/3 (assuming this is 
> what you want).
> Don't set a ratio of 0, this seems not correct to me 
> unless you know a specific reason why.

Docs say "0" removes info.

Only sensible results seem to be to completely remove SAR + DAR.

> Note that I suspect the original ratio is simply correct 
> and the result of cropping.
> 
> What is avinfo?

Simple script that scrapes stream + duration line from ffmpeg output.

> Carl Eugen
> 
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user


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


More information about the ffmpeg-user mailing list