[FFmpeg-user] To Speed Up thumbnail creation - picture & video
Arunava Banerjee
arunava.banerjee at capitalnumbers.com
Mon Jun 22 08:23:52 EEST 2020
Hello,
We have been using FFMPEG library to create the following thumbnails from
videos:
a. picture
b. video - for example a 60secs video thumbnail.
Our video sizes are about 200 - 300 MB. We are using a PHP program to
transfer command to the shell for FFMPEG executable to generate the
thumbnails.
The videos exists on AWS S3, and we are fetching them using S3 signature
url, generating the thumbs and uploading back.
We have noticed that FFMPEG takes quite sometime to create the thumbnails,
which is creating a wait time on the part of the interface.
Please let us know if there could be a way, we can fasten this process.
Do such params exist in FFMPEG ?
The time for creation on a local system using S3 is given hereunder:
To create a picture:
real 0m37.618s
user 0m17.791s
sys 0m0.783s
To create a video thumb:
real 3m6.979s
user 2m29.448s
sys 0m4.621s
The commands used for the purpose are as hereunder:
To create a picture:
"ffmpeg -i '".$s3_key_url."' -r 1 -vframes 1 -an -s $thumbnail_size -ss 05
$extracted_thumbnail_location 2>&1"
To create a videothumb of 60 secs:
"ffmpeg -ss 00 -t 60 -i '".$s3_key_url."' -vf scale=$video_scale -strict -2
$extracted_video_location 2>&1"
The logs of the respective commands are as follows:
For picture:
---------------
ffmpeg -i '
https://cnp892.s3.amazonaws.com/main/010420_Downtown_SD_Waterfront_2.mov?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAZD5VS7Z66QJB56WV%2F20200505%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200505T065154Z&X-Amz-SignedHeaders=host&X-Amz-Expires=1200&X-Amz-Signature=14930fed30d72ef3afbb06ec0ac70cae5e741e067b4c0da5108b1b49e17ce665'
-r 1 -vframes 1 -an -s 640X360 -ss 05
/data/html/wpsite/wp_5_2_5/wp-content/uploads/VaspmTempsu/010420_Downtown_SD_Waterfront_2_preview.jpg
ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg
developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1
--build-suffix=-ffmpeg --toolchain=hardened
--libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu
--cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping
--disable-decoder=libopenjpeg --disable-decoder=libschroedinger
--enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa
--enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
--enable-libcdio --enable-libflite --enable-libfontconfig
--enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm
--enable-libmodplug --enable-libmp3lame --enable-libopenjpeg
--enable-libopus --enable-libpulse --enable-librtmp
--enable-libschroedinger --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-libzvbi
--enable-openal --enable-opengl --enable-x11grab --enable-libdc1394
--enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264
--enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[https @ 0xd03fe0] HTTP error 416 Requested Range Not Satisfiable
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '
https://cnp892.s3.amazonaws.com/main/010420_Downtown_SD_Waterfront_2.mov?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAZD5VS7Z66QJB56WV%2F20200505%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200505T065154Z&X-Amz-SignedHeaders=host&X-Amz-Expires=1200&X-Amz-Signature=14930fed30d72ef3afbb06ec0ac70cae5e741e067b4c0da5108b1b49e17ce665
':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2020-01-13 23:36:24
Duration: 00:00:33.99, start: 0.000000, bitrate: 49379 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv,
bt709), 3840x2160 [SAR 1:1 DAR 16:9], 49376 kb/s, 23.98 fps, 23.98 tbr, 24k
tbn, 48k tbc (default)
Metadata:
creation_time : 2020-01-13 23:36:24
handler_name : Core Media Data Handler
encoder : H.264
timecode : 00:00:00:00
Stream #0:1(und): Data: none (tmcd / 0x64636D74) (default)
Metadata:
creation_time : 2020-01-13 23:36:24
handler_name : Core Media Data Handler
timecode : 00:00:00:00
[swscaler @ 0x1103300] deprecated pixel format used, make sure you did set
range correctly
Output #0, image2, to
'/data/html/wpsite/wp_5_2_5/wp-content/uploads/VaspmTempsu/010420_Downtown_SD_Waterfront_2_preview.jpg':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
encoder : Lavf56.40.101
Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 640x360 [SAR 1:1 DAR
16:9], q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc (default)
Metadata:
creation_time : 2020-01-13 23:36:24
handler_name : Core Media Data Handler
timecode : 00:00:00:00
encoder : Lavc56.60.100 mjpeg
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
frame= 1 fps=0.1 q=6.4 Lsize=N/A time=00:00:01.00 bitrate=N/A
video:47kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: unknown
real 0m37.618s
user 0m17.791s
sys 0m0.783s
For video:
--------------
ffmpeg -ss 00 -t 60 -i '
https://cnp892.s3.amazonaws.com/main/010420_Downtown_SD_Waterfront_2.mov?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAZD5VS7Z66QJB56WV%2F20200506%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200506T063632Z&X-Amz-SignedHeaders=host&X-Amz-Expires=1200&X-Amz-Signature=b22ed0c2db7154c0e533a875b32cd1b4b96878361a3e6ab8f0c341bdc8ecd120'
-vf scale=640:360 -strict -2
/data/html/wpsite/wp_5_2_5/wp-content/uploads/VaspmTempsu/010420_Downtown_SD_Waterfront_2_preview_tmp.mp4
ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg
developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1
--build-suffix=-ffmpeg --toolchain=hardened
--libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu
--cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping
--disable-decoder=libopenjpeg --disable-decoder=libschroedinger
--enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa
--enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
--enable-libcdio --enable-libflite --enable-libfontconfig
--enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm
--enable-libmodplug --enable-libmp3lame --enable-libopenjpeg
--enable-libopus --enable-libpulse --enable-librtmp
--enable-libschroedinger --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-libzvbi
--enable-openal --enable-opengl --enable-x11grab --enable-libdc1394
--enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264
--enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[https @ 0x126afa0] HTTP error 416 Requested Range Not Satisfiable
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '
https://cnp892.s3.amazonaws.com/main/010420_Downtown_SD_Waterfront_2.mov?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAZD5VS7Z66QJB56WV%2F20200506%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200506T063632Z&X-Amz-SignedHeaders=host&X-Amz-Expires=1200&X-Amz-Signature=b22ed0c2db7154c0e533a875b32cd1b4b96878361a3e6ab8f0c341bdc8ecd120
':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2020-01-13 23:36:24
Duration: 00:00:33.99, start: 0.000000, bitrate: 49379 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv,
bt709), 3840x2160 [SAR 1:1 DAR 16:9], 49376 kb/s, 23.98 fps, 23.98 tbr, 24k
tbn, 48k tbc (default)
Metadata:
creation_time : 2020-01-13 23:36:24
handler_name : Core Media Data Handler
encoder : H.264
timecode : 00:00:00:00
Stream #0:1(und): Data: none (tmcd / 0x64636D74) (default)
Metadata:
creation_time : 2020-01-13 23:36:24
handler_name : Core Media Data Handler
timecode : 00:00:00:00
[libx264 @ 0x12b2960] using SAR=1/1
[libx264 @ 0x12b2960] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x12b2960] profile High, level 3.0
[libx264 @ 0x12b2960] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec
- Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1
ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00
mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11
fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1
sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0
constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1
weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=23 scenecut=40
intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0
qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to
'/data/html/wpsite/wp_5_2_5/wp-content/uploads/VaspmTempsu/010420_Downtown_SD_Waterfront_2_preview_tmp.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
encoder : Lavf56.40.101
Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021),
yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 23.98 fps, 24k tbn, 23.98 tbc
(default)
Metadata:
creation_time : 2020-01-13 23:36:24
handler_name : Core Media Data Handler
timecode : 00:00:00:00
encoder : Lavc56.60.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame= 815 fps=4.9 q=-1.0 Lsize= 5573kB time=00:00:33.90
bitrate=1346.3kbits/s
video:5562kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.187583%
[libx264 @ 0x12b2960] frame I:4 Avg QP:21.82 size: 63742
[libx264 @ 0x12b2960] frame P:407 Avg QP:24.15 size: 12739
[libx264 @ 0x12b2960] frame B:404 Avg QP:29.67 size: 631
[libx264 @ 0x12b2960] consecutive B-frames: 0.9% 99.1% 0.0% 0.0%
[libx264 @ 0x12b2960] mb I I16..4: 7.9% 19.5% 72.6%
[libx264 @ 0x12b2960] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 38.0% 25.6%
21.7% 0.0% 0.0% skip:14.6%
[libx264 @ 0x12b2960] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 30.1% 2.3%
0.7% direct: 1.3% skip:65.5% L0:30.1% L1:51.7% BI:18.2%
[libx264 @ 0x12b2960] 8x8 transform intra:19.2% inter:45.7%
[libx264 @ 0x12b2960] coded y,uvDC,uvAC intra: 87.1% 96.4% 86.6% inter:
26.4% 17.5% 4.9%
[libx264 @ 0x12b2960] i16 v,h,dc,p: 7% 55% 3% 35%
[libx264 @ 0x12b2960] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 41% 14% 4% 4%
3% 8% 4% 8%
[libx264 @ 0x12b2960] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 26% 9% 5% 6%
5% 10% 5% 9%
[libx264 @ 0x12b2960] i8c dc,h,v,p: 39% 40% 12% 9%
[libx264 @ 0x12b2960] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x12b2960] ref P L0: 60.4% 14.1% 17.6% 7.9%
[libx264 @ 0x12b2960] ref B L0: 70.9% 29.1%
[libx264 @ 0x12b2960] kb/s:1340.28
real 3m6.979s
user 2m29.448s
sys 0m4.621s
--
======================================================
Best Regards,
Arunava Banerjee
Sr. Web Developer,
Capital Numbers Infotech Pvt.Ltd.
Gmail: arunava.banerjee at capitalnumbers.com
======================================================
More information about the ffmpeg-user
mailing list