Page 1 of 1

Stream Loop overwrites output file

Posted: 25 Apr 2011 21:35
by ivanxx
Hi guys,

I've set up a small surveilance recorder using vlm and vlc running in telnet mode so I can rotate the output files from a cron file using a expect script. I rotate the output stream files once a day, and start over every new week.

It works great, but I just discovered that in case power fails in my camera, the file being recorded gets overwritten when the camera is back online and the stream resumes.

Is there any way to force the file to be appended to the existing output instead of overwritten?

Thanks for being there!

Ivan.

Re: Stream Loop overwrites output file

Posted: 09 Jun 2011 22:39
by yasdnil1
Ooh, could you explain what you did to set this up? I don't get the 'rotate the output files from a cron file using an expect script', what's that mean? How'd you do that?

Re: Stream Loop overwrites output file

Posted: 15 Jun 2011 17:50
by ivanxx
sure!, I just configured a vlc running in telnet mode. This means you can actually telnet to your host on the port you specified on the vlc start command and send control commands to the vlc.
On the other hand you have expect, a scriptable telnet interface that allows you to telnet to a host, wait for prompts and send responses. In this case, my expect script contains the necessary commands to stop the running vlc stream, change the name for the output file based on the weekday, and restart the streaming recording. I run this expect script everyday at 0:00 from the crontab, so I have a new file everyday that overwrites last week's.

Here's my actual expect script:

#!/usr/bin/expect -f
set systemTime [clock seconds]
set dia [clock format $systemTime -format %A]
set timeout -1
spawn telnet localhost 4212
match_max 100000
expect -exact "Trying 127.0.0.1...\r
Connected to localhost.\r
Escape character is '^\]'.\r
VLC media player 1.1.9 The Luggage\r
Password: "
send -- "mypassword\r"
expect -exact "\r
Welcome, Master\r
> "
send -- "control cam1 stop"
expect -exact "control cam1 stop"
send -- "\r"
expect "> "
send -- "setup cam1 output #std{access=file,mux=ts,dst=/path_to_storage/$dia.mp4}"
expect -exact "setup cam1 output #std{access=file,mux=ts,dst=/path_to_storage/$dia.mp4}"
send -- "\r"
expect -exact "\r
setup\r
> "
send -- "control cam1 play"
expect -exact "control cam1 play"
send -- "\r"
expect -exact "\r
control\r
> "
send -- "quit\r"
expect eof

You need to have vlc running and listening on the telnet port before you run this, and the cam1 stream configured against your camera, but I assume you can find the information required for this in the vlc docs.

happy expectin'!

Ivan.

Re: Stream Loop overwrites output file

Posted: 21 Jun 2011 15:56
by yasdnil1
Hmmm, still confusing :( I so don't get VLM stuff. Think I need a more bare bones explanation. Haha. If only you could youtube it or sumthin. Thx for the info, though.
I dunno if this helps or anything, but I found this --sout-file-append command and other append commands in this doc. Dunno if that's what you need, but here's the web addy:
http://wiki.videolan.org/VLC_command-line_help