[FFmpeg-devel] Scale filter bug
Alexander Bokovikov
openworld at uralweb.ru
Fri Dec 9 16:01:26 CET 2011
Hi, All,
The scale filer being applied to produce M4V or MP4 file format
inserts wrong pixel aspect ratio box, and incorrectly sets the frame
size in the track header box. As a result target aspect ratio is the
same as source file aspect ratio, though I've defined target width and
height explicitly. The same effect appears if I use -s WxH parameter
instead of -vf scale=W:H one.
As I believe the problem is here:
[SAR 25:36 DAR 5:3]
instead of
[SAR 1:1 DAR 12:5]
Changing the values by manual boxes editing I get correct movie. I.e.
the problem isn't in a wrong stream encoding, but just in wrong MP4
boxes writing. Taking into account that 12:5 = (36x5)/(25x3) (see
digits above), I believe the bug is in these calculations - wrong
digits are at wrong places. Something like that.
Here is the source FLV file:
http://home.bokovikov.com/ffmpeg/video5.flv
Here is converted M4V file:
http://home.bokovikov.com/ffmpeg/video5.m4v
Here is the command line:
./ffmpeg -i video5.flv -f ipod -vcodec libx264 -vprofile baseline -
level 30 -maxrate 10000000 -bufsize 10000000 -vf scale=720:300 -acodec
copy -threads 0 -y video5.m4v
And here is the output:
ffmpeg version N-35462-g61b1d85, Copyright (c) 2000-2011 the FFmpeg
developers
built on Dec 7 2011 17:25:26 with gcc 4.0.1 (Apple Inc. build 5493)
configuration: --enable-static --enable-memalign-hack --enable-gpl --
enable-libx264 --disable-doc --disable-ffserver --disable-ffplay --
disable-ffprobe --enable-pthreads --enable-runtime-cpudetect --disable-
network --disable-shared --disable-filters --disable-decoders --
disable-encoders --disable-muxers --disable-demuxers --disable-parsers
--disable-bsfs --disable-protocols --disable-devices --enable-
filter=crop --enable-filter=scale --enable-protocol=file --enable-
decoder=aac --enable-decoder=h263 --enable-decoder=flv --enable-
decoder=vp6f --enable-decoder=vp6a --enable-decoder=h264 --enable-
decoder=nellymoser --enable-decoder=mp3 --enable-encoder=libx264 --
enable-encoder=flv --enable-encoder=aac --enable-parser=h264 --enable-
parser=mpegaudio --enable-demuxer=flv --enable-muxer=ipod --enable-
muxer=mp4 --enable-demuxer=mp4 --enable-encoder=mjpeg --enable-
demuxer=mov --enable-muxer=mjpeg
libavutil 51. 30. 0 / 51. 30. 0
libavcodec 53. 40. 0 / 53. 40. 0
libavformat 53. 24. 0 / 53. 24. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 51. 0 / 2. 51. 0
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, flv, from 'video5.flv':
Metadata:
totalduration : 60
starttime : 0
lastkeyframetimestamp: 59
lasttimestamp : 60
canseekontime : true
canseektoend : true
hasvideo : true
hasaudio : true
datasize : 630
bytelength : 7077753
author :
copyright :
title :
rating :
metadatacreator : FLV Spider for Mac OS X - www.flvspider.com
Duration: 00:01:00.36, start: 0.019000, bitrate: 938 kb/s
Stream #0:0: Video: h264 (Baseline), yuv420p, 720x432 [SAR 1:1 DAR
5:3], 819 kb/s, 25 tbr, 1k tbn, 50 tbc
Stream #0:1: Audio: aac, 48000 Hz, stereo, s16, 131 kb/s
[buffer @ 0x6014e0] w:720 h:432 pixfmt:yuv420p tb:1/1000000 sar:1/1
sws_param:
[scale @ 0x60c7a0] w:720 h:432 fmt:yuv420p -> w:720 h:300 fmt:yuv420p
flags:0x4
[libx264 @ 0x81b620] using SAR=25/36
[libx264 @ 0x81b620] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
[libx264 @ 0x81b620] profile Constrained Baseline, level 3.0
[libx264 @ 0x81b620] 264 - core 119 - H.264/MPEG-4 AVC codec -
Copyleft 2003-2011 - http://www.videolan.org/x264.html - options:
cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1
psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1
8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2
threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0
bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250
keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf
mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4
vbv_maxrate=10000 vbv_bufsize=10000 crf_max=0.0 nal_hrd=none
ip_ratio=1.40 aq=1:1.00
Output #0, ipod, to 'video5.m4v':
Metadata:
totalduration : 60
starttime : 0
lastkeyframetimestamp: 59
lasttimestamp : 60
canseekontime : true
canseektoend : true
hasvideo : true
hasaudio : true
datasize : 630
bytelength : 7077753
author :
copyright :
title :
rating :
metadatacreator : FLV Spider for Mac OS X - www.flvspider.com
encoder : Lavf53.24.0
Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p, 720x300
[SAR 25:36 DAR 5:3], q=-1--1, 25 tbn, 25 tbc
Stream #0:1: Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, 131
kb/s
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 1509 fps= 48 q=-1.0 Lsize= 4766kB time=00:01:00.32 bitrate=
647.3kbits/s
video:3775kB audio:942kB global headers:0kB muxing overhead 1.042347%
[libx264 @ 0x81b620] frame I:8 Avg QP:18.41 size: 8940
[libx264 @ 0x81b620] frame P:1501 Avg QP:21.42 size: 2528
[libx264 @ 0x81b620] mb I I16..4: 56.0% 0.0% 44.0%
[libx264 @ 0x81b620] mb P I16..4: 10.8% 0.0% 0.8% P16..4: 46.5%
10.2% 2.9% 0.0% 0.0% skip:28.7%
[libx264 @ 0x81b620] coded y,uvDC,uvAC intra: 6.8% 52.7% 8.9% inter:
8.4% 31.8% 0.3%
[libx264 @ 0x81b620] i16 v,h,dc,p: 56% 24% 13% 7%
[libx264 @ 0x81b620] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 15% 27% 6%
4% 5% 4% 7% 3%
[libx264 @ 0x81b620] i8c dc,h,v,p: 59% 19% 20% 2%
[libx264 @ 0x81b620] ref P L0: 77.4% 13.9% 8.7%
[libx264 @ 0x81b620] kb/s:512.31
More information about the ffmpeg-devel
mailing list