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.
Related
I am trying to use libvpx encoder for incoming h264 stream. It works good however it consumes too much cpu (around %50-60). Even when I start second ffmpeg encoder, the frames decreases to 4-5fps. How can I solve cpu consumption problem for libvpx codec on Mac Pro - M1 Pro chip ?
xxx | ffmpeg -f h264 -i pipe:0 -f rtp -codec:v libvpx -filter:v scale=310:420 -preset ultrafast -minrate 500k -maxrate 500k -b:v 500k -crf 40 "rtp://localhost:12333?pkt_size=1200"
CPU Usage around %50-60 for one ffmpeg encoding.
I installed ffmpeg using Macports. ffmepg version is 4.4.1
Thanks
I recently upgraded to Windows 11, just in case that matters, and I went to encode a series of images into a video with FFmpeg like I usually would. For some reason seemingly randomly it just stops. No error is given, the frame that it stops on is random, the amount of time it's encoding for is random, and starting from a different frame doesn't change anything.
Here is the code I'm using:
ffmpeg -r 59.94 -f image2 -start_number 0 -i "%06d.png" -vcodec libx265 -crf 18 -preset medium -tune grain -pix_fmt yuv420p10le "Encode/S2005E14.mp4"
The version of ffmpeg I'm using is the newest git-full version from https://www.gyan.dev/ffmpeg/builds/
The CPU being used to encode it is a Ryzen 3900x.
Log: https://pastebin.com/EnyWs7cL
The problem was caused by an unstable overclock. After reducing the overclock everything worked normally.
I'm using ffmpeg to string together some .bmp images into a movie. In total, there are 1001 frames, amounting to 0:40 length. The command I'm using is
ffmpeg -f image2 -i render.%05d.bmp -c:v libx264 -s 512:268 render.mp4
The output file is 33,2 MB large, which is about twice the size of a full HD (about 16 times the pixels!) video of the same length. Apart from the file size being unreasonably large, I realized it grows faster than linearly (can't tell exactly if it is quadratic, exponential etc.) with the number of frames. After 100 frames it is about 1536 KB large (which is already too large), after 500 frames it is already 15104 KB, and after 1001 it finally arrives at 34085 KB.
My educated guess would be that for each frame it stores some information about all of the previous frames again, which makes absolutely no sense.
What am I doing wrong? Before you recommend libx265 to me: It turns the entire video green.
Use:
ffmpeg -i render.%05d.bmp -c:v libx264 -vf "scale=512:-2,format=yuv420p" -movflags +faststart output.mp4
If the output file size is too big add the -crf and -preset options as described in FFmpeg Wiki: H.264.
If the output is still too big change -c:v libx264 to -c:v libx265 but encoding will be slower. Your output was green when you tried x265 because of the pixel format: using format=yuv420p as shown in my example will fix that. See FFmpeg Wiki: H.265.
If you are targeting a specific output file size then use two-passes with -b:v (see either link above).
I want to convert a mkv formatted video to mp4, using the ffmpeg application.
and for that I ran below command in terminal:
ffmpeg -y -i c38a4990774b3c23.mkv -c:v libx264 -c:a aac -r 25 -strict -2 -map_metadata -1 -movflags faststart -vf "crop=1920:800:0:4, scale=iw*min(426/iw\,240/ih):ih*min(426/iw\,240/ih), pad=426:240:(426-iw*min(426/iw\,240/ih))/2:(240-ih*min(426/iw\,240/ih))/2, setsar=sar=1" output.mp4
I have compiled ffmpeg with --enable-pthread configuration
when I run this command on my personal PC with a 3.2GHz quad core cpu, it uses 60% of overall cpu process and encode video with 150fps; but when I run this command on a production server with 8 2.4GHz dual core cpu (16 core) it only uses up to 20% of overall cpu process and encode video with 97fps.
I have also tried ramdisk but I got no performance improvement.
My computer (Intel Core 2 Duo T9300, 2.5GHz) can usually play any Full HD file, and Blu-Rays perfectly.
However, when I encode a Full HD file myself, the CPU is struggling and frames are dropped.
Here's my command line:
ffmpeg.exe -r 24 -f concat -i list_of_png_files.txt -i w:\audio.wav -acodec copy -c:v libx264 -preset medium -b:v 10000k -shortest output.avi
I tried adding -maxrate 13000k after "-preset medium". However, x264 doesn't seem to honor this - the framerate still reaches 20MBit at parts.
How can I encode videos in such a way as to reduce CPU usage during decoding?
There is an x264 tuning option for exactly this purpose. I believe -tune fastdecode is what you are looking for. But this will disable some compression features, so the video may not look as good without increasing the bitrate.