+12
Discuss & Vote

Using VLC transcode Video RTSP stream to MJPEG

Brent Thomas 7 years ago in Media Tiles / Video Camera Feeds updated by k0jdd 1 week ago 22

I posted this for another user but though I would create a topic on how I was able to access my Samsung SNH-v6410PN camera feed in action tiles using VLC.  There are a lot of variations when setting this up so this is not comprehensive to cover every camera type but hopefully it gets you most of the way there.s


To do this through VLC with my Samsung camera I took the following steps.  Before proceeding identify the url for you cameras RTSP stream - Great database to find this: 


1. Make sure you can access your cameras RTSP stream from a browser.   In the case of my samsung camera I accessed the RTSP stream with this path, rtsp://user:password@192.168.1.72/profile5/media.smp (Make sure to replace with the RTSP format for your camera (it will vary).   Note:  If camera is user/password protected you may not be able to pass the user:password in the URL when trying to access the feed.   This depends on the browser you are using.  Chrome and fully do not allow them to passed so simply enter the URL as shown below and then you should be prompted for the user name and password.  Firefox should work ok with the user:pass being passed within the URL as shown above.


2. Install VLC (im using version 2.2.8) and access VLC command line. To do this from windows open up Windows CMD prompt as administrator and navigate to you VLC directory path below.  Note:  Some VLC versions are buggy with trans-coding so thats why I reference the version of VLC I am using to do this successfully.

C:\>cd Program Files (x86)

C:\Program Files (x86)>cd VideoLAN

C:\Program Files (x86)\VideoLAN>cd VLC

C:\Program Files (x86)\VideoLAN\VLC>


3. Once there enter the command string shown below and REPLACE the part highlighted in bold with your cameras RTSP stream link.  Note: you only need to enter the user:password part of the string if you have assigned the camera a user name and password logon.  Also replace the IP address with your IP address.    After you press enter if you dont receive any errors go to step 4.


vlc.exe -R rtsp://user:password@192.168.1.72/profile5/media.smp --sout

"#transcode{vcodec=mjpg,vb=2500,scale=1.0,fps=10,acodec=none}:standard{access=http{mime=multipart/x-mixed-replace; boundary=7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8888/videostream.cgi}


4.  Change the IP address below to the IP of the PC running VLC that is doing the transcoding.  Try to access the stream from a web browser or action tiles (only will work on your local network).    If camera is user/password protected you may not be able to pass the user:password in the URL when trying to access the feed, this depends on the browser you are using.  Chrome and fully do not allow them to passed so simply enter the URL as shown below and then you should be prompted for the user name and password. http://192.168.1.119:8888/videostream.cgi


5.  If all is successful grab yourself a Beer and celebrate :)


Hope this helps

Discuss & Vote

Thanks for providing this solution, Brent! 


There's some indication that the Android App "IP Cam Viewer Pro" (or is it "Tiny Cam Viewer..."?) can do transcoding right in the background processing of a tablet and serve it through its built-in mini-webserver.


I've yet to experience this myself, but it's the same general concept as you recommend except it bypasses the requirement for a separate PC or rPi to run VNC... For just 1 or 2 cameras.


I hope to find out if this really works soon! I have to pick up a couple RTSP output cameras... 


... Terry.

+2

Interesting I’ll have to give it a try.  I’m using ip webcam on a cisco dx80 video endpoint running Android 4.0 and outputting as an mjpeg to AT which works well.  I have tried an external ip camera through ip webcam and it may chug on that device but worth a try.

I've been experimenting with the Tinycam webserver and it is very easy to set up and it works perfectly...everywhere except AT.  


I have the server running on a Nexus 9 tablet and I can access the feed from my desktop computer and from my phone, but if I use the same URL in AT, I get nothing.   


I'm stymied and will keep working on this.  If anyone has any ideas, I'm open!

  1. What format of URL are you using? 
  2. Which browser on the Nexus 9?
+2

This is very nice, thank you Brent ! Can this be done for multiple cameras at the same time ?

