Web Hosting Forum | Lunarpages

Author Topic: MJPEG rebroadcast with only one connection to the source  (Read 11421 times)

Offline edlins

  • Newbie
  • *
  • Posts: 3
MJPEG rebroadcast with only one connection to the source
« on: September 27, 2011, 08:27:22 AM »
Hi all,

I'm trying to rebroadcast an MJPEG on my shared linux host such that any number of web users can connect to the LP host and receive an MJPEG stream, while the host maintains only one connection to the original MJPEG source.

I currently have a PHP script that pulls the MJPEG stream from the source and pushes it to a user's web browser.  Each web user spawns a separate PHP session that initiates its own connection (via PHP cURL) to the original source.  This actually works very well, but the problem is that the original source's network connection is low bandwidth and more than one user really bogs it down.  This connection cannot be upgraded.  :(  I also have a javascript page that pulls JPG stills (again via PHP cURL) one at a time from the source, but that only gives me one image every 10 seconds whereas the connected MJPEG stream gives me about 1 frame per second (10 times faster).

What I'd like is a lightweight rebroadcast server that utilizes one permanent "service" connection to the MJPEG source and reproduces the MJPEG stream for any number web users.  Since I'm on a shared account, I'd rather not consume CPU transcoding the stream, so MJPEG output is fine.  Each web user would connect to the shared host only, and that would _not_ create a new connection to the source but the server would utilize a _single_ connection to the source to serve all web users.  I don't know of a way to do this simply (one page of code or less) in home-brew PHP.

I know there are various media servers that can do this, such as VLC as discussed here:
http://stream.deus-exmachina.net/axis-vlc-mms-HOWTO.html
However, it appears that VLC is not installed on my host (Nott).

So, does anyone have any ideas on how to do this?  Should I request VLC for Nott or pursue another option?

Thanks in advance,
-scott

Offline AndrewBucklin

  • Newbie
  • *
  • Posts: 2
Re: MJPEG rebroadcast with only one connection to the source
« Reply #1 on: November 04, 2011, 06:19:04 PM »
I am looking to do the same.  I have a solution almost worked out, but I'm interested in seeing if you found a solution?

Offline beerhat

  • Newbie
  • *
  • Posts: 2
Re: MJPEG rebroadcast with only one connection to the source
« Reply #2 on: August 02, 2014, 02:49:17 PM »
I am looking to do the same.  I have a solution almost worked out, but I'm interested in seeing if you found a solution?

OK, so this post is rather old.. yeaaaahh I get that.  But, I actually had the same problem a couple years back and have since then come up with a bulletproof solution.  Been in place for a couple years now, rock solid.  So, I'll share.


I use the strings below in a startup script to take a single feed from our Foscam (used as a babycam, limited to 4 http connections for viewing), and rebroadcast on the localhost port 8080 (and 8081 for a slower framerate).  The only 'special' software installed on the Linux box is vlc.  It takes next to no CPU.  I've stress tested it running 40 or so streams to network connected PCs and load is still 0.00.  Pretty amazing actually.   There should be no reason you can't use this as a one-to-many to serve your need.  The string below actually introduces authentication, but you can leave that out if you prefer.

# FAST FEED - 30 FPS
/usr/bin/vlc -I dummy "http://172.16.0.15:8080/videostream.cgi?user=camuser&pwd=campassword" --no-sout-audio --sout '#standard{access=http{user=picksomething,pwd=picksomething},mux=asf,dst=0.0.0.0:8080}' &

# SLOW FEED - 5 FPS
/usr/bin/vlc -I dummy "http://172.16.0.15:8080/videostream.cgi?user=camuser&pwd=campassword&resolution=32&rate=11" --no-sout-audio --sout '#standard{access=http{user=picksomething,pwd=picksomething},mux=asf,dst=0.0.0.0:8081}' &

Dan

Offline davidfrost

  • Space Explorer
  • ***
  • Posts: 8
Re: MJPEG rebroadcast with only one connection to the source
« Reply #3 on: August 03, 2014, 09:04:27 AM »
I am looking to do the same.  I have a solution almost worked out, but I'm interested in seeing if you found a solution?

Can you please share on how you were able to do this?

Offline AndrewBucklin

  • Newbie
  • *
  • Posts: 2
Re: MJPEG rebroadcast with only one connection to the source
« Reply #4 on: August 03, 2014, 01:50:31 PM »
Can you please share on how you were able to do this?

Honestly, I don't remember; it's been so long... But I'm pretty sure I would have done whatever I did using VLC on my Windows desktop computer. Reference beerhat's post above; that looks familiar.

On a similar note, I'm putting together a service that might accomplish this (among many other things), if you're interested.  Maybe I'll also sell the software so you can run it on your own shared linux hosting server...

Offline gavind

  • Spaceship Navigator
  • *****
  • Posts: 99
Re: MJPEG rebroadcast with only one connection to the source
« Reply #5 on: October 19, 2014, 09:41:44 AM »
Count me in here then. Please post it as soon as available. Would be nice to get free updates here too.

Offline beerhat

  • Newbie
  • *
  • Posts: 2
Re: MJPEG rebroadcast with only one connection to the source
« Reply #6 on: December 11, 2014, 04:48:02 PM »
Ok, so I've retired my old mjpeg based cams, in favor of some new h.264 cams.

My new strings for h.264...

########### MAIN INPUT FEEDS #############
# h.264 CAM 720p
/usr/bin/vlc -I dummy "rtsp://cam-username:cam-password@172.16.3.44:53280/videoMain" --no-sout-audio --sout '#standard{access=http{user=someusername,pwd=somepassword},mux=ts,dst=0.0.0.0:8080}' &


(the above should yield a 1:1 authenticated connection by doing a vlc http://linuxbox:8080 from any box on the network)

########### OUTPUT FEEDS #############
# h.264 CAM/re-encoded (less bandwidth)
/usr/bin/vlc -I dummy "http://someusername:somepassword@127.0.0.1:8080" --no-sout-audio --sout '#gather:transcode{vcodec=mp4v,vb=250,width=640,height=360}:duplicate{dst=std{access=http{user=someusername,pwd=somepassword,seglen=1,delsegs=true,numsegs=5"},mux=ts,dst="0.0.0.0:8081"}}' &


(same drill as above, but this lower bandwidth stream is sitting on 8081.. vlc http://linuxbox:8081.   Notice we're picking up the initial feed from the localhost, not the camera.)


OLD MJPEG STREAMS:

# FAST FEED - 30 FPS
/usr/bin/vlc -I dummy "http://172.16.0.15:8080/videostream.cgi?user=camuser&pwd=campassword" --no-sout-audio --sout '#standard{access=http{user=picksomething,pwd=picksomething},mux=asf,dst=0.0.0.0:8080}' &

# SLOW FEED - 5 FPS
/usr/bin/vlc -I dummy "http://172.16.0.15:8080/videostream.cgi?user=camuser&pwd=campassword&resolution=32&rate=11" --no-sout-audio --sout '#standard{access=http{user=picksomething,pwd=picksomething},mux=asf,dst=0.0.0.0:8081}' &
« Last Edit: December 11, 2014, 04:50:09 PM by beerhat »

 

Share |