[FFmpeg-trac] #404(undetermined:new): Rounding error in scaling expression

FFmpeg trac at avcodec.org
Thu Aug 18 18:58:34 CEST 2011


#404: Rounding error in scaling expression
-----------------------------------------+---------------------
 Reporter:  blaw                         |        Type:  defect
   Status:  new                          |    Priority:  normal
Component:  undetermined                 |     Version:  git
 Keywords:  rouding scalling expression  |  Blocked By:
 Blocking:                               |  Reproduced:  0
 Analyzed:  0                            |
-----------------------------------------+---------------------
 Looks like the calculation in the scaling filter is not rounding properly.

 This is the math I'm doing to convert all inputs to square pixels while
 maintaining aspect ratio.

 -vf scale='iw:ow/dar',setsar=1:1

 The input video is 352x480 with SAR of 20:11 and DAR of 4:3.

 The output file becomes 352x263. But when I do the math it should be
 352x264.  And since 263 isn't divisible by 2, the output video has color
 artifacts at the bottom.

 Here's my math (using windows calc):
 ow = 352
 dar = 4:3 = 1.3333333333333333333333333333333
 352/1.3333333333333333333333333333333 = 264.00000000000000000000000000007

 =================================================

 *******************
 *   Input Video   *
 *******************
 Input #0, mpeg, from '/data/transcode/input/Code Violation_
 Azarenka_Clijsters in Miami.mpg':
   Duration: 00:01:16.70, start: 0.213367, bitrate: 2661 kb/s
     Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 352x480 [SAR
 20:11 DAR 4:3], 2714 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
     Stream #0.1[0x80]: Audio: ac3, 48000 Hz, stereo, s16, 224 kb/s
 [STREAM]
 index=0
 codec_name=mpeg2video
 codec_long_name=MPEG-2 video
 codec_type=video
 codec_time_base=1001/60000
 codec_tag_string=[0][0][0][0]
 codec_tag=0x0000
 width=352
 height=480
 has_b_frames=1
 sample_aspect_ratio=20:11
 display_aspect_ratio=4:3
 pix_fmt=yuv420p
 level=8
 id=0x1e0
 r_frame_rate=30000/1001
 avg_frame_rate=30000/1001
 time_base=1/90000
 start_time=0.213367
 duration=76.576500
 [/STREAM]



 *******************
 *   Output Video  *
 *******************
 Input #0, matroska,webm, from '/data/transcode/input/Code Violation_
 Azarenka_Clijsters in Miami.mpg.webm':
   Duration: 00:00:07.57, start: 0.000000, bitrate: N/A
     Stream #0.0: Video: vp8, yuv420p, 352x263, SAR 1:1 DAR 352:263, 29.97
 fps, 29.97 tbr, 1k tbn, 29.97 tbc (default)
     Stream #0.1: Audio: vorbis, 44100 Hz, stereo, s16 (default)
 [STREAM]
 index=0
 codec_name=vp8
 codec_long_name=On2 VP8
 codec_type=video
 codec_time_base=1001/30000
 codec_tag_string=[0][0][0][0]
 codec_tag=0x0000
 width=352
 height=263
 has_b_frames=0
 pix_fmt=yuv420p
 level=-99
 r_frame_rate=30000/1001
 avg_frame_rate=1349849997/45039994
 time_base=1/1000
 start_time=0.000000
 duration=N/A
 [/STREAM]




 *******************
 *   ffmpeg cmd    *
 *******************
 WEBM_PROFILE="-vf
 yadif=0:-1:1,unsharp=3:3:1.0,scale='iw:ow/dar',setsar=1:1 -f webm -threads
 0 -vcodec libvpx -g 360 -keyint_min 0 -vb 800k -qmin 1 -qmax 63 -quality
 good -slices 1 -vp8flags altref -acodec libvorbis -ac 2 -ab 128k -ar
 44100"

 ffmpeg -i <filename> $WEBM_PROFILE -y <filename>.webm


 ffmpeg version 0.8.2.git, Copyright (c) 2000-2011 the FFmpeg developers
   built on Aug 17 2011 15:52:09 with gcc 4.4.3
   configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-
 postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-
 amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-
 libxvid --enable-x11grab --enable-libmp3lame --enable-libvpx --enable-
 static
   libavutil    51. 12. 0 / 51. 12. 0
   libavcodec   53. 11. 0 / 53. 11. 0
   libavformat  53.  7. 0 / 53.  7. 0
   libavdevice  53.  3. 0 / 53.  3. 0
   libavfilter   2. 32. 0 /  2. 32. 0
   libswscale    2.  0. 0 /  2.  0. 0
   libpostproc  51.  2. 0 / 51.  2. 0

-- 
Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/404>
FFmpeg <http://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list