popcornmix / omxplayer

omxplayer
GNU General Public License v2.0
1.01k stars 334 forks source link

omxplayer has 20s delay on raspberry pi live stream #832

Open gitterman opened 10 months ago

gitterman commented 10 months ago

I am running buster on a pi model B which acts as a door monitor with an attached USB cam. The camera is streamed with mjpg_player on the internal network without any significant delay. I also have a 640x480 car monitor attached to the analog video output, and I am using omxplayer to show the stream on this monitor. Alas, there is a delay of about 20s on the omxplayer output which makes the setup rather unusable. The command line I am using is: omxplayer -r -b --no-keys --live http://$HOSTNAME:8080/?action=stream I have tried to reduce the frame rate by adding --fps 10 before the --live option but no change.

popcornmix commented 10 months ago

Setting the fps higher than the actual rate would be more likely to reduce buffering (although if stream contains timestamps the fps setting will be ignored).

I'd suggest playing with:

  --audio_fifo  n         Size of audio output fifo in seconds
    --video_fifo  n         Size of video output fifo in MB
    --audio_queue n         Size of audio input queue in MB
    --video_queue n         Size of video input queue in MB
    --threshold   n         Amount of buffered data required to finish buffering [s]

But be aware omxplayer is deprecated and will get no updates, so you may be better off with a newer distribution and a supported tool like VLC.

gitterman commented 10 months ago

Thanks for the quick answer, I will give it a try. From my understanding VLC is way much more resource consuming than omxplayer and has its problems when running without a GUI. My doorcam pi runs just from CLI and has no keyboard attached. Tools like omxplayer and streamers like mjpg_streamer are very valuable in these scenarios. The usefulness of a raspberry pi as a headless workhorse in the closet, without a GUI is much bigger than to use it as a desktop because of its lack of power compared to a cheap refurbished notebook. It is a pity that things become so GUI oriented these days.

popcornmix commented 10 months ago

VLC will run without a gui (e.g. from a RPiOS lite image launched from CLI).

gitterman commented 10 months ago

Installation of VLC required 224MB, and it is not supposed to be run as root. I can display the stream with VLC on my desktop PC and on my raspberry 4 GUI, but I did not succeed to get the live stream shown on my attached analog display to my CLI only buster raspi yet. I also found that VLC needs more CPU than omxplayer. So far, I have changed the omxplayer command according to your hints to the one below, which reduces the delay to about 4 seconds, which is acceptable for me. omxplayer -r -b --no-keys -n -1 --video_queue 0.1 --live http://$HOSTNAME:8080/?action=stream