FFMPEG when compiled with following options give abysmal performance on Amazon G2 instance( g2.2xlarge, GRID K520) when compared with standalone Dell-Precision-T1700 (Quadro-k620)
"--enable-nonfree --enable-gpl --enable-version3 --enable-shared --enable pthreads [b]--enable-nvenc[/b] --enable-runtime-cpudetect --disable-doc --enable-libmp3lame"
Above ffmpeg binary took 66 seconds to transcode 5.22 mins BVE_Localize.mp4 file with following command.
time ffmpeg -y -i BVE_Localize.mp4 -strict -2 -vcodec nvenc_h264 -b 5000k -acodec aac -ab 256k -f mpegts BVELocalize.ts ( took 1m6.990s on G2)
When same ffmpeg command is executed on Dell-Precision-T1700 (Xeon Dual core, Quadro K620) based workstation takes 0m41.572s.
I would like ffmpeg to perform better on Amazon G2 instance. What do you think I might be missing? My Amazon G2 instance configuration is Ubuntu 14.04 64 bit, Cuda 7.0 , 352.55 drivers, MSI disabled,NVIDIA SDK 5.0.1
Related
im playing with my video files, I want to convert them from mp4, mkv, wmv, avi, flv, mov... to webm.
So I have written this:
for file in *
do
if [ -f "$file" ]
then filename="${file%.*}"
../ffmpeg -hwaccel nvdec -hwaccel_device 0 -hwaccel_output_format cuda -i "$file" -c:v vp9 -b:v 0 -crf 31 -c:a libvorbis "$filename".webm
fi
done
As shown, I have compiler my own ffmpeg binary, with those options:
./configure --enable-gpl --enable-libx264 --enable-nonfree --enable-cuda-nvcc --enable-libvpx --enable-vaapi --enable-libvorbis --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64
It works, but, with CPU I got speed 0,1x and with cuda... almost the same.
My CPU? 11th Gen Intel(R) Core(TM) i7-11800H
My GPU? GeForce RTX™ 3060 mobile
Filesize? 300-3000mb (same speed with any)
Is there anything I could do? (I also tried vp9_vaapi, getting
Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scale_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Any clue? Or do I have to give up?
Thanks
Well, after some tests, the bests results were obtained using
-c:v libvpx-vp9 -cpu-used 8 -deadline realtime
speed increased from 0,05x to 1,12x slow, but, good enough.
Quality is good for me.
Since there aren't m1 builds available from ffmpeg.org, I had to compile my own. Obviously, I'd like to get the best possible performance.
Does ffmpeg use the "Hardware-accelerated H.264" on the m1 max?
Is there anything I need to do, like compiler flags, to get it?
Any switch at run time?
How can I verify that it's being used?
To compile ffmpeg, I just did the basics:
./configure --prefix=/tmp/ff --enable-gpl --enable-nonfree --enable-libx264
make
make install
For x264, I just did
./configure --prefix=/tmp/ff
make
make install
to run:
ffmpeg -i random.wmv -c:v libx264 -preset ultrafast -c:a aac output-ultra.mp4
Anything else I should be doing?
It looks like what I wanted was videotoolbox
Usage is documented here, basically
To use H.264/HEVC hardware encoding in macOS, just use the encoder -c:v h264_videotoolbox
Example:
ffmpeg -i random.wmv -c:v h264_videotoolbox -c:a aac junk-vt.mp4
Seems to be slightly faster than "ultrafast" with software, and much smaller files.
H264_videotoolbox is useless on M1 Pro. I don't see that the GPU is working. I use the same file to transcode h264_videotoolbox can only play to a 6.x magnification and -vcodec h264 Use CPU magnification to reach 12.x
Ffmpeg 5.1.2 macos 13.1
Recently I compiled natively the latest version of ffmpeg 4.3 on Windows 10 amd64.
Evironment:CUDA11.0, NASM, VS2019, MYSY2 with mingw64.
I also used the patch https://trac.ffmpeg.org/attachment/ticket/9019/0001-Patch-for-ticket-9019-CUDA-Compile-Broken-Using-MSVC.patch
Compile featrues were:
--enable-nonfree --enable-cuda-nvcc --enable-libnpp --enable-gpl --enable-libx264 --enable-cuda-llvm --enable-nvenc
--toolchain=msvc --extra-cflags=-I../nv_sdk --extra-ldflags=-libpath:../nv_sdk
I tested ffmpeg for cuda acceleration. the CPU is an AMD 3500x. the GPU is an RTX 2060Ultra.
Issuing this command:
.\ffmpeg -hwaccel cuvid -i .\a.wmv -c:v hevc_nvenc -bf 4 -preset slow -c:a aac -b:a 256k myvideo.mp4
But recieved this error:
[wmv3 # 000002632DFC5180] No decoder surfaces left
Error while decoding stream #0:0: Cannot allocate memory
[hevc_nvenc # 00000263300B1740] Failed locking bitstream buffer: out of memory (10):
video encoding failed: Cannot allocate memory
I'm not sure where I've gone wrong here.
Try adding -extra_hw_frames N to your input and increase N until the error ceases. I just needed 8 myself.
I encountered this same problem on version 4.4 as well. This was reported against 4.1 but only on some cases. Someone suggested the -extra_hw_frames N workaround on https://trac.ffmpeg.org/ticket/7562 and it worked for me.
I also had the same problem as OP and followed the user's "Moby Disk" advice to use "-extra_hw_frames N"
Here is what I used which worked for me:
ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -extra_hw_frames 8 -i video_sample.mp4 -c:a copy -c:v h264_nvenc -b:v 5M output.mp4
The GPU I have is:
MSI Nvidia GeForce GT 710 2GB 2GD3
setting the output format to auto working for me. the -extra_hw_frames cause a initialisation error (but do convert the video)
ffmpeg -hwaccel cuda -hwaccel_output_format auto
I tried brew installed ffmpeg, i am also tried to compile ffmpeg but in all cases i have the error
Illegal instruction: 4
I run something like this:
./ffmpeg -i /Users/ruslan/Torrents/Weird\ smiling\ dog.3gp -codec:v libx264 -b:v 360k -maxrate 360k -bufsize 720k -movflags +faststart -vprofile high -preset slow -vf 'scale=trunc(iw/2)*2:360' -threads 0 -codec:a libfdk_aac -b:a 96k -ac 2 -f mp4 -threads 0 -y /dev/null >> /Users/ruslan/erosite/log/ffmpeg_convertation.log 2>&1
Illegal instruction: 4
Or only ffmpeg with options when used homebrews installed version
Additional info:
OS X Yosemite 10.10.2
MacBook Pro (15-inch, Mid 2009)
This may happen when you restore OS X from Time Machine backup to another computer with different architecture (eg. Haswell to Ivy Bridge). ffmpeg might have been compiled with optimization for a particular architecture. Reinstalling ffmpeg worked for me.
$ brew uninstall ffmpeg && brew install ffmpeg
If you have multiple version of ffmpeg present, run the uninstall command multiple times.
On reinstalling ffmpeg was not compiled on my machine but poured from a precompiled bottle.
A problem was resolved when I fully reinstall brew.
It appears that ffmpeg now has a segmenter in it, or at least there is a command line option
-f segment
in the documentation.
Does this mean I can use ffmpeg to realtime-transcode a video into h.264 and deliver segmented IOS compatible .m3u8 streams using ffmpeg alone? if so, what would a command to transcode an arbitrary video file to a segmented h.264 aac 640 x 480 stream ios compatible stream?
Absolutely - you can use -f segment to chop video into pieces and serve it to iOS devices. ffmpeg will create segment files .ts and you can serve those with any web server.
Working example (with disabled sound) - ffmpeg version N-39494-g41a097a:
./ffmpeg -v 9 -loglevel 99 -re -i sourcefile.avi -an \
-c:v libx264 -b:v 128k -vpre ipod320 \
-flags -global_header -map 0 -f segment -segment_time 4 \
-segment_list test.m3u8 -segment_format mpegts stream%05d.ts
Tips:
make sure you compile ffmpeg from most recent git repository
compile with libx264 codec
-map 0 is needed
How I compiled FFMPEG - with extra rtmp support to get feeds from flash-media-server
export PKG_CONFIG_PATH="/usr/lib/pkgconfig/:../rtmpdump-2.3/librtmp"
./configure --enable-librtmp --enable-libx264 \
--libdir='../x264/:/usr/local/lib:../rtmpdump-2.3' \
--enable-gpl --enable-pthreads --enable-libvpx \
--disable-ffplay --disable-ffserver --disable-shared --enable-debug
This is found in the ffmpeg documentation: https://ffmpeg.org/ffmpeg-formats.html#segment_002c-stream_005fsegment_002c-ssegment