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
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
So far I use NVENC with ffmpeg for all my encoding successfully. Today I got a new Zotac nVidia GEForce GTX 1660 6GB card.
I get "No NVENC capable devices found" error from ffmpeg. Only if I use -flags:v +ildct flag. Without ildct flag no issues except the output is progressive.
I 100% need Interlaced output and I tried most of the Interlaced flags like, -vf tinterlace=interleave_top,fieldorder=tff -x264opts tff=1 Nothing is giving me Interlaced output except -flags +ildct But with "Zotac nVidia GEForce GTX 1660" ffmpeg shows:
No NVENC capable devices found
I even tried all latest nVidia drivers. Nothing helped me.
My pseudo ffmpeg command line is as below:
ffmpeg -i SourceFile.mkv -codec:v h264_nvenc -preset:v slow -flags:v +ildct+cgop -s:v 1920x1080 -ac 2 -ar 48000 -codec:a mp2 -b:a 384k -r 25 -f mp4 -y NewFile.mp4
Is it a bug with nVidia driver or ffmpeg ? Is latest nVidia Turing technology doesn't support Interlaced (very Bad) ?
Could some one help me ?
nVidia inexplicably disabled interlaced encoding on Turing GPU's. See here and here.
I'm waiting for fix, too.
I am encoding videos from h264 to h265 using ffmpeg. First I used the x265 software version for a 30 sec movie clip reducing the file size from 18Mb to 2Mb and got the following still-frame result in 45 sec
Next I used the hevc_videotoolbox hardware accelerated version, first going from 18 to 1.6 Mb and the results were so poor I decided to up the bitrate to 1.5Mbit/s, thus getting a 5.7Mb file in 12 sec. However, the result is clearly inferior to the x265 version despite the almost 3x increase in filesize.
Any ideas if it is possible to improve the hevc_toolbox quality and still retain the speed advantage?
ffmpeg -i test.mp4 -an -c:v libx265 -vtag hvc1 -y test_x265.mp4
ffmpeg -i test.mp4 -an -c:v hevc_videotoolbox -vtag hvc1 -y -b:v 1.5M test_vt.mp4
I am on a MB pro late 2017 version with kaby lake
hevc_videotoolbox is hardware accelerated and because of that it will never be as efficient as x265. If you have the time I would recommend you using x265.
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