jneilliii / OctoPrint-RTMPStreamer

22 stars 13 forks source link

Choppy Live Stream #15

Closed adewey30 closed 4 years ago

adewey30 commented 5 years ago

Hi, I am running octoprint and RTMPStreamer on a Raspberry Pi 3 B+. I have been able to get a Twitch stream up, but it is very inconsistent and choppy. I have tried resolutions and frame rates from 640x480 15fps to 1280x720 30fps and they all have the same, choppy result. I noticed that the bitrate appears to be locked at 700kbps and it may need a higher bitrate to support the stream. I have the raspberry pi on ethernet with upload/download speeds around 90 mbps. Is there any further adjustments I can try beyond resolution and frame rate?

jneilliii commented 5 years ago

Not really sure actually. Because the stream is being re-encoded there could be other options to the ffmpeg command line in entry.sh of the docker image that gets built that could help. If you find an option that works well using standard ffmpeg command line options let me know and I could integrate into the plugin. From my understanding the bitrate is being calculated based on the other options but I might be wrong.

adewey30 commented 5 years ago

I'll poke around and see if I can't get something to work

jneilliii commented 5 years ago

I forgot to ask, did you also update your octopi.txt file for the camera settings to be optimized to match the plugin settings?

adewey30 commented 5 years ago

I'll check tonight when I'm back at my printer. I think I set it to 1280x720 30fps but I only restarted octoprint and not the entire system.

jneilliii commented 5 years ago

Yeah, changes to that file require restart of the pi I think, not just octoprint.

adewey30 commented 5 years ago

I verified that I have the same camera settings between RTMPStreamer and octopi.txt. Rebooting with the updated camera resolution didn't change anything with the stream. I've checked that the cpu usage is not causing any issues while streaming as well.

My camera settings in octopi.txt are camera_raspi_options="-x 1280 -y 720 -fps 30 -ex auto -quality 95" I'm not sure how to edit the dockerfile to get to entry.sh in order to edit the ffmpeg options.

jneilliii commented 5 years ago

In the instructions listed below the entry.sh file is part of the git clone.

cd ~
git clone https://github.com/jneilliii/rtmpstreamer --depth 1
cd rtmpstreamer
docker build -t octoprint/rtmpstreamer .

So if you go into the folder ~/rtmpstreamer the entry.sh file should be there. Make adjustments and then rerun the command docker build -t octoprint/rtmpstreamer . (don't forget the period at the end).

adewey30 commented 5 years ago

I've been playing around with changing the bitrate, adding a buffer, and a few random things but haven't had any luck. I've noticed that when I test the stream in the ssh terminal, it shows that the fps is around 5 and the speed is around 0.13 which definitely doesn't seem right. It explicitly shows that it should be 30fps though in the initialization section Here's an example of the output frame= 47 fps=4.0 q=-0.0 Lsize= 295kB time=00:00:01.55 bitrate=1553.3kbits/s speed=0.133x

jneilliii commented 5 years ago

Yeah, that's what is being detected by ffmpeg when you run the command. I can't control what it does I'm afraid, so not going to be able to help much.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had activity in 14 days. It will be closed if no further activity occurs in 7 days.