environment:
- OS:Centos7
- FFMPEG version: 4.2
- GPU: NVIDIA Tesla T4
I have a requirement to work with multiple FFMPEG instance,command like this:
ffmpeg -y -loglevel info -hwaccel cuvid -hwaccel_output_format cuda -c:v h264_cuvid \
-i http://xx/xxxx.mp4 \
-c:v h264_nvenc -ss 0 -t 600 out.mp4
and the output like this:
ffmpeg version 4.2.git Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
configuration: --enable-cuda-nvcc --enable-cuda --enable-cuvid --enable-nvenc --enable-libnpp --prefix=/snbeauty//platform/centos --pkg-config-flags=--static --extra-cflags='-I/snbeauty//platform/centos/include -I/usr/local/cuda/include/ -Werror=implicit-function-declaration -std=gnu99' --extra-ldflags='-L/snbeauty//platform/centos/lib64 -L/snbeauty//platform/centos/lib -L/usr/local/lib64 -L/usr/lib64 -L/usr/local/cuda/lib64 -L/lib64' --extra-libs='-lpthread -lm -lEGL -lGL -lpng -lYNEffect -ltracker -lcuda -lcudart' --bindir=/snbeauty//platform/centos/bin --enable-static --enable-nonfree --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-filters --enable-version3 --enable-gpl --enable-libass --enable-libfdk_aac --enable-encoder=libfdk_aac --enable-opengl --enable-filter=xiu --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libtheora --enable-libwebp --enable-frei0r --enable-openssl --enable-gray --enable-libxml2 --enable-libxvid
libavutil 56. 42.100 / 56. 42.100
libavcodec 58. 73.102 / 58. 73.102
libavformat 58. 39.101 / 58. 39.101
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 77.100 / 7. 77.100
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'http://xxx/xxxx.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:38:52.05, start: 0.000000, bitrate: 5370 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080, 5245 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 119 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> h264 (h264_nvenc))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, mp4, to 'out.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.39.101
Stream #0:0(und): Video: h264 (h264_nvenc) (Main) (avc1 / 0x31637661), cuda, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 25 fps, 12800 tbn, 25 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.73.102 h264_nvenc
Side data:
cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: N/A
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc58.73.102 aac
frame=15000 fps=336 q=26.0 Lsize= 152462kB time=00:10:00.00 bitrate=2081.6kbits/s speed=13.4x
video:142668kB audio:9418kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.247139%
[aac @ 0x32437c0] Qavg: 168.657
real 0m45.568s
user 0m29.034s
sys 0m2.961s
is very fast
But when I try concurrent 10 processes to run this command with different input url,ffmpeg start is very slowly. Then I found FFmpeg is slowly in this step:
Stream mapping:
Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> h264 (h264_nvenc))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
When the video is very short(like 0.5s or 1s), FFmpeg takes a long time to start.The actual codec takes less time than the boot time.
I would like to ask what causes this problem? (Nvidia GPU limit or FFmpeg) .And any way to solve it.
Thanks!