Script to Automatically Record

Microsoft Windows specific usage questions
Forum rules
Please post only Windows specific questions in this forum category. If you don't know where to post, please read the different forums' rules. Thanks.
shopper
New Cone
New Cone
Posts: 4
Joined: 20 Jan 2018 14:45

Script to Automatically Record

Postby shopper » 20 Jan 2018 15:25

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.

robUx4
Developer
Developer
Posts: 255
Joined: 31 Jan 2005 13:50
VLC version: master
Operating System: Windows
Contact:

Re: Script to Automatically Record

Postby robUx4 » 22 Jan 2018 09:05

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.

shopper
New Cone
New Cone
Posts: 4
Joined: 20 Jan 2018 14:45

Re: Script to Automatically Record

Postby shopper » 22 Jan 2018 15:08

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?

robUx4
Developer
Developer
Posts: 255
Joined: 31 Jan 2005 13:50
VLC version: master
Operating System: Windows
Contact:

Re: Script to Automatically Record

Postby robUx4 » 24 Jan 2018 11:31

it's at least missing " at the end.

shopper
New Cone
New Cone
Posts: 4
Joined: 20 Jan 2018 14:45

Re: Script to Automatically Record

Postby shopper » 24 Jan 2018 13:23

Same result with the trailing "

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Script to Automatically Record

Postby mederi » 24 Jan 2018 16:55

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\...

verbal_666
Cone that earned his stripes
Cone that earned his stripes
Posts: 129
Joined: 02 Nov 2010 20:46

Re: Script to Automatically Record

Postby verbal_666 » 25 Jan 2018 00:10

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.

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Script to Automatically Record

Postby mederi » 25 Jan 2018 13:40

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

shopper
New Cone
New Cone
Posts: 4
Joined: 20 Jan 2018 14:45

Re: Script to Automatically Record

Postby shopper » 25 Jan 2018 20:34

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.

verbal_666
Cone that earned his stripes
Cone that earned his stripes
Posts: 129
Joined: 02 Nov 2010 20:46

Re: Script to Automatically Record

Postby verbal_666 » 25 Jan 2018 21:03

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

madnesofjuice
New Cone
New Cone
Posts: 4
Joined: 03 Sep 2018 16:32

Re: Script to Automatically Record

Postby madnesofjuice » 31 Jan 2019 16:15

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?

AlexKa
New Cone
New Cone
Posts: 1
Joined: 09 Apr 2019 08:25

Re: Script to Automatically Record

Postby AlexKa » 09 Apr 2019 08:35

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.


Return to “VLC media player for Windows Troubleshooting”

Who is online

Users browsing this forum: No registered users and 56 guests