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
Related
I'm running ffmpeg from a windows 10 machine.
My goal is to trim silence from the beginning to the end of a track (this works just fine) and compress using opus.
I am new in the "audio elaboration" world so maybe I'm not understanding this properly...but the main issue here is that ffmpeg doesn't recognize --enable-libopus although it's clearly in the options (see attachment).
Can anyone help please?
--enable-libopus in the build configuration indicates that libopus is available.
To use it as an encoder, you have to use the codec option.
ffmpeg -i input -af silenceremove... -c:a libopus -b:a 96k out.opus
I am ching.
I use the following command to transcode h264 to h265.
ffmpeg -i input.mp4 -c:v libx265 -crf 26 -preset fast -c:a aac -b:a 128k output.mp4
But the result is
Unknown encoder 'libx265'
But I have compiled h265 by the following command before using the above command.
sudo apt-get install cmake mercurial
cd ~/ffmpeg_sources
hg clone https://bitbucket.org/multicoreware/x265
cd ~/ffmpeg_sources/x265/build/linux
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source
make
make install
Then, I use ffmpeg -codecs to check if it supports to encode h265.
The result is
D.V.L. hevc H.265 / HEVC (High Efficiency Video Coding)
It seems that ffmpeg does not support h265.
How can I solve this problem?
To call the ffmpeg binary in the current folder do
./ffmpeg -i input.mp4 -c:v libx265 -crf 26 -preset fast -c:a aac -b:a 128k output.mp4
Without ./ it will call the binary in /usr/bin which is probably installed through apt without x265 in it.
Hint: The jump in efficiency between preset medium and fast is really high, medium is way better than fast. The same goes for slow and medium (all other presets make no big difference), so consider using slow if you have a little bit more time.
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 download cuda driver for my nvidia
but it still does not use my GPU, it still using cpu.
how can i make it use GPU.
i heard about hardware acceleration as well but thats not working.
It has to be h.264
Your question is not very clear.
From what I have read, it looks like you are trying to do h.264 encoding using your Nvidia GPU card.
Try this command and add your other codec or change the codec you use.
But usually, this will encode a file you have to mp4 using GPU.
ffmpeg -hwaccel cuvid -i input.mp4 -c:v h264_nvenc -pix_fmt yuv420p -preset slow output.mp4
I'm trying to decode an FLV's audio to a playable format. I attempted to use this SO post: FMS FLV to mp3.. as an example, but my FLV is encoded in Speex.
I have compiled ffmpeg with --enable-libspeex on a Fedora 15 machine.
I believe this can be done with ffmpeg but I'm having a hard time figuring out how to do it.
Any thoughts? Thanks
Your ffmpeg needs to be configured with --enable-libspeex to support Speex decoding. Since you did not provide your OS I can not give any more specific instructions. Once you have a build of ffmpeg that can decode speex the most simple command would be:
ffmpeg -i input.flv output.wav
while reencoding flv file (speex to mp3) if you get sample rate error try this:
ffmpeg -i c:\in.flv -acodec libmp3lame -ar 44100 -vcodec copy c:\out.flv
It does not matter what your input. As long as you have the decoder and encoder enabled in your ffmpeg it will do it.
ffmpeg -i inputfile.flv -acodec libmp3lame any_other_parameters_you_want -vcodec copy out.flv
will do the trick.
run ffmpeg -codecs to see the codecs supported and ffmpeg -formats to see the formats supported in your install.