VLC plays stream, won't record

About encoding, codec settings, muxers and filter usage
BZLederman
Blank Cone
Blank Cone
Posts: 39
Joined: 04 May 2017 14:16

VLC plays stream, won't record

Postby BZLederman » 25 Nov 2023 20:55

I'm begging for help here, I'm getting severe anxiety because I'm copying command lines from the documentation and can't get them to work.

My goal is to record a stream at a given time. There are examples of this, which I have tried to follow, but none of the steps work for me. I'm probably making a simple mistake, but can't figure it out, and a search of the previous topics here isn't helping.

The simplest command would seem to be this:

vlc -vvv https://i.mjh.nz/SamsungTVPlus/GBBC2700001CK.m3u8 --sout=file/ps:UKMB.mpg

This command would seem to be the way to do this. It starts up an instance of VLC, which opens and plays the stream. But no matter what I do, the --sout part doesn't work: it does not record any sort of file, and does not appear to even try. The input is AVI so a PS or TS file (I've tried both) should work. I've also tried:

vlc -vvv https://i.mjh.nz/PlutoTV/5f15e32b297f96 ... 8-alt.m3u8 --sout="#std{access=file,mux=ps,dst=I:\\Downloads\\Pluto.mpg}"

with no results. I don't see any error messages that mean anything in the Message window, and there are no errors reported on the command line.

I can play the stream just fine in VLC, and if I press the "Record" button the stream does record properly in the directory I have set in Preferences.

I also found this article on the web which would seem to give directions for exactly what I want to do:

https://superuser.com/questions/287222/ ... g-a-stream

Superuser is usually reliable. I have (I think) followed the example given there, and got this as the generated stream:

:sout=#transcode{vcodec=h264,scale=2,acodec=mp4a,ab=128,channels=2,samplerate=44100,scodec=none}:file{dst=i:\\downloads\\stream.mp4,no-overwrite} :no-sout-all :sout-keep

I tried that, but got no results either.

I have also stumbled on the extra options available for streaming and found the start and end time options, but I'm not getting anywhere with those either. I set a time in the future, I saw VLC pop up at the specified start time, it created a 4 second file with no content, and just sat there.

There "should" be some sort of beginner level explanation of how to do this somewhere, but I can't find it anywhere in this forum or anywhere else, and I'm usually pretty good with web searches. Could someone please give an example here that is actually tested and known to work? Or could someone please point me to the exact location where simple instructions that have actually been tested and are known to work are available? Or can someone at least explain why none of my commands will write an output file?

Lotesdelere
Cone Master
Cone Master
Posts: 10002
Joined: 08 Sep 2006 04:39
Location: Europe

Re: VLC plays stream, won't record

Postby Lotesdelere » 27 Nov 2023 11:45

vlc -vvv https://i.mjh.nz/SamsungTVPlus/GBBC2700001CK.m3u8 --sout=file/ps:UKMB.mpg
vlc -vvv https://i.mjh.nz/PlutoTV/5f15e32b297f96 ... 8-alt.m3u8 --sout="#std{access=file,mux=ps,dst=I:\\Downloads\\Pluto.mpg}"

These streams are using H.264 video + AAC audio so you can't directly mux them into MPEG PS, mux them into MP4 instead.

BZLederman
Blank Cone
Blank Cone
Posts: 39
Joined: 04 May 2017 14:16

Re: VLC plays stream, won't record

Postby BZLederman » 27 Nov 2023 12:16

Thanks for your reply.

I have been doing more tests. For the moment, I'm concentrating on getting one timer to work by setting it up within VLC's GUI as described in the superuser article.

I have been able to get it to work partially: but the only combination is to record in MPEG-2 video, MPEGA audio, and a TS file with a TS file name extension. All attempts to record to an MP4 file, and all attempts to record the raw stream have failed silently. I would prefer the raw stream, but I can live with this.

However, there is another problem. Specifying a start and end time using the GUI is only partially successful: the start time is ignored. This problem was apparently reported over 10 years ago, and hasn't been fixed.

https://forum.videolan.org/viewtopic.php?t=104979

