Advertisement
Guest User

Earn money video$

a guest
Jan 22nd, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.17 KB | None | 0 0
  1. How-to open RTSP stream from cheap chinese video camera (or any other alike camera) in linux.
  2. .
  3. .
  4. Download link in here: #http://brokersdoor.com/Offerfree
  5. .
  6. .
  7. This story is for thouse who own cheap chinese video camera and DVR (Digital Video Registrator) and want to use it in Linux.
  8.  
  9. NOTE: Scroll down if you want to open RTSP encoded by QuickTime codec and written in dirty javascript in VLC.
  10.  
  11. The problem: cheap chinese camera DVR provides web interface for "Internet Explorer" the worst ever browser in the world. It works like this (I am not a specialist, but basically):
  12.  
  13. 1) Coaxial (cable) camera sends its stream to the DVR.
  14. 2) DVR's processor (most likely philips 500 mhz processor or so) is powered with Linux and take the stream, encodes it to H.264 stream.
  15. 3) Then, stream is enclosed in different containers (according to setup and type of DVR) and saved to the internal/external HDD and/or streamed over the internal/external network.
  16. 4) In my case, it was the worst ever proprietary container for web-streaming - QuickTime video.
  17. 5) Not only the contained is stupid (quicktime video is mostly just "Motion JPEG" so it's stuipd, slow and bad compression, because the technology was created to work with photos, not with video), but also the decoder is stupid - Internet Explorer uses ActiveX (old, buggy and proprietary technology) - a special web-browser plugin to decode the stream.
  18. 6) The system itself is written on Javascript and Java (web-interface of the DVR)
  19. 7) And again, all this encoding software works on DVR's built-in small linux (Linux is written in C).
  20.  
  21. So why the video is freezed sometimes and shown slow?
  22.  
  23. No, not because the bad processor. Of course, we could use powerful PC CPU and we would get no problems, but should we spend 200-400 wt of power to get the images? The problem sits in the system, written by china to work with most PCs, which are windows ones. So.
  24.  
  25. One good and powerful platform works hard to encode the data with different tricks just only to make it possible to display in world's worst operation system and worst web browser ever (windows and internet explorer, especially).
  26.  
  27. So. We anyway have the way to open the stream.
  28.  
  29. If you open firefox, or google chrome, or opera in Linux, anyway, it will not show the stream when you enter your DVR's web interface. But if you look closer at sources of the web interface that is open you can find interesting things:
  30.  
  31. There are included file "mt.js" in the beginning
  32.  
  33. If you look inside, you'll find:
  34.  
  35. ############################################
  36. mt.js listing
  37. ############################################
  38.  
  39. /*
  40. * author: duchangjiang
  41. */
  42.  
  43.  
  44. eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('4 3(h) { k n=$(8[h].l).c(); e(!7) { n.i(\'m\',6); n.i(\'d\',5); } 2 { n.i(\'m\',a); n.i(\'d\',9); } n.i(\'g-j\',\'0\'); n.i(\'g-f\',\'0\'); 1(b[h]);}',62,24,'0px|clearInterval|else|fake|function|g_H|g_W|g_bigView|g_channelStatu|g_playViewH|g_playViewW|g_setInterval|getLast|height|if|left|margin|nChannel|setStyle|top|var|vfID|width|wrap'.split('|'),0,{}))
  45. var OneView= new Array(6);
  46. OneView[0]="<div id='";
  47. OneView[1]="' style='border:0;width:100%;height:100%;position:absolute;'><object classid='CLSID:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' id='mo'"
  48. +"width='100%' height='100%' codebase='http://www.apple.com/qtactivex/qtplugin.cab'>"
  49. +"<param name='src' value='back.GIF'/><param name=\"allowFullScreen\" value=\"true\"/> <param name='qtsrc' value='rtsp://"+g_address+":"+g_port+"/user="+g_user+"&password="+g_passWord+"&channel=";
  50. OneView[2]="&stream=";
  51. OneView[3]=".sdp?real_stream--rtp-caching=100'/> <param name='autoplay' value='true'/>"
  52. +"<param name='autohref' value='True'/><param name='target' value='myself '/> <param name='href' value='javaScript:void(0)' />"
  53. +"<param name='loop' value='false'/><param name='wMode' value='transparent'/><param name='controller' value='false'/> <param name='scale' value='tofit'/>"
  54. +"<embed src='back.GIF' name='movie1' qtsrc='rtsp://"+g_address+":"+g_port+"/user="+g_user+"&password="+g_passWord+"&channel=";
  55. OneView[4]="&stream=";
  56. OneView[5]=".sdp?real_stream--rtp-caching=100' controller='false' width='100%' "
  57. +" height='100%' loop='false' scale='tofit' wmode='Transparent' autoplay='true' kioskmode='true'"
  58. +" enablejavasript='true' href='javaScript:void(0)' target='Myself' allowfullscreen=\"true\" bgcolor='black' plugin='quicktimeplugin' "
  59. +" type='video/quicktime' pluginspage='http://www.apple.com/quicktime/'> </embed></object></div>";
  60.  
  61. ############################################
  62.  
  63. So we can see here how JS tries to use ActiveX to say it to handle and decode QuickTime format, so we need both Active X and QuickTime plugins on windows to make it work there. The fun is that Windows has to use proprietary Apple code to open the camera, which is work on Linux.
  64.  
  65. Why they just didn't make a MPEG stream which will open on all platforms with built-in tools, decoders/codecs, players and browsers? Noone knows for real. Maybe this code is really old and they still use it because it mostly work, i don't know.
  66.  
  67. Okay, let's open the stream. We don't need any quicktime, activex or any microsoft shit to play this video. We have VLC and Mplayers which can held nearly any videostream format, so we just need to find, where camera puts its stream and how we can get it. Easy (if you didn't change the media stream port in DVR settings, if you didn't set up password, etc / otherwise, edit this line):
  68.  
  69. Open the following with your VLC (Open URL / Open Network Stream)
  70.  
  71. http://ip-of-your-dvr:554/user=admin&password=&channel=1&stream=
  72.  
  73. You should change ip-of-your-dvr, maybe port, user, password, and channel accordingly.
  74.  
  75. If you want, you also can use the variant from the "Chinese Specialists", they also provides additionally "&stream=.sdp?real-stream--rtp-caching=100", I am not sure if this is important, mine works without this params.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement