ffmpeg - How to use all the CPU of the server? - ffmpeg

I am using this command to run ffmpeg -
ffmpeg -i - -isync -threads 16 -vcodec libx264 -acodec aac -ar 22050 -r 25 -s 640x360 -strict experimental -b:a 32k -b:v 100k -f flv "rtmp://" -threads 16 -vcodec libx264 -acodec aac -ar 22050 -r 25 -s 640x360 -strict experimental -b:a 32k -b:v 400k -f flv "rtmp://"
I am running ffmpeg processes on my server. Currently ffmpeg don't use all my CPU, I want to use all my CPU usage.
My server has 24 CPU, 16 GB RAM, and 1 TB HDD. Please tell me the command to use all my CPU usage, and to make my ffmpeg smooth.
Thanks

0% idle and 0% wait. That is using 100% of your CPU. Your computer is just not powerful enough to process 20 videos simultaneously. You can try adding the 'ultrafast' option to use less CPU per encode (at the price of lower quality)

Related

FFmpeg latency is over 3 seconds (must be subsecond)

I'm working on a robot (raspberry pi 4 based) that is accessible from anywhere. My robot is currently at a 3-second latency. I also use OvenMediaEngine (RTMP to WebRTC) to transmit my stream to the client (on a website).Here is my command:
raspivid -n -t 0 -w 1280 -h 720 -fps 25 -b 3500000 -g 50 -fl -o - | ffmpeg -thread_queue_size 1024 -i - -itsoffset 6 -f alsa -channels 1 -thread_queue_size 1024 -i hw:2 -preset ultrafast -tune zerolatency -vcodec libx264 -r 25 -b:v 512k -s 1280x720 -acodec aac -ac 2 -ab 32k -ar 44100 -f flv rtmp://xxxxxxxx:1935/app/stream
Does anyone know why it won't stream at subsecond latency?
Thanks in advance!
I am not exactly sure where you are incurring latency, but it usually happens either during transport or encoding.
If possible I would see if you avoid re-encoding to H264. You are going to pay a penalty of decoding (or just parsing?) and then encoding.
I would also see if you can ingest into OME with something other then RTMP. WebRTC and RTSP both will give you better latency.

ffmpeg process has GPU usage limit

i'm using ffmpeg and an NVIDIA for my video transcode process.
so i have one problem.
look at below image :
one process just use 263MiB of my second GPU. not completly use that !!
that is not good. i think there should be a way to remove this limitation for gpu process.
my ffmpeg command that i run is:
ffmpeg -y -loglevel info -hwaccel cuda -hwaccel_output_format cuda -hwaccel_device 1 -i "MYVIDEO" -vf scale_npp=w=426:h=240 -c:v h264_nvenc -profile:v main -b:v 400k -sc_threshold 0 -g 25 -keyint_min 25 -bf 2 -c:a aac -b:a 64k -ar 48000 -f hls -hls_time 6 -hls_playlist_type vod -hls_allow_cache 1 -hls_segment_filename f-0-seg-%d.ts f-0.m3u8
There is no limitation going on here, At least not related to memory.
You are scaling the video to 426x240 Assuming 4:2:0 subsampling, That is 153K per frame. The encoder needs 16 frames at most. Which is a little over 2MB. The GPU is using over 100 times that.

How to switch from yuyv422 to yuv420p for better framerate in ffmpeg on Windows 10

I upgraded PC from Windows 7 to Windows 10, as it is discontinued. Problem is,
I had low latency monitoring and recording solution with FFmpeg.
After the upgrade, Logitech camera switched from yuv420p to yuyv422 and I lost 30 fps support at 1280x720. Now it is only limited to 10 FPS.
Tried different drivers, it still yuyv422
Here is a code i use.
ffmpeg -y -loglevel panic -hwaccel qsv -threads 1 -fflags nobuffer -flags low_delay -strict experimental -f dshow -video_size 1280x720 -framerate 10 -pixel_format yuyv422 -i video="C922 Pro Stream Webcam" -codec:v libx264 -preset ultrafast -crf 24 -tune zerolatency -map 0 -f segment -segment_time 600 -segment_wrap 2 -reset_timestamps 1 dvr_%%04d.avi -codec:v copy -f nut - | ffplay -fflags nobuffer -flags low_delay -vf scale=1920x1080:flags=lanczos -window_title "kamera" -noborder -left 1920 -top 150 -fast -framedrop -
I really need low CPU, no latency monitoring at minimum 24 FPS and recording capabilities. File size doesn't matter so much.
Using mjpeg eats CPU like crazy.
I force installed old Logitech driver and get back yuv420p/30FPS support.
I store some instructions and drivers here: https://github.com/mjasnikovs/logitechC920-vlc
Maybe somebody will find it useful.

How to reduce audio delay in FFmpeg using HTTP FLV stream?

I have problem with live http flv stream. I'm using the following command and it works great except for the audio. Audio has delay that increasing over time. I can fix the this by removing refresh rate option on the output (-r 30) but then stream latency goes higher for about half second.
ffmpeg -f v4l2 -threads 0 -video_size 672X420 -i /dev/video1 -f alsa -thread_queue_size 512 -i hw:1,0 -c:a aac -ar 44100 -b:a 128k -c:v libx264 -s 672x420 -r 30 -g 60 -preset superfast -tune zerolatency -strict -2 -f flv rtmp://localhost/live/primary
Can someone explain why this happening and what possible fixes are?
On the client I'm using Chrome with flv.js library.
On the server Node-Media-Server.

ffmpeg erases the last part of audio in the video file

I use following encoding option.
ffmpeg -i input.wmv -movflags faststart -c:v libx264 -profile:v baseline -acodec aac -ac 2 -ar 48000 -strict -2 /root/output.mp4;
But sometimes last 5~30 seconds audio is erased.
Total video duration is about 3 mins.
what do you think the problem is?
Is this related to computer performance? I use quadcore, 4G ram.

Resources