In a couple of tests, the end time was honored: but in at least one test it was not. It looks like you can't have a recording go across midnight and stop the next day.

I will try your suggestions from the command line again, first transcoding with MPEG and then trying to save the raw stream. A sample complete command line that is tested and known to work would be very great help to me, and I'm sure it would help many others as well if you are willing to supply one.

BZLederman
Blank Cone
Blank Cone
Posts: 39
Joined: 04 May 2017 14:16

Re: VLC plays stream, won't record

Postby BZLederman » 27 Nov 2023 12:44

I have another question.

When I create a stream using the GUI, it says i can copy the commands and use them in the command line.

In my latest test, I did a copy and paste to a file, and got this (in this test I did not specify a start or end time):

:sout=#transcode{vcodec=mp2v,vb=1500,scale=Auto,acodec=mpga,
ab=128,channels=2,samplerate=44100,scodec=none}:file{dst=I:\\Downloads\\vlc-recording.ts,no-overwrite} :sout-all :sout-keep

I put this into a batch file, and it didn't work.

However, it occurred to me that commands start with "--", not ":", at least on Windows. So I tried this in a batch file:

@echo on

vlc -vvv https://i.mjh.nz/SamsungTVPlus/GBBC2700001CK.m3u8 --sout=#transcode{vcodec=mp2v,vb=1500,scale=Auto,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:file{dst=I:\\Downloads\\vlc-recording.ts,no-overwrite} --sout-all --sout-keep

This appears to have worked. I got a TS file with transcoded video and audio.

DId I miss something in VLC that said you have to change ":" to "--" ? I don't remember seeing this documented anywhere.

If this can be changed to copy the raw stream it would be nice, but I can live with this.

The next step is to try adding something like :start-time=28800.000 :stop-time=32400.000 (with the appropriate changes).

BZLederman
Blank Cone
Blank Cone
Posts: 39
Joined: 04 May 2017 14:16

Re: VLC plays stream, won't record

Postby BZLederman » 27 Nov 2023 17:07

I've done more tests, but every time I think I'm making progress something else fails.

I've done several tests with this:

vlc -vvv https://stream.m3u8 -I dummy ^
--network-caching=1000 --start-time=41400.000 --stop-time=44000.000 --run-time 4400 ^
--sout=#transcode{vcodec=mp2v,vb=5500,scale=Auto,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:file{dst=E:\\Capture\\vlc-recording-commandline.ts,no-overwrite} ^
--sout-all --sout-keep

This is done from a Windows Batch file.

The first test actually started on time, recorded a stream, and stopped recording. However, vlc itself did not stop, leaving the video locked, and it had to be 'killed'. This is not terrible, but it should be fixed.

I did several more tests, adding a quit command; something I found when doing web searches for VLC not stopping.

vlc -vvv https://i.mjh.nz/PlutoTV/634dacf51d9032 ... a-alt.m3u8 -I dummy ^
--network-caching=1000 --start-time=41400.000 --stop-time=44000.000 --run-time 4400 ^
--sout=#transcode{vcodec=mp2v,vb=5500,scale=Auto,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:file{dst=E:\\Capture\\vlc-recording-commandline.ts,no-overwrite} ^
--sout-all --sout-keep vlc://quit

But when I ran tests, --start-time was not being honored: the recordings started right after the batch procedure started.

I've done several tests with and without --run-time, and with and without vlc://quit, and I can't seem to get back to the point where recording will start when it's supposed to. I'm using a calculator to set the start time as the number of seconds since midnight, and double checking the results, and I can't seem to reproduce the command line that worked.

Needless to say, this is exceptionally aggregating. I may have to stop testing for several hours (or days) before continuing my tests. As I said, I'm doing this from a batch procedure so it should not be the result of typographical errors.

I have also encountered another problem: many streams have more than one video track, in different resolutions. VLC has a preference that says "select the best resolution". Is there an equivalent of this for the command line interface? In my tests, it appears that the first track is always selected, and it's usually the worst resolution. Or is there a way to select the track by number or resolution?

