FFmpeg randomly stopping during encoding. No error given - ffmpeg

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.

Related

get consistent 60fps while recording X screen with ffmpeg

I wrote the following script to record an X screen for a specified amount of time, to make sure that it's lossless I've separated it into two steps
record for the specified amount in a codec that requires almost no compression (so there's no overhead that might cause frames to be dropped)
re-encode the original video into HEVC to make the filesize significantly smaller
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -vsync 1 -f x11grab -probesize 128M -s 1920x1080 -r 60 -i :0.0 -qscale 0 -vcodec huffyuv -t 00:01:13 "$video.avi" # record the screen losslessly
ffmpeg -hwaccel cuvid -vsync 1 -i "$video.avi" -map 0:0 -c:v:0 hevc_nvenc -crf 23 -preset medium "$video-clean.mp4"
This works just like I expect it to some of the time, but very often it drops a lot of frames (I've seen as many as 10000 frames dropped on occasion)
The gpu is a 1080 TI that's being used just for rendering an X server with a chrome window and recording it, according to nvidia-smi the usage never goes to higher than 50% even in the most extreme cases.
I don't know what else to try, I thought about using a ramdisk to write the file to as it might be an IO problem, but ffmpeg refuses to write to tmpfs (for some reason I can't explain)
Solved it, recording to a tmpfs turned out to be the solution for me, however because I was using the snap version of ffmpeg I couldn't directly write to ram (because of permission issues), so I just compiled ffmpeg myself (needed support for cuda, and since this script runs on an ubuntu-based machine and the apt version of ffmpeg doesn't have access to cuda for some specific encoders I just compiled ffmpeg myself)

FFMPEG not getting a smooth video

I am trying to record my screen using ffmpeg but i am not getting a smooth video. Below is the command line code used. I am using windows 10;
ffmpeg -f gdigrab -framerate 30 -i desktop output.mp4
is there is any extra setting to get a good video
Currently output video is playing like missing frames
I myself found the answer, I changed the code like below
ffmpeg -f gdigrab -framerate 24 -probesize 42M -i desktop -preset ultrafast -pix_fmt yuv420p camera1.mp4
Actual i had a warning "Stream #0: not enough frames to estimate rate; consider increasing probesize" so i increased the probesize and added the ultrafast preset.
Now it is recording with good quality...

Can't fix timestamp of WebM video with dynamic resolution using FFmpeg

I'm developing the platform for 1-1 video calls with recording. For my purposes, I work with the following stack: WebRTC, Kurento Media Server, FFmpeg.
It works perfectly in an ideal environment, but if my users have a poor connection, after the recording I see a lot of problems with the out of sync audio and video tracks.
As I understand, the problem appears due to the incorrect timestamp, so I'm doing a bit post-processing where I generate a new timestamp and it helps!
Here is the command example:
ffmpeg -fflags +genpts -acodec libopus -vcodec libvpx \
-i in.webm \
-filter_complex "fps=30, setpts=PTS-STARTPTS" \
-acodec libvorbis -vcodec libvpx \
-vsync 1 -async 1 -r 30 -threads 4 out.webm
After that, I've faced one more problem. If the user has a poor connection, WebRTC can dynamically change the video resolution. After the post-processing for such type of videos (with the different resolutions during the video) I see the frozen image until the end of the video and it started from the moment, where the resolution was dynamically changed. There are no error in the FFmpeg logs, just information about changing the resolution:
[libvpx # 0x559335713440] dimension change! 480x270 -> 320x180
-async is forwarded to lavfi similarly to -af aresample=async=1:min_hard_comp=0.100000.
After analyzing the logs, I realized that the problem was due to the STARTPTS parameter, which, after automatically changing the extension, became very large (equal to the number of frames that were before it). I tried to remove STARTPTS and leave only PTS.
After that, the video started to work well, but only until the video resolution are dynamically changed, then again the audio and video tracks are out of sync.
I've tried to scale videos to a static resolution before fixing timestamp and it helps. But it's a little bit extra work. Command example:
ffmpeg -acodec libopus -vcodec libvpx \
-i in.webm \
-vf scale=640:480 \
-acodec libvorbis -vcodec libvpx \
-threads 4 out.webm
Also I've tried to combine both commands using filter_complex, but it didn't work.
I've worked with FFmpeg not so many time so far, so, maybe I'm doing something wrong? Maybe there are some easier ways to do that?
Since Kurento uses GStreamer for the video recording, so maybe it would be a better option to reconfigure Kurento to fix timestamp during the video recording?
I can provide any videos and commands which I use.
I'm using:
Kurento Media Server 6.9.0,
FFmpeg 4.1

FFMPEG PERFORMING VERY SLOW

I'm trying to setup a media processing server. I've done a lot of research for FFMPEG and wrote a command. The command is as follows.
ffmpeg -y -i "bbb_sunflower_2160p_60fps_normal.mp4" -c:v libx264 \
-threads 7 -profile:v main -preset ultrafast -vf scale=1920:-1 \
"process/video/1080p.mp4" -c:v libx264 -threads 7 -profile:v main \
-preset ultrafast -vf scale=1280:-1 "process/video/720p.mp4" -c:v \
libx264 -threads 7 -profile:v main -preset ultrafast -vf \
scale=854:-1 "process/video/480p.mp4" -vf fps=5/60 \
process/image/thumb_%d.jpg
This command works and runs perfectly, but it is dirt slow. My server, which is dedicated to just running ffmpeg has the following specs:
12 core intel Xeon X5650 (Hyperthreading enabled)
64 GB ECC DDR3 RAM
250 GB SSD Drive
But when I use this command, the server CPU load hangs around 250-300%, which I would like it to hang around 2,000% while processing the video. Currently when processing the video, the server is rendering around 17 frames per second. This would take a very long time to process a 10 minute video that's 60fps.
It's the scaler. The scaler in ffmpeg is single threaded, it is a bottleneck on a system with that many threads. Try running a different process for each output.
If you are running windows, try again with defender (and any other virus checker) disabled. It can make a huge difference.
Let us know the outcome please...
This worked for me on a windows 10 machine (which then processed up to ten times faster ) and is therefore a possible answer to the above problem. Clarification (of any sort) is not requested, but it would be good to know if it helped.
This is a very complicated commandline with little to no useful information. For example, you're not providing FFmpeg stdout/stderr (which contains lots of useful information). Possible causes:
video encoding is simply too slow (try 1 encode instead of 3, w/o screenshots)
maybe your bottleneck is audio (test with -an)
something else?
I'd encourage you to test simpler versions and provide stdout/stderr.

x264: Encoded videos need lots of CPU to play

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.

Resources