Can mjpg-streamer Stream To a Streaming Service?

Hello,

I'm wanting to stream my prints to my Twitch channel and I'm trying to find out if mjpg-streamer has the capability. I have figured out a little work around, by installing libav-tools and using the following command:

raspivid -t 0 -fps 25 -hf -b 2000000 -o - | avconv -i - -vcodec copy -an -r 30 -g 30 -bufsize 2000000 -pix_fmt yuv420p -f flv rtmp://TWITCH_INGEST_ENDPOINT/YOUR_STREAM_KEY_HERE

The only thing is, you have to kill the mjpg_streamer process for this to work, or you'll get mmal_vc_component_enable failed to enable component enospc since mjpg-streamer is started at boot and is using the camera.

So, I'm trying to figure out if mjpg-streamer can stream to Twitch by itself, instead of me installing other software, using it, and killing the mjpg-streamer process.

Thanks.

That seems like it should be possible, there's an MQTT plugin and a youtube plugin. Have you looked at possibly modifying one of those ?

I do have some programming background, but I will admit this is a bit more advance, for me. I do know of the YouTube plugin, and was going to take a look at it. I just didn't know if mjpg-streamer can actually stream to Twitch, cause if it doesn't have the capability, I didn't want to waste my time researching.

Time spent researching goes toward your Cool Guy points.

Or ask and you shall receive....thanks for the idea @BeerGeekGamer.

I forked my YouTube-Live plugin to work with Twitch. The difference being it should work with any RTMP streaming service as long as it's a simple url you post to. I tested Twitch and it is working for me.

2 Likes

Sooooo, how about a html5-compatible streamer? :sunglasses:

I played with it a little before...in theory the plugin below could work, but it's only for displaying the stream, not actually sending the stream. The mp4 type would embed the html5 player if I remember correctly.

Interestingly enough, it looks like someone got gstreamer working outside of octoprint to stream h.264 video on a pi a while back for working with octorprint. Don't think he ever got it completely working because he didn't use the plugin system and wrap his commands using the gstreamer python library. More information on that blog post over here.

From what I can tell from other searching on gstreamer...it's not very well documented and looks to be very robust and therefore complex at the same time. There could potentially be issues with gstreamer on Raspbian Stretch, but haven't really dug into it that much yet. I'm assuming a little tweaking to the haproxy config would allow gstreamer to function in lieu of setting of nginx etc. like mentioned in that blog post.

If I get some time I'll look into the possibility of making that into a plugin or potentially integrating gstreamer into the RTMPStreamer plugin I've created.