I went through these steps, as I am able to view on a browser at http://<IPaddress of computer>:8887/videostream.cgi I am using 8887 as I have multiple RTSP cameras so I changed the port.  However I am unable to view this within action tiles. 

Please test using a desktop browser so that you can press F12 to use the browser debugger pane - Console tab might show helpful specific errors about the camera connection attempts.

+1

Great solution. Make sure your hardware can support transcoding. On my media server that uses built in graphics it pegged the CPU to 100%. This caused the stream to get further behind the current time. When I run this on my gaming system it barely increases the CPU and uses my graphics card to perform the transcoding with little impact.

In my case any device with questionable wifi speed (kindle devices in my case) had issues with the live stream timing out and the picture freezing due to the network throughput. It may also be due to the 4 other live camera feeds I have up on my dashboard.

Got it working with one of my cameras, YAY!!  Can this be done with multiple cameras?

Yes.


You can run multiple instances of VLC, and give each one a unique https URL port number or channel number (or something like that ... I haven't done it personally, but I'm confident it isn't hard).

I seem to be having some issues with the VLC command syntax that you gave in this article. Please note: streaming the RTSP doesn't seem to be the problem. The problem is in the syntax of the conversion.

Does anyone have any suggestions?


The following is a screenshot of the command with the error:

Jack...

Maybe I'm not reading the screen print correctly, but ... aren't you missing double-quotation marks (") at the end of the vlc command line?

You are quite right!However, I added the " at the end of the line, and it still gave me the same error

Please provide your command line here in plain text to assist folks in helping you debug. (It will save them from reading the small print on your screenshot, right?). Thanks.

+1

I started to play with it, and I got it working....

There are 2 dashes before the "sout", and I had only 1 (a copy and paste error).


The following is the revised VLC command line:


vlc.exe -R rtsp://###.###.###.###:rtspPort --sout "#transcode{vcodec=mjpg,vb=2500,scale=1.0,fps=10,acodec=none}:standard{access=http{mime=multipart/x-mixed-replace; boundary=7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8888/videostream.cgi}"


Thanks for everything!

Just wanted to say THANKS!!! That's the ticket right there, man. This is awesome! :)

I tried all that and can't access the videostream.cgi. in step 4. I only see a pop-up asking if I want to save or open file. If I click open it just sits there in my downloads folder showing a progress bar with file size increasing. 

Step 3 only opened VLC player with no feed, albeit no error messages. The play progress

timer is stuck at 00:00 

Strange enough it started working tonight when I tried again. Thank you all for the tips

Can Somebody help figure out why I can see the video stream on the media tile, I followed the 4 steps above and was able to see the video on the web link using the http://192.xxx.x.xx:8888/videostream.cgi, however, when using the same link to generate the media tile I always get the message "Enter valid URL to preview video stream".  I can't figure out why.  




I am really struggling connecting to the new http.  rtsp works fine in VLC, but cannot access it via web.  any ideas?

I was just doing this now to support a Roku app that wasn't handling RTSP properly and the problem I didn't realize was the RTSP URL had an ampersand in it that was throwing off the command.  If you place the RTSP link in quotes it works:

start /min /b "" "C:\Program Files\VideoLan\VLC\vlc.exe" -R "rtsp://user:pass@XXX.XXX.XXX.XXX/live?channel=1&subtype=0" --sout "#transcode{vcodec=mjpg,vb=800,scale=1.0,fps=5,acodec=none}:standard{access=http{mime=multipart/x-mixed-replace; boundary=7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8881/video.mpg}"

I had this working in a similar fashion for several years.

Now it is broken because all the major browsers are BLOCKING mixed content - with no provision to turn that off...

Running HTTPS on the trans-coding hardware is not easy...


  • A self-signed certificate does not seem to help because there is no way to create an exception.
  • Spending the $$ to get a CA signed certificate seems a waste
  • I could try to use Let's Encrypt, but that is an adventure in itself and I believe you need a registered domain name


Does anyone have any other ideas besides replacing the cameras?