On a related note: is there a place to download a complete manual for VLC? searching through web page after web page for answers just isn't practical, and many essential qualifiers (like -vvv) aren't included in vlc --help . I'm also finding that web searches often turn up articles here in this forum and elsewhere where other users have asked the same questions: but very, very, very few of them have actual tested answers that work.

Thanks for all of your time and patience. If I ever find a way to make this work correctly I will make sure to post it for the benefit of future generations.

BZLederman
Blank Cone
Blank Cone
Posts: 39
Joined: 04 May 2017 14:16

Re: VLC plays stream, won't record

Postby BZLederman » 27 Nov 2023 17:28

Maybe I need to ask a different question: am I asking for the right thing?
I'm assuming that VLC uses start time for the time of day. I have now realized
that this probably isn't correct.

If I'm reading a stream, does --start-time start at the point where VLC started reading the stream and wait that number of seconds? My tests indicate that the answer is no.

In some of my prevous tests I set --start-time to be the time of day, and it seemed to work. Now I'm thinking it's measuring the amount of time from when the stream itself says it started, which could be hours or days in the past.

Using the GUI to set recording a stream gives values in Hours, Minutes, Seconds, which are converted to just seconds, but it doesn't actually say what the reference point is. I've done tests asking for a delay from "now" but I can't tell if that is what is being measured.

I'm going to do more tests, but I'm beginning to think I should use some other mechanism to start VLC when I want the recording to start, and only specify a run time for when it should stop. But if anyone knows the answer please post it here.

Thanks.

BZLederman
Blank Cone
Blank Cone
Posts: 39
Joined: 04 May 2017 14:16

Re: VLC plays stream, won't record

Postby BZLederman » 27 Nov 2023 19:33

Things are both better and worse.

I have changed my batch procedure to this:


set datetimef=%date:~-4%_%date:~3,2%_%date:~0,2%-%time:~0,2%_%time:~3,2%_%time:~6,2%

set datetimeG=VLC_Record_%datetimef: =0%

TIMEOUT /T 10 /NOBREAK

vlc -vvv https://nhkwlive-ojp.akamaized.net/hls/ ... index.m3u8 -I dummy ^
--network-caching=1000 --run-time 300 ^
--sout=#transcode{vcodec=mp2v,vb=5500,scale=Auto,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:file{dst=E:\\Capture\\%datetimeG%.ts,no-overwrite} ^
--sout-all --sout-keep vlc//quit

PAUSE

The first few lines are just to give me a more useful file name.

The first test worked. It ran for 10 minutes and then quit.

Since then, all of the tests get to within 10 seconds of --run-time and then stall.

Every single one.

No matter how long I wait, the capture procedure never finishes properly. I've
tried shortening the run time, I've tried at least four different streams from
completely different sources, and I can't reproduce the first test that quit
properly. I have also tried vlc:quit instead of vlc//quit with no difference.

I will probably have to stop for a while and maybe try tomorrow if I'm not overly
traumatized.

BZLederman
Blank Cone
Blank Cone
Posts: 39
Joined: 04 May 2017 14:16

Re: VLC plays stream, won't record

Postby BZLederman » 27 Nov 2023 21:06

I think I finally got it.

vlc -vvv https://nhkwlive-ojp.akamaized.net/hls/ ... index.m3u8 -I dummy ^
--sout=#standard{access=file,mux=ts,dst=E:\\Capture\\%datetimeG%.ts} ^
--run-time 1200 --stop-time=1200 vlc://quit

This copied one AVC video stream, three ACC audio streams, and two closed caption streams into one TS file with no transcoding needed, and it stopped when it was supposed to leaving a complete file. (Yes, you can put AVC and ACC into a TS muxed file.)

I've run five additional tests using streams from completely different sources and different durations, and they all worked. Most stopped a few seconds before the specified time, but it's easy to compensate for that.

The only thing I've tried so far is that this command procedure won't capture a Youtube live stream, but that isn't a high priorty for me.

It might still be necessary to find a way to select the desired video track from some streams, but so far I'm finally getting what I want.


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 31 guests