{"id":48,"date":"2009-07-12T19:51:25","date_gmt":"2009-07-12T17:51:25","guid":{"rendered":"http:\/\/log.or.cz\/?p=48"},"modified":"2009-07-12T19:55:08","modified_gmt":"2009-07-12T17:55:08","slug":"vlc-mpjpeg-streaming","status":"publish","type":"post","link":"https:\/\/log.or.cz\/?p=48","title":{"rendered":"VLC mpjpeg streaming"},"content":{"rendered":"<p>Last weekend, we were streaming four webcams from internal LAN behind firewall to the internet; the webcams were giving the stream as multipart jpeg and we wanted the stream at the internet to be multipart jpeg as well &#8211; it is not very effective, but the webcams aren&#8217;t high FPS and you can easily watch the stream in any browser.<\/p>\n<p>You need a Linux system A in the LAN network, and publicly accessible Linux server B on a thick line at the internet (Windows should work too, but I didn&#8217;t test it). You need VLC 0.9.x (important! 0.8.x has mpjpeg streaming broken) installed on both.<\/p>\n<p>On the A system, for each camera run:<\/p>\n<pre>\r\nwhile true; do \\\r\n  vlc -I dummy -vvv \\\r\n  'http:\/\/10.92.8.74\/axis-cgi\/mjpg\/video.cgi?camera=1&resolution=352x288' \\\r\n  --sout '#es{access-video=udp,mux-video=ts,dst-video=62.24.64.27:9991}'; \\\r\n  sleep 1; done\r\n<\/pre>\n<p>(adjust URL for camera stream, IP address for B Linux server; hostnames mysteriously don&#8217;t work sometime!).<\/p>\n<p>On server B, for each camera run:<\/p>\n<pre>\r\nwhile true; do \\\r\n  vlc -vvv udp:\/\/@62.24.64.27:9991 --sout \\\r\n  '#standard{access=http{mime=multipart\/x-mixed-replace; boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=62.24.64.27:8881}' \\\r\n  sleep 1; done\r\n<\/pre>\n<p>Then, connect with your browser to http:\/\/62.24.64.27:8881\/. If the stream gets stuck, hit reload. For multiple cameras, just use port numbers 9992 and 8882 etc.<\/p>\n<p>It&#8217;s a shame that you have to manually specify this magic to have browsers understand VLC-generated mpjpeg stream&#8230; I hope someone fixes this in future releases; in theory looking at the code it should work, but somehow something overrides the MIME type to application\/octet-stream.<\/p>\n<p>No re-encoding is done, you get the original quality as with the original stream. Unfortunately, the scheme doesn&#8217;t deal well with too thin uplink, if you fill your bandwidth from A to B, you don&#8217;t get dropped frames but completely corrupted stream. :-(<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last weekend, we were streaming four webcams from internal LAN behind firewall to the internet; the webcams were giving the stream as multipart jpeg and we wanted the stream at the internet to be multipart jpeg as well &#8211; it is not very effective, but the webcams aren&#8217;t high FPS and you can easily watch [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6],"tags":[29,30,28],"class_list":["post-48","post","type-post","status-publish","format-standard","hentry","category-linux","category-software","tag-mpjpeg","tag-streaming","tag-vlc"],"_links":{"self":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts\/48","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=48"}],"version-history":[{"count":4,"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts\/48\/revisions"}],"predecessor-version":[{"id":52,"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts\/48\/revisions\/52"}],"wp:attachment":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}