Saturday, June 11, 2011

Convert nphmotionjpeg to video or images

Hi all. I've found a work-around to convert streaming video in nphMotionJpeg format into mp4/jpg. I'm sure that this is what some of you might be interested. So, I'm posting this.

Apparently, ffmpeg doesn't seem to do this. Instead,  I made this process work with VLC player and Avidemux only.

There might be some other better way to do it, I'm not sure. But, I found no help on the web regarding the same, so I've written this blog post.

They are explained as follows:

  1. Make sure that open a streaming video on the internet. (Obviously :p)
  2. Right click on the video and click as "Save As"/ "Save Image as". This might take some time for the browser to understand whats going on, as what we are saving is not a image, its a continuous stream instead. If browser doesn't respond after a minute or two retry this step.
  3. Leave the default name/format. It is likely to be "nphMotionJpeg"
  4. Save the file in certain location which is accessible. 
  5. Save the video as long as you want (I've saved as long as the file size becomes 8 GB). More than 8 GB didn't seem to work if i did so.
  6. Now as its a continuous stream and not a file of certain size, its size goes on increasing. If you cancel the download, then the entire file gets deleted. Make another copy of this "downloading" file. You may want to do this number of times possible if you want the latest data.
  7. Now after you made a copy of the currently "downloading" file, cancel the download and the file gets deleted (except for the copies).
  8. Now rename the file as "foo.avi" (apparently, if I name it as ".avi" extension only then this method works).
  9. Open the file in vlc player (windows/linux). Now you have the entire video here.
  10. Pause the video and Click on File->Convert/Stream
  11. "Add" the file that you want to convert.
  12. Select convert, then it asks for which format it needs to be converted.
  13. Select H.264 .mp4 format.
  14. Click on convert and it converts it to the specified format.
  15. Now as the nphMotionJpeg stream is in a readble format, open it in Avidemux (you can use ffmpeg here, but may loose some frames if you don't give the right parameters while converting).
  16. Open the file in Avidemux and it will give a warning ask you to open the file in SAFE MODE. DO NOT open it in SAFE MODE, as you might loose frames. Click on  NO/Cancel and then select OK for indexing.
  17. Go to File->Save->Selection as series of Jpegs.
  18. Give the filename in a particular folder and it will give you a series of jpeg images from the video stream recorded.


  1. Friend, you can glab the stream directly using VLC, all you need to do is open File/Media->"network stream", and fill in the url (the url *must* start with http://).
    To save to disk, open File/Media->Convert/Save and select "network", then add the url (starting with http://) and it will do the work.

  2. Hey Gero. I can't seem to remember what my problem was. I am sure VLC didn't work. As I mentioned in the post, there was a better way to do it. :)