Skip to content

Instantly share code, notes, and snippets.

@arthurzhukovski
Created July 17, 2018 14:49
Show Gist options
  • Star 35 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save arthurzhukovski/e4a02cca358ba9b4b36391f31e5bdf32 to your computer and use it in GitHub Desktop.
Save arthurzhukovski/e4a02cca358ba9b4b36391f31e5bdf32 to your computer and use it in GitHub Desktop.
RTSP to HTTP with VLC (Windows)
:: The following line is neccessary if you need an ability to restart the streams with this batch file
:: Kill all existing streams (the command actually suspends ALL the vlc processes):
taskkill /f /im "vlc.exe"
:: Run two instances of VLC. These would transcode MP4 rtsp-stream to Motion JPEG http-stream:
start vlc -vvv -Idummy rtsp://login:password@192.168.0.2/streaming/channels/2/preview --sout #transcode{vcodec=MJPG,venc=ffmpeg{strict=1},fps=10,width=640,height=360}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:9911/}
start vlc -vvv -Idummy rtsp://login:password@192.168.0.3/streaming/channels/2/preview --sout #transcode{vcodec=MJPG,venc=ffmpeg{strict=1},fps=10,width=640,height=360}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:9912/}
:: In order to execute VLC with `vlc` as in exapmle above, you have to add corresponding value to the PATH variable.
:: Otherwise you have to use full path e.g `"C:\Program Files\VLC\vlc.exe"`.
:: Such rtsp-stream uri as rtsp://login:password@127.0.0.1/streaming/channels/2/preview is specific for Hikvision cameras.
:: Access the http-streams like that:
:: For the first camera: http://127.0.0.1:9911
:: For the the second camera: http://127.0.0.1:9912
:: For external access change `127.0.0.1` to the address of the server (or PC) you are running VLC on.
:: Your server's Ports you are using for streaming (9911 and 9912 from current example) must be open for external access.
@arthurzhukovski
Copy link
Author

This example shows how to transcode an RTSP-stream to HTTP-stream (MJPEG) with VLC.
rtsp://mycameraip -> http://myserverip
It might be a suitable solution if there's a need to embedd an rtsp-stream from a cctv-camera to a web-page and this web-page will be used by a wide range of devices (LG WebOS TVs for example).

The following line
taskkill /f /im "vlc.exe"
is neccessary if you need an ability to restart the streams with this batch file

The part of uri /streaming/channels/2/preview is specific for Hikvision cameras.

Access the http-streams like that:
http://127.0.0.1:9911
For external access change 127.0.0.1 to the address of the server (or PC) you are running VLC on. Your server's ports you are using for streaming (9911 from current example) must be open for external access.

@Emalton
Copy link

Emalton commented Apr 20, 2020

Thank you! It still works great!

@arthurzhukovski
Copy link
Author

For external access change 127.0.0.1 to the address of the server (or PC) you are running VLC on. Your server's ports you are using for streaming (9911 from current example) must be open for external access.

I opened inbound port 9911 in windows firewall but not able to access the stream on another device.

Probably something is misconfigured in some other part of you infrastructure. Host any static resource on this machine & port and check whether or not you're able to access it

@Fomi-2020
Copy link

Hi @JonesTwink,

How can i use VLC commandline to steam a RTSP to HTTP in Ubuntu linux OS?

@NickWtrs
Copy link

NickWtrs commented Dec 18, 2020

Hi,
Many thanks! RSTP TO HTTP stream works great! but,
Is it possible to add username and pw to the http stream? like http://username:password@hostname:port/
At vlc help page:
--sout-http-user= Username
User name that will be requested to access the stream.
--sout-http-pwd= Password
Password that will be requested to access the stream.
But i can't figure out how to add those lines,
thanks!

@Emalton
Copy link

Emalton commented Jan 21, 2021

@JonesTwink I'm having problems with the feeds progressively getting slower and I believe the result is VLC not skipping frames if it gets behind. Do you know how to adjust this behavior? I'd appreciate any insight that you can provide!

@dysordamha
Copy link

how about uses video src=localhot:9912? in html

@TheExpertNoob
Copy link

Works like a charm!
http://gandalfsax.com:9911/

@askb
Copy link

askb commented Dec 23, 2021

I get a grey screen running on vlc on Fedora 33, on the browser, using hikvision. Is this a known issue?

@RonaldCoutinho
Copy link

Hi, guys!

I wanted to use the same command to generate snapshots in octoprint. but the URL is not working for snapshot, does anyone have any ideas?

as a streamer the procedure works very well, but as a snapshot I'm not having success.

Screenshot_1

@JonesTwink

@Esbirraco
Copy link

Works Perfect. Can you use https protocol too? Or only http? Thanks.

@NickWtrs
Copy link

Is there any way i can use rtsps stream to convert it in http streams?

@aitoncumbi
Copy link

Do i have to use a specific web player because I can't get it to play with the video tag

@arthurzhukovski
Copy link
Author

Do i have to use a specific web player because I can't get it to play with the video tag

You have to use img tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment