[FFmpeg-trac] #6358(ffmpeg:new): Video to images functionality does not take SAR into account

FFmpeg trac at avcodec.org
Fri Apr 28 14:48:52 EEST 2017


#6358: Video to images functionality does not take SAR into account
--------------------------------+----------------------------------
             Reporter:  01sas   |                     Type:  defect
               Status:  new     |                 Priority:  normal
            Component:  ffmpeg  |                  Version:  3.2.4
             Keywords:          |               Blocked By:
             Blocking:          |  Reproduced by developer:  0
Analyzed by developer:  0       |
--------------------------------+----------------------------------
 Summary of the bug:
 I have a video recorded from TV (DVB) and this video has a different SAR
 other the time. Like when advertisement or some modern TV show is shown
 then SAR is 64:45 which gives image with 16:9 aspect ratio but when some
 old TV show is shown then SAR is 16:15 which gives image with 4:3 aspect
 ratio. I want to convert this video to a sequence of images one per second
 and I want image to have a valid resolution according to SAR with correct
 aspect ratio.

 The first problem which I face is that ffmpeg does not take SAR into
 account when generate images. I solve this problem using video filter,
 like this: -vf "scale=iw:ih/sar:eval=frame".

 But after that I face a problem which I don't know how to solve: ffmpeg
 generate images with always the same resolution and does not change it in
 respect to changed scale. In my case it simply crop image when aspect
 ratio is 4:3. In logs it is visible that scaler calculate resolution
 correctly but output images always has the same resolution as for first
 image which is a problem.

 How to reproduce:
 {{{
 % ffmpeg -i test.ts -vf "scale=iw:ih/sar:eval=frame,fps=1" -qscale:v 6
 "frames/out%03d.jpg"
 ffmpeg version 3.2.4-1~16.04.york1 Copyright (c) 2000-2017 the FFmpeg
 developers
   built with gcc 5.4.1 (Ubuntu 5.4.1-5ubuntu2~16.04.york1) 20170210
   configuration: --prefix=/usr --extra-version='1~16.04.york1'
 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu
 --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping
 --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa
 --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
 --enable-libcdio --enable-libebur128 --enable-libflite --enable-
 libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme
 --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-
 libopenmpt --enable-libopus --enable-libpulse --enable-librubberband
 --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex
 --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis
 --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265
 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-
 openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-
 libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv
 --enable-libx264 --enable-shared
   libavutil      55. 34.101 / 55. 34.101
   libavcodec     57. 64.101 / 57. 64.101
   libavformat    57. 56.101 / 57. 56.101
   libavdevice    57.  1.100 / 57.  1.100
   libavfilter     6. 65.100 /  6. 65.100
   libavresample   3.  1.  0 /  3.  1.  0
   libswscale      4.  2.100 /  4.  2.100
   libswresample   2.  3.100 /  2.  3.100
   libpostproc    54.  1.100 / 54.  1.100
 Input #0, mpegts, from 'test.ts':
   Duration: 00:01:00.14, start: 1.400000, bitrate: 8223 kb/s
   Program 1
     Metadata:
       service_name    : Service01
       service_provider: FFmpeg
     Stream #0:0[0x100]: Video: mpeg2video (Main), 1 reference frame
 ([2][0][0][0] / 0x0002), yuv420p(tv, top first, left), 720x576 [SAR 64:45
 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
     Stream #0:1[0x101](deu): Audio: ac3 ([129][0][0][0] / 0x0081), 48000
 Hz, 5.1(side), fltp, 448 kb/s
 [Parsed_scale_0 @ 0x55a718d39480] w:iw h:ih/sar flags:'bicubic' interl:0
 [Parsed_fps_1 @ 0x55a718d39f20] fps=1/1
 [graph 0 input from stream 0:0 @ 0x55a718d39da0] w:720 h:576
 pixfmt:yuv420p tb:1/90000 fr:25/1 sar:64/45 sws_param:flags=2
 [swscaler @ 0x55a718d3af40] deprecated pixel format used, make sure you
 did set range correctly
 [Parsed_scale_0 @ 0x55a718d39480] w:720 h:576 fmt:yuv420p sar:64/45 ->
 w:720 h:405 fmt:yuvj420p sar:1/1 flags:0x4
 Output #0, image2, to 'out%03d.jpg':
   Metadata:
     encoder         : Lavf57.56.101
     Stream #0:0: Video: mjpeg, 1 reference frame, yuvj420p(pc, left),
 720x405 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc
     Metadata:
       encoder         : Lavc57.64.101 mjpeg
     Side data:
       cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
 Stream mapping:
   Stream #0:0 -> #0:0 (mpeg2video (native) -> mjpeg (native))
 Press [q] to stop, [?] for help
 [mpegts @ 0x55a718cf04a0] Correcting start time by 178733
 [swscaler @ 0x55a718ee4560] deprecated pixel format used, make sure you
 did set range correctly
 [Parsed_scale_0 @ 0x55a718d39480] w:720 h:576 fmt:yuv420p sar:16/15 ->
 w:720 h:540 fmt:yuvj420p sar:1/1 flags:0x4
 No more output streams to write to, finishing.56.00 bitrate=N/A speed=
 9.3x
 frame=   61 fps=9.7 q=6.0 Lsize=N/A time=00:01:01.00 bitrate=N/A speed=
 9.7x
 video:1537kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: unknown
 Input file #0 (test.ts):
   Input stream #0:0 (video): 1497 packets read (53746648 bytes); 1494
 frames decoded;
   Input stream #0:1 (audio): 0 packets read (0 bytes);
   Total: 1497 packets (53746648 bytes) demuxed
 Output file #0 (out%03d.jpg):
   Output stream #0:0 (video): 61 frames encoded; 61 packets muxed (1573461
 bytes);
   Total: 61 packets (1573461 bytes) muxed
 [Parsed_fps_1 @ 0x55a718d39f20] 1494 frames in, 61 frames out; 1433 frames
 dropped, 0 frames duplicated.
 }}}

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


More information about the FFmpeg-trac mailing list