FFmpeg latency is over 3 seconds (must be subsecond)

Viewed 265

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!

1 Answers

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.

Related