Using ffmpeg for webcam streaming and timelapse support

Hey, great to hear. Yes, this was not meant to be a step-by-step guide, just wanted to share how I did it, as the documentation of restreamer is quite good.
If there's a demand I can maybe write this down in more detail.

Same here... that's why I meant that the whole thing is kind of a mess :wink:

How much cpu load do you have at 1080p@30? Here all 4 cores are lifting between 30-60% for 720p. See htop for info.
Thus I'm seeking the hardware encodig ffmpeg. I've found an old NUC with a Pentium G5400... I will test about the cpu load on this.

Do you have an h264 capable camera?
How long is your delay? I have around 5-10 seconds.

Hmm, I think I did not have the size hassle, or do I?
But I admit, that I've also exposed a standalone player through nginx (https, letsencrypt) to only watch without the Octoprint controls.

Pi 4 is a four core device and load average sits at around 1.36, but no single CPU is maxed ever. At most I see Chromium taking up a good chunk of CPU but usually sub 50%, sometimes as high as 80. ffmpeg sits sub 10%. Looking at ffmpeg's parameters it's just do a copy rather than any transcoding so this doesn't really surprise me. My camera is a Raspberry Pi v2 camera which natively outputs H264, hence the transcoding not being necessary.

My delay is like 5-10 seconds. I hate that, I was trying to see if it's the player that's buffering it, or something in streaming. I mean it doesn't really matter, seeing the printer delayed doesn't really change the usefulness of this that much, but it does bug me :slight_smile:

Your screen shot shows pretty low res to my eyes for that window. I am using a 1920x1080 stream, so I wanted my window to match. I'm using the Themify plugin to expand the interface making room for the Webcam iframe.

Ah, then it's clear that this is easy going.
I'm using a Logitech C920, sadly the new version without hardware encoding.
That's why I've opened an issue over at restreamers github as the Pi has hardware h264 encoding capabilities that would be great to use.

I've found this regarding the delay, but did not implement it, yet:

Well, I got an 1080p monitor and cause of the software encoding I thought 720p is enough for the video. Maybe I will bump it up once propper hardware encoding or the NUC is in place.

Rather than patching a generated file it might be a little safer to use Themeify and just make the edit there.

1 Like

Oh yeah you're 100% right there. I have no idea (yet) how to make the tweak via Themeify but I suspected that would be the ultimate solution.

I tried copying the configs from the container and mounting them outside and editing the nginx.conf with the hls setting changes mentioned in that link about lag, and they didn't improve the lag at all for me. I'm staring at it wondering if I did something wrong.

Search the forum for "pimp" for a wide variety of edits we've all made.

Well I'm no Docker person... I will look into this when I get feedback from the restreamer guys.

Per OutsourcedGuru's nudging about Themeify, it hit me that the settings were pretty simple to do:
Selector CSS-Rule Value
#webcam_container height 1080
#webcam_container width 1920

so no silly manually editing of the generated file which can get lost with other changes (happened to me which lit the fire under my butt to figure out how to do this in Themeify).

2 Likes

Anyone knows if this works with MultiCam plugin ?

So now we need to use c930e only ?
I need to check if the c920 in my setup has h264 (it should because I've bought an older one second hand).

Puhh... I think @jneilliii would have to answer this.

Not quite. I'm using the C920 but have some cpu load (40-50%) as it don't has native h.264, thus I can't use copy in the encoding options of restreamer. But it works.
Currently I know no way to use hardware h264-encoding which the Pi is cappable of. See my comment on the issue over at restreamers github:

Not really sure, never used multi cam, but my assumption is no because I think it just charges the src attribute of the image.

I'm having CORB issues when I use the 192.168.1.XXX ip of the Pi, and connection refused when I use 127.0.0.1... and I don't even know where do to begin to fix that.

I can see restreamer fine in my browser, though!

HLS support for OctoPrint....

Setting up Octoprint on a old Toshiba laptop with Ubuntu 18.04. After a few days of struggle trying to get mjpg streamer to work I decided to try this and finally got a webcam feed... but the snapshot url isn't working. I can get more detail is needed any help would be awesome!!! (Next time I'm just buying the Pi, ha)