[FFmpeg-user] filter thumbnail does not respect aspect ratio
Thomas Seilund
tps at netmaster.dk
Tue Apr 9 12:26:36 CEST 2013
Hi All
I have problems creating thumbnails that respect the aspect ratio of the
video.
I have two videos. One is 16:9 and another one is 4:3.
I would expect the thumbnail filter to create an image that has the same
aspect ratio as the input video!
Below I run two commands for each video.
1. ffmpeg -i video -ss 0 -vf thumbnail -frames:v 1 thumbnail.jpg
2. identify thumbnail.jpg
Command `identify` is from ImageMagick and describes the format and
characteristics of an image file. In this case the thumbnail created by
ffmpeg.
Note that the output from `identify` is the same (thumbnail.jpg JPEG
720x576) for both videos. I would have expected pixel width and height
to give 16:9 and 4:3 ratio.
16:9 video:
ffmpeg -i p20120122142736.mpg -ss 0 -vf thumbnail -frames:v 1 thumbnail.jpg
ffmpeg version 0.10.3 Copyright (c) 2000-2012 the FFmpeg developers
built on Mar 13 2013 20:25:12 with gcc 4.6.3
configuration: --prefix=/usr --libdir=/usr/lib64
--shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_6
4-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++
--ar=x86_64-pc-linux-gnu-ar --optflags='-march=native -O2 -pipe' --extra-c
flags='-march=native -O2 -pipe' --extra-cxxflags='-O2 -pipe'
--disable-static --enable-gpl --enable-version3 --enable-postp
roc --enable-avfilter --disable-stripping --disable-debug --disable-doc
--disable-network --disable-vaapi --disable-vdpau -
-disable-ffplay --enable-libmp3lame --enable-libvo-aacenc
--enable-libtheora --enable-libvorbis --enable-libx264 --enable-l
ibfaac --enable-nonfree --disable-indev=v4l --disable-indev=alsa
--disable-indev=oss --disable-indev=jack --enable-libv4l2
--disable-outdev=alsa --disable-outdev=oss --disable-outdev=sdl
--enable-libfreetype --enable-libvpx --disable-amd3dnow --d
isable-amd3dnowext --disable-altivec --disable-avx --disable-mmx2
--disable-ssse3 --disable-vis --disable-neon --cpu=host -
-enable-hardcoded-tables
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
[mpeg @ 0x7fb0d9a0f620] max_analyze_duration 5000000 reached at 5000000
Input #0, mpeg, from 'p20120122142736.mpg':
Duration: 00:01:24.80, start: 1.000000, bitrate: 6577 kb/s
Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x576 [SAR
64:45 DAR 16:9], 9000 kb/s, 25 fps, 25 tbr, 90k tbn
, 50 tbc
Stream #0:1[0x80]: Audio: ac3, 48000 Hz, stereo, s16, 448 kb/s
Incompatible pixel format 'yuv420p' for codec 'mjpeg', auto-selecting
format 'yuvj420p'
[buffer @ 0x7fb0d9a17a80] w:720 h:576 pixfmt:yuv420p tb:1/1000000
sar:64/45 sws_param:
[thumbnail @ 0x7fb0d9a23b90] batch size: 100 frames
[buffersink @ 0x7fb0d9a17b00] auto-inserting filter 'auto-inserted scale
0' between the filter 'Parsed_thumbnail_0' and the
filter 'out'
[thumbnail @ 0x7fb0d9a23b90] auto-inserting filter 'auto-inserted scale
1' between the filter 'src' and the filter 'Parsed_
thumbnail_0'
[scale @ 0x7fb0d9a243e0] w:720 h:576 fmt:yuv420p -> w:720 h:576
fmt:rgb24 flags:0x4
[scale @ 0x7fb0d9a23f70] w:720 h:576 fmt:rgb24 -> w:720 h:576
fmt:yuvj420p flags:0x4
Output #0, image2, to 'thumbnail.jpg':
Metadata:
encoder : Lavf53.32.100
Stream #0:0: Video: mjpeg, yuvj420p, 720x576 [SAR 64:45 DAR 16:9],
q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video -> mjpeg)
Press [q] to stop, [?] for help
frame id #34 (pts_time=1.360000) selected time=00:00:00.00 bitrate=
0.0kbits/s
frame= 1 fps= 1 q=5.9 Lsize= 0kB time=00:00:00.04 bitrate=
0.0kbits/s dup=34 drop=0
video:40kB audio:0kB global headers:0kB muxing overhead -100.000000%
identify thumbnail.jpg
thumbnail.jpg JPEG 720x576 720x576+0+0 8-bit DirectClass 41.4KB 0.000u
0:00.000
4:3 video:
ffmpeg -i p20130120155621.ts -ss 0 -vf thumbnail -frames:v 1 thumbnail.jpg
ffmpeg version 0.10.3 Copyright (c) 2000-2012 the FFmpeg developers
built on Mar 13 2013 20:25:12 with gcc 4.6.3
configuration: --prefix=/usr --libdir=/usr/lib64
--shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared
--cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++
--ar=x86_64-pc-linux-gnu-ar --optflags='-march=native -O2 -pipe'
--extra-cflags='-march=native -O2 -pipe' --extra-cxxflags='-O2 -pipe'
--disable-static --enable-gpl --enable-version3 --enable-postproc
--enable-avfilter --disable-stripping --disable-debug --disable-doc
--disable-network --disable-vaapi --disable-vdpau --disable-ffplay
--enable-libmp3lame --enable-libvo-aacenc --enable-libtheora
--enable-libvorbis --enable-libx264 --enable-libfaac --enable-nonfree
--disable-indev=v4l --disable-indev=alsa --disable-indev=oss
--disable-indev=jack --enable-libv4l2 --disable-outdev=alsa
--disable-outdev=oss --disable-outdev=sdl --enable-libfreetype
--enable-libvpx --disable-amd3dnow --disable-amd3dnowext
--disable-altivec --disable-avx --disable-mmx2 --disable-ssse3
--disable-vis --disable-neon --cpu=host --enable-hardcoded-tables
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
[mpegts @ 0x7fc790518620] max_analyze_duration 5000000 reached at 5000000
Input #0, mpegts, from 'p20130120155621.ts':
Duration: 00:02:19.44, start: 1.376978, bitrate: 2479 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (Constrained Baseline)
([27][0][0][0] / 0x001B), yuv420p, 720x576 [SAR 16:15 DAR 4:3], 25 fps,
25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x101]: Audio: mp3 ([3][0][0][0] / 0x0003), 48000 Hz,
stereo, s16, 128 kb/s
Incompatible pixel format 'yuv420p' for codec 'mjpeg', auto-selecting
format 'yuvj420p'
[buffer @ 0x7fc79051e6f0] w:720 h:576 pixfmt:yuv420p tb:1/1000000
sar:16/15 sws_param:
[thumbnail @ 0x7fc79051ebf0] batch size: 100 frames
[buffersink @ 0x7fc79051e950] auto-inserting filter 'auto-inserted scale
0' between the filter 'Parsed_thumbnail_0' and the filter 'out'
[thumbnail @ 0x7fc79051ebf0] auto-inserting filter 'auto-inserted scale
1' between the filter 'src' and the filter 'Parsed_thumbnail_0'
[scale @ 0x7fc79051f470] w:720 h:576 fmt:yuv420p -> w:720 h:576
fmt:rgb24 flags:0x4
[scale @ 0x7fc79051efd0] w:720 h:576 fmt:rgb24 -> w:720 h:576
fmt:yuvj420p flags:0x4
Output #0, image2, to 'thumbnail.jpg':
Metadata:
encoder : Lavf53.32.100
Stream #0:0: Video: mjpeg, yuvj420p, 720x576 [SAR 16:15 DAR 4:3],
q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> mjpeg)
Press [q] to stop, [?] for help
[thumbnail @ 0x7fc79051ebf0] frame id #64 (pts_time=2.583022) selected
frame= 1 fps= 0 q=6.1 Lsize= 0kB time=00:00:00.04 bitrate=
0.0kbits/s dup=65 drop=0
video:47kB audio:0kB global headers:0kB muxing overhead -100.000000%
identify thumbnail.jpg
thumbnail.jpg JPEG 720x576 720x576+0+0 8-bit DirectClass 48.1KB 0.000u
0:00.000
Thanks in advance
Thomas S
More information about the ffmpeg-user
mailing list