Jump to content
simy8891

Video stream capture

Recommended Posts

simy8891

Hello everyone,

I've got a very cr.. err low cost IP camera and I'd like to capture its video stream with autoit and save it to a file.

I've found this IP Camera script which looks to work ok for other people, unfortunately it doesn't with mine:

'?do=embed' frameborder='0' data-embedContent>>

I've played with FireBug and finally got the right URL which brings me straight to the video stream (only when using the below HTML):

<img onload="load_video()" src="http://IP:PORT/videostream.cgi?rate=0&amp;user=USERNAME&amp;pwd=PASSWORD&amp;next_url=tempsnapshot.jpg&amp;count=7" alt="video" id="imgDisplay">

This works great as it refresh almost instantaneously (I managed to get it to work with VLC too, but it's way slower in refreshing - talking of 10, 15 seconds delays).

Is there a way to capture this video stream and save it to a video format file?

I could then go ahead and try to build something around it.

Cheers! 

Share this post


Link to post
Share on other sites
simy8891

Was wondering if anybody could come up with an idea at least? :)

Thanks

Share this post


Link to post
Share on other sites
SmOke_N

This is url based?  Is there a standard API that your cr... err low cost camera has?

If it's only retrieving snapshots, have you tried InetRead() or InetGet()?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
simy8891

Hi SmOke_N,

 

If it's only retrieving snapshots, have you tried InetRead() or InetGet()?

 

Thanks for your reply. No, I have not. Do you actually think it's a series of snapshots being updated? The video is very smooth but it might be.

As far as I know there's no API for it, this is the camera:

http://www.medisana.com/en/Health-control/Smart-Baby-Monitor/

How would you use inetRead/Get in the case it's a sequence of pictures? Shall I run an infinite loop and save them all in a tmp folder and once done implement an avi builder (which I've seen on the forum if I'm not mistaking).

Thanks a lot :)

Share this post


Link to post
Share on other sites
simy8891

Me again.

I've tried the below, which got the snapshots but it's way too slow so I'm missing most of the "action".

#include <InetConstants.au3>

$sFilePath = @ScriptDir & "\jpgs"
$sFileName = "testimage"
$sFileExt = ".jpg"

$count=0

While 1

    $tempFileName=$sFilePath&'\'&$sFileName&$count&$sFileExt
    $hDownload = InetGet("http://IP:PORT/snapshot.cgi?user=myuser&amp;pwd=mypwd", $tempFileName,$INET_FORCERELOAD)
    $count=$count+1

WEnd

Share this post


Link to post
Share on other sites
SmOke_N

Can you post the "load_video()" javascript (<script>data here</script>) function?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
simy8891

I'm afraid it's not going to be very helpful, this is what I see with FireBug:

<td valign="middle" bgcolor="#E0E0E0" align="center">
<script>
document.write(imgsrc);
</script>
<img src="videostream.cgi?rate=0">
</td>

There's also an option to see the camera with a lower resolution (Mobile view) and that one is given by the below:

<img id="imgDisplay" onload="load_video()" src="http://IP:Port/snapshot.cgi?user=myusername&pwd=mypassword&next_url=tempsnapshot.jpg&count=41" alt="video">

I've also tried this with no luck:

#include <InetConstants.au3>

$sFilePath = @ScriptDir & "\jpgs"
$sFileName = "testimage"
$sFileExt = ".jpg"

$count=0

While 1

    $tempFileName=$sFilePath&'\'&$sFileName&$count&$sFileExt
    $hDownload = InetGet('<img onload="load_video()" src="http://IP:PORT/snapshot.cgi?rate=0&amp;user=myusername&amp;pwd=mypassword&amp;next_url=tempsnapshot.jpg&amp;count=7" alt="video" id="imgDisplay">', $tempFileName,$INET_FORCERELOAD)
    $count=$count+1

WEnd

Thanks for your support

Share this post


Link to post
Share on other sites
SmOke_N

Just trying to narrow down the actual stream and not the snapshot jpgs.

Might play around with directly (through the browser) seeing if you can connect to the videostream.cgi?rate=0


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
FireFox

Hi,

InetGet needs a correct url, try this instead :

$hDownload = InetGet("http://IP:PORT/snapshot.cgi?rate=0&user=myusername&pwd=mypassword&next_url=tempsnapshot.jpg&count=7", $tempFileName, $INET_FORCERELOAD)

Don't forget to replace the IP/PORT etc.
 
I'm wondering what is the "count" parameter for.
 
Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Sven-Seyfert
      By Sven-Seyfert
      Hi Community,

      I use a UDF by @smashly to play a video in a GUI. That works fine for my main monitor.
      But when I change the X and Y positions of the GUI (also for the video) to my second or third monitor, the video plays, I can hear the sound of it, but I don't see the video.

      I debugged the UDF and checked the Microsoft description for MCI Command Strings which are used in the UDF (docs.microsoft...) - everything is fine, so I got no clue why the video isn't displayed.

      PlayVideoTest.au3:
       
      VideoInGui_by_Smashky.au3 (UDF):
       
      The example video:
       
      It would be great when anyone can help .
      Is there maybe a other way to play (display videos in GUI)?

      Thanks for any suggestion - I'm grateful!
      Sven
    • WoodGrain
      By WoodGrain
      Hi guys,
       
      I've written a script that will move my mouse to a location on the screen whenever my remote access software becomes active, the problem I have is that as soon as the remote access software becomes active it appears to capture the mouse and keyboard so nothing happens when I use MouseMove().
       
      Is there any way around this?
       
      Thanks!
    • UEZ
      By UEZ
      AutoIt Windows Screenshooter
      Key Features:
      takes easily a screenshot from any visible window capture any region of the desktop incl. freehand capturing capture GUI controls and GUI menus separately capture a marked area every x seconds for a duration of y seconds create a GIF animation from saved frames (Vista or higher os required) capture to AVI file (without audio!) takes a screenshot from web sites (available only on Win7+ os and when Aero is enabled) put images to clipboard to paste to other applications easily color picker save image in different formats and also to PDF! add timestamp to saved images simple image editing options: greyscale, b&w, invert, rotate +-90° send image to printer and default email client preview of captured screens incl. zoom option multi monitor support display pixel color under mouse ruler basic image editor (paint, highlight, ellipse, rectangle, text and some graphic FX) watermark captured image no 3rd party tools or DLLs used - pure AutoIt! fully portable - no installation is needed multi language feature (Eng, Ger, Tur, Fra and Rus only) To do:
      capture content of scrollable window/control capture cascaded menus Due to DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "handle", $hMemDC, "int", 0) limitation some windows cannot be captured properly (GDI+, ProgDVB, etc.) but can take screenshots of hidden windows. One workaround is to use full screen capturing (F11/F12) or "Grab Screen" function! Or try double click with rmb on listview items (beta).
      Download source code (7339 downloads previously): AutoIt Windows Screenshooter v1.82 Build 2018-12-13.7z (version 3.3.12.0+ needed!)
      You are not allowed to sell this code or just parts of it in a commercial project or modify it and distribute it with a different name!
      Download compiled Exe only: 4shared / Media Fire  / Softpedia (1.54mb)
      Distributing copies of the program in compiled format (exe) must be free of any fee!
      -----> click here to Donate!  
       
      (Current donators: 1. Cuong N.) 
      It is designed for Win7+ operating systems with AERO enabled! E.g. on WinXP machines some functions are not working properly and might crash the application!
      AV scanners may have a negative impact the execution of compiled exe and might report any malware. I guarantee that there is no malicious code in the source code / exe!!! 
      Main GUI:

       
       
      About Intro:

       
       
      Basic Image Editor:

       
       
      Watermark:

       
       
      Click link for an enhanced version of Watermark Image.
      Credits:
      main code by UEZ additional code (alphabetical order) by Authenticity, AutoItObject Team, Eemuli, Eukalyptus, funkey, _Kurt, martin, monoceres, ProgAndy, taietel, trancexx, Ward, wolf9228 and Yashied! mesale0077 for turkish translation wakillon for french translation AZJIO for russian translation Keys:
      Main GUI:
      User your mouse to scroll preview window or
      Numpad 8: Scroll preview window up
      Numpad 2: Scroll preview window down
      Numpad 4: Scroll preview window left
      Numpad 6: Scroll preview window right
      Numpad +: zoom in preview window or mouse wheel down
      Numpad -: zoom out preview window or mouse wheel up
      F1: capture again on last position
      F5: refresh Windows Name list
      PRINTSCREEN: take screenshot from whole screen
      ALT+PRINTSCR: take a screenshot from active window
      F10: Undo made changes with Image Editing function
      F11: take screenshot from whole screen incl mouse cursor
      F12: take screenshot from whole screen
      Ctrl+Alt+F9 start "Grab Screen" mode
      Ctrl+Alt+F12: take a screenshot from active window using alternative screenshot functionality (beta)!
      Ctrl+r: call ruler
      Ctrl+s: save current displayed image
      Ctrl+x: exit program
      ctrl+w: call web grab input field (available only when Aero is enabled)
      Ctrl+i: call image editor
      Ctrl+m: call watermark editor
      Ctrl+z: undo
      Only available on Vista+ os: double click with rmb on list items to use alternative screenshot functionality (beta)!
      When 'Grab Screen' is clicked you can hold down the ctrl key to switch to 'grab controls' mode. Control under mouse will be framed red.
      ctrl + shift will take the screenshot of appropriate control. To capture GUI menus you can press rmb which simulates the lmb. When a menu is opened press shift additionally to capture it.
      Press and hold only the shift key to capture any region on the desktop using freehand capturing - release it so capture marked regions!
      Or just mark resize able area which you want to grab. Press CTRL key to grab marked area or right mouse button to capture the marked area every x seconds for a duration of y seconds.
      When saving the image just enter the extension you wish to use (*.jpg;*.png;*.bmp;*.gif;*.tif;*.pdf). Big thanks to taietel for his PDF UDF!
      Image Editor:
      s: save
      c: copy
      n: send
      h: highlighter
      p: pen
      r: rectangle
      e: ellipse
      a: arrow
      o: color
      t: text
      g: text config
      Ctrl+z: undo
      Watermark editor:
      Ctrl+z: undo
       
      To start the app minimized just call it "Windows Screenshooter.exe /min"
      Maybe it is useful for someone...
      Any kind of comment is welcome.
      Br,
      UEZ
      Change log:
       
    • cramaboule
      By cramaboule
      Hi all,
       
      I was wondering if it is possible (and how) to put text on video on-the-fly (like VLC displays Title movie at the begining)
      and of course doing that in AutoIt
      Thanks in advance...
       
      C.
    • ManualIT
      By ManualIT
      Is there anyway that Autoit can detect a video that has been frozen on screen for a certain time?
       
      I have a program that records videos from my surveillance cameras, unfortunately after an update, sometimes the recording and live feed freezes on one of the cameras displayed on screen.
      The program has to be restarted, so I wrote a script that it restarts the program and then starts recording on each camera, but only if i physically notice that it has been frozen.
      So it would be great if all this can be done automatically.
       
       
×