Page 1 of 1

Script to Automatically Record

Posted: 20 Jan 2018 15:25
by shopper
Is there a way to force VLC to automatically record online streams?

Currently I have a .bat file that will open the stream in VLC and I can open that .bat file using windows task scheduler.
What I can't do is have VLC record the stream after it opens.

My goal is to have VLC open the file at a specific time every day, record the stream for 2 hours and then close.

Re: Script to Automatically Record

Posted: 22 Jan 2018 09:05
by robUx4
You should look at the --sout options, it allows you to output what is being read into a file. You can choose the bitrate, codec, select the input track, etc.

Re: Script to Automatically Record

Posted: 22 Jan 2018 15:08
by shopper
Ok. I have really no idea how to do most of this but I ran this line from the intf.rc console: http://*t/i/*/index_4296_av-p.m3u8?sd=10&rebase=on --sout="#std{access=file,mux=ts,C:\Users\*\Desktop\*.ts}
(some information redacted)

All that does is bring up a list of remote control commands.

Any ideas?

Re: Script to Automatically Record

Posted: 24 Jan 2018 11:31
by robUx4
it's at least missing " at the end.

Re: Script to Automatically Record

Posted: 24 Jan 2018 13:23
by shopper
Same result with the trailing "

Re: Script to Automatically Record

Posted: 24 Jan 2018 16:55
by mederi
vlc.exe -H
--run-time=<float> Run time
The stream will run this duration (in seconds).

vlc://quit
The streaming wizard (Media > Stream...) can help you to find out sout parameters.
dst=C:\Users\...

Re: Script to Automatically Record

Posted: 25 Jan 2018 00:10
by verbal_666
Are you on Windows?

[RECORD.BAT]
@echo off
::RECORD A STREAM FOR XX SECONDS ## VERBAL 2017
start "" "PATH_TO_VLC\vlc.exe" "http://YOUR_URL" --sout=#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100}:file{dst=MY_RECORD.mp4,no-overwrite} --sout-keep
timeout /t 7200 && taskkill /im vlc.exe

Schedule it with Windows Scheduler, and you did it.

You can also use "ffmpeg" directly, if you want.

Re: Script to Automatically Record

Posted: 25 Jan 2018 13:40
by mederi
Try this:
@echo off
::RECORD A STREAM FOR XX SECONDS ## VERBAL 2017
start "" "PATH_TO_VLC\vlc.exe" "http://YOUR_URL" vlc://quit --run-time=7200 --sout=#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100}:file{dst=MY_RECORD.mp4,no-overwrite} --sout-keep

Re: Script to Automatically Record

Posted: 25 Jan 2018 20:34
by shopper
Thanks for the replies folks.
When I use either of these methods VLC will open as if it was going to play the stream and it creates a 40kb .mp4 file but the stream doesn't actually start.

I have opened the stream URL directly from within VLC and verified that it works fine, just not when I run either of these commands from a .bat file.

Re: Script to Automatically Record

Posted: 25 Jan 2018 21:03
by verbal_666
You have to "encode" the URL.

Since Windows batch-interpreter uses special chars for internal use, in your .bat substitute special http characters.

Example, if the url contains
% substitute it with %%
& substitute it with ^&

So, if your original url is something like
http://www.domain.it/show.php?display=mychannel&video=h264&output=mpegts

it should become, inside .bat, in
http://www.domain.it/show.php?display=mychannel^&video=h264^&output=mpegts

Re: Script to Automatically Record

Posted: 31 Jan 2019 16:15
by madnesofjuice
You have to "encode" the URL.

Since Windows batch-interpreter uses special chars for internal use, in your .bat substitute special http characters.

Example, if the url contains
% substitute it with %%
& substitute it with ^&

So, if your original url is something like
http://www.domain.it/show.php?display=mychannel&video=h264&output=mpegts

it should become, inside .bat, in
http://www.domain.it/show.php?display=mychannel^&video=h264^&output=mpegts
Its not working. Same thing, I cant open the file

Code: Select all

@echo off ::RECORD A STREAM FOR XX SECONDS ## VERBAL 2017 start "" "C:\Program Files\VideoLAN\VLC\vlc.exe" "https://mylive.m3u8^&video=h264^&output=mpegts" --sout=#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100}:file{dst=MY_RECORD.mp4,no-overwrite} --sout-keep timeout /t 60 && taskkill /im vlc.exe
Can someone help me please?

Re: Script to Automatically Record

Posted: 09 Apr 2019 08:35
by AlexKa
Had to deal with this for several hours today, so thought I'd share the script that worked for me:

Code: Select all

@echo off start "" "C:\Program Files\VideoLAN\VLC\vlc.exe" "https://vdn.terrafox.com/live/downtown-silver.stream/playlist.m3u8" :sout=#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100,scode=none}:file{dst=C:\\Users\\Alex\\Videos\\silver.mp4,no-overwrite} :no-sout-all :sout-keep --stop-time=26400 vlc://quit
Only occurred to me after a long struggle why the stream would not start and why I was ending up with empty mp4 files. I was connecting to a file/stream that was already playing (it's a m3u8 file format, which is a pointer to an internet stream), but was trying to connect to it from the beginning (in the past), not having a --start-time value. You can only connect to it from the current time and the stop time (in seconds) should be in the future, counting from the beginning of the file. I discovered this after just deciding to play the stream in the player (instead of streaming) and seeing that the starting time was not 0:00:00.