FFmpeg, capturing video is laggy, how to eliminate that? - ffmpeg

Lets say I dont have a very good computer and my recordings are laggy. Two version I tried:
ffmpeg -f dshow -framerate 30 -i video="screen-capture-recorder":audio="virtual-audio-capturer" -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le output.mkv
ffmpeg -f gdigrab -framerate 30 -i desktop -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le output.mkv
I tried to avoid all compressing stuff, still lagging. Although Im recording 1920x1080 video... I dont care how big the result is. Isnt there an option like "store all frames, and encoding a bit later, I dont care the realtime capturing" ?

Related

FFmpeg - Streaming from a rtsp server to a rtmp server - loosing packages

I'm trying to stream a video from a rtsp server to a rtmp one using FFmpeg.
Tried multiple arguments for my command :
ffmpeg.exe -re -i "rtsp://10.65.28.251:11442/video/live" -pix_fmt yuv420p -codec:v libx264 -tune animation -preset fast -crf 23 -maxrate 4M -bufsize 8M -f flv "rtmp://10.65.58.21:1935/rec/XB"
ffmpeg.exe -re -i "rtsp://10.65.28.251:11442/video/live" -preset ultrafast -vcodec libx264 -tune zerolatency -b 900k -f flv "rtmp://10.65.52.131:1935/rec/XB
I'm loosing a lot of packages as seen in the picture. I'm pretty new to FFmpeg so I'm pretty sure I'm messing up the parameters somehow.
My goal is to get a video on rtmp with min 30fps and as least lost packages as possible. If needed a downsize of the video quality would be fine.
Any idea what I'm doing wrong?
Thanks!
As kesh pointed above removing -re made a big difference. I ended up with this command which holds pretty good quality at 30fps.
ffmpeg.exe -i "rtsp://serversource:11442" -filter:v fps=fps=30 -crf 40 -preset ultrafast -vcodec libx264 -f flv "rtmp://servertarget:1935"

ffmpeg resulting in no audio and unplayble video

I am trying to get ffmpeg to work as expected however I am having all kinds of trouble getting it to work.
I need to output a webm and h264 for web play. However, the command I am using, while it used to work a few years ago, does not work at all now.
Both my webm and h264 do not have audio, and neither will play in any browser.
My command for webm is:
ffmpeg -y -i "$KMVAR_File" -c:v libvpx -crf 24 -b:v 1000k -vf scale=720:-2 -c:a libvorbis "$KMVAR_webmPath"
and my command for mp4 is:
ffmpeg -y -i "$KMVAR_File" -c:v libx264 -pix_fmt yuv420p -profile:v baseline -level 3.0 -crf 32 -b:v 1M -minrate 1M -maxrate 1M -bufsize 2M -vf scale=720:-2 -c:a aac -strict experimental -movflags +faststart "$KMVAR_mp4Path"
When playing with multiple audio, downmixing or extracting, there's no "one size fit all" solution with ffmpeg.
Look at https://trac.ffmpeg.org/wiki/AudioChannelManipulation as it provides multiple possible solution to your problem.
(I usually go with the pan filter : not the easiest to use, but more powerful than the map_channel approach)

ffmpeg - slow x11 framerate when audio enabled

I've got a weird issue running ffmpeg and trying to capture my screen.
When I run it with:
ffmpeg -video_size 512x383 -framerate 60 -f x11grab -i :0.0+512,203 -c:v libx264 -crf 0 -preset ultrafast -t 20 /tmp/lossless.mkv
I can capture 60fps without any issue.
However, as soon as I try to capture audio. The framerate drops to less than 30fps:
ffmpeg -video_size 512x383 -framerate 60 -f x11grab -i :0.0+512,203 -f pulse -ac 2 -i default -c:v libx264 -crf 0 -preset ultrafast -b:a 64k -t 20 /tmp/lossless_with_audio.mkv
See here for command output: https://pastebin.com/BMq38raq
I'd try with:
ffmpeg -framerate 60 -f x11grab -thread_queue_size 1024 -i :0.0 -f pulse -ac 2 -i default -c:v libx264 -acodec libmp3lame -crf 0 -preset ultrafast -b:a 64k -t 20 /tmp/lossless_with_audio.mkv
Also, in terms of framerate, Are we talking about high motion here, such as game graphics? If not, I'd reduce the framerate to 25-30.
Note that the FPS may also drop due to lack of CPU resources so you should check the utilisation.
You may also want to review https://trac.ffmpeg.org/wiki/EncodingForStreamingSites
Cheers,
This is a very weird problem, I have the slight feeling that starting dbus helped prevent this problem.
https://stackoverflow.com/a/64080884/903004

ffmpeg - Convert MP4 to WebM, poor results

I am trying to encode a video to webm for playing through a HTML5 video tag. I have these settings...
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:a 128k -b:v 1M -c:a libopus output.webm
The results aren't great, video has lost lot's of it's sharpness. Looking at the original file I can see the bitrate is 1694kb/s.
Are there any settings I can add or change to improve the output? Would maybe a 2 pass encode improve things?
Try with
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -b:a 128k -c:a libopus output.webm
Adjust the CRF value till the quality/size tradeoff is ok. Lower values produce bigger but better files.
Try to run two passes:
ffmpeg -i file.mp4 -b:v 0 -crf 30 -pass 1 -an -f webm -y /dev/null
ffmpeg -i file.mp4 -b:v 0 -crf 30 -pass 2 output.webm
From - https://trac.ffmpeg.org/wiki/Encode/VP9

FFMPEG HLS video speed is too fast

I am trying to make a .m3u8 hls playlist locally on my computer. I am using Windows 7, 32 bit.
I am a begginner of FFMPEG, and finally I combined some commands into this:
ffmpeg -re -rtbufsize 999999k -y -f dshow -video_size 640x360 -r 15 -i video="ManyCam Virtual Webcam" -c:v libx264 -crf 18 -profile:v main -maxrate 999999k -bufsize 99999k -pix_fmt yuv420p -flags -global_header -hls_time 10 -g 3 -hls_list_size 2 -hls_wrap 0 -start_number 1 D:\\stream\stream.m3u8 -tune zerolatency
The problem is that while playing the m3u8 playlist with VLC or a HLS player, the video speed is faster than normal.
If you need more info, please comment.
EDIT
If I play one of the .ts files, the problem is the same.
Thank you so much!

Resources