Skip to content

What's known about livestream on NX camera

Nikolas-LFDesigns edited this page Jul 10, 2015 · 5 revisions

What's known about livestream on NX camera

Samsung NX wifi cameras are capable of broadcasting live stream to the remote client. To access that stream there are 2 URLs:

http://192.168.107.1:7679/livestream.avi
http://192.168.107.1:7679/qvga_livestream.avi

of high and low quality. On subsequent sessions a port may vary, always pay attention to previous responses that are needed to execute before accessing stream.

Any usual streamer (no matter it's your off-the-shelf media player or any generic API) assume those things won't happen:

  • HTTP 206 error while accessing the stream
  • receiving incomplete RIFF header of the incoming video.

HTTP 206

The w3c states that HTTP 206 - partical content, means that there should be a range defined by the request, but that seems not the case with continuous video stream.
The problem of 206th error might be resolved by means of establishing proxy that passes

HTTP/1.1 200 OK

to the client instead of error. That at least was a case with VLC media player, but no other player still is that capable to stream contents. Which leads us to the second problem: incomplete header.

Incomplete header

Here's how original header of stream looks like:

RIFF ('AVI '
	  LIST ('hdrl'
			'avih' 56 0 0 0 272 0 0 1 0 640 480)
  	LIST ('strl'
			'strh' 56 'vids' 'H264 ' 0 0 0 0 1001 30000 0 0 1048576 10000 921600)
 	...

The stream is continuous, so it can't have a length (0 at position 11th counting from 'strh'). There might be a trick to redefine the header and pass only the part of the video, then passing new header and new chunk of video etc.
Redefining zeros in positions 2,3,6 of avih header (counting from 'avih') and 11th of strh (counting from 'strh') which are dwMicroSecPerFrame, dwMaxBytesPerSec, dwTotalFrames, dwLength subsequently according to a header description from Microsoft to some meaningful values would possibly define a range for video stream and make it viewable on stock media players and available for various API-s as well as preventing screen tearing that plagues VLC.

The solution: one lib fits them all?

As you probably know, there is a powerful codec pack named ffmpeg. It does know about both problems and effortlessly solves them.
There is a special debugging tool from ffmpeg package - ffplay that could livestream from the camera feed, execute it with the following command after camera gone to livestream:

ffplay -analyzeduration 5000 http://192.168.107.1:7679/livestream.avi

where "-analyzeduration 5000" effectively provides delay-free streaming. Also that comman may be implemented into ffmpeg calls by accessing AVFormatContext property:

     avFmtCtx->max_analyze_duration = 5000;

As a result, getting camera to stream something to the PC (for example) could be one ffmpeg implementation away.


Eskymak: I was able to access live stream on my NX1000 just by connection with ffplay using cloned MAC of before paired device and camera stayed in waiting for remote viewer app and stream was running. Unforunately, it did not jumped to remove viewer state and stream ended after while, as unsuccesful pairing. Once, but really just once, I was able to establish long stream with combination of Smart camera app (it probably sent remote viewer request) but then I was able to take over this stream to ffplay. I have bridged two wifi networks together, one is connected to camera, other is accessible for android phone with Smart camera app and debian pc in between.

For me personaly, would be helpfull to know, how to exactly sent those http/raw/socket or whatever request.


Answered by Nikolas-LFDesigns: Wiki is not a forum, it would be helpful if you re-shape your request as a contribution to the wiki after reading this. Especially we're curious about your man-in-the-middle approach in details (would be useful to use PC as wireshark proxy monitoring Smart Camera activity in realtime instead of analyzing logcat) As for your question, I've prepared a separate material: https://github.com/ge0rg/samsung-nx-hacks/wiki/Connecting-as-remote-viewfinder-to-NX-camera ,
hope it helps. Awaiting for new article from you ;) For furhter questions look here http://op-co.de/blog/posts/hacking_the_nx300/