Page 1 of 1

Quit VLC on loss of stream

Posted: 15 Jan 2021 07:34
by troykelly
Using VLC to transcode via a VLM and I can not work out how to get VLC to quit if it stops transcoding the stream.

VLC is being started with

Code: Select all

/usr/bin/vlc -I telnet --telnet-password=${PASSWORD} --telnet-port=${PORT} --drop-late-frames --skip-frames --play-and-exit --no-daemon --adaptive-logic=${VLC_ADAPTIVE_LOGIC} --adaptive-maxwidth=${VLC_ADAPTIVE_WIDTH} --adaptive-maxheight=${VLC_ADAPTIVE_HEIGHT} --adaptive-bw=${VLC_ADAPTIVE_BITRATE} --vlm-conf=/vlc/stream.vlm
Where the VLM is simply

Code: Select all

del all new stream broadcast enabled setup stream option network-caching=1000 setup stream input "http://example.com/stream/abcnews24" loop setup stream output #transcode{venc=x264{preset=ultrafast},vcodec=h264,threads=4,vb=1000}:duplicate{dst='rtp{access=udp,mux=ts,ttl=15,dst=234.0.1.1,port=1234,sdp=sap://,group="News",name="ABC News 24"}'} control stream play
If VLC stops streaming for some reason VLC logs this (but does not quit)

Code: Select all

2x3_1 | [00007f33b3b8e5b0] stream_out_transcode stream out: aspect-ratio changed, reiniting. 1 -> 0 : 1 -> 1. 2x3_1 | [00007f33b27bd500] x264 encoder error: Input picture width (720) is greater than stride (0)
And so I am stuck.

I've been told to build a whole tool using the telnet interface to interrogate VLC - but that doesn't help - because the stream shows as playing (it's not) and `is_playing` always returns `0` even when it _is_ working.

Code: Select all

workstation:~ troy$ telnet streaming.server.example.com 9999 Trying 10.0.0.1... Connected to streaming.server.example.com. Escape character is '^]'. VLC media player 3.0.11.1 Vetinari Password: Welcome, Master > show stream show stream type : broadcast enabled : yes loop : yes inputs 1 : http://example.com/stream/abcnews24 output : #transcode{venc=x264{preset=ultrafast},vcodec=h264,threads=4,vb=1000}:duplicate{dst='rtp{access=udp,mux=ts,ttl=15,dst=234.0.0.1,port=1234,sdp=sap://,group="News",name="ABC News 24"}'} options network-caching=1000 instances instance name : default state : playing position : 0.000000 time : 0 length : 0 rate : 1.000000 title : 0 chapter : 0 can-seek : 0 playlistindex : 1 >
Surely... there must be a way to know if VLC is actually outputting something... somehow?

Re: Quit VLC on loss of stream

Posted: 15 Jan 2021 16:49
by Rémi Denis-Courmont
The whole point of VLM was to handle multiple streams. Of course it won't quit because of any given single stream.

Just don't use VLM.

Re: Quit VLC on loss of stream

Posted: 17 Jan 2021 10:54
by troykelly
Thank you @Rémi Denis-Courmont

Changing to the below. How should I get VLC to quit when not using a VLM?

Code: Select all

/usr/bin/vlc -I telnet --no-repeat --no-loop "${VLC_SOURCE_URL}" --network-caching=${VLC_CACHE} --telnet-password="${PASSWORD}" --telnet-port=${PORT} --drop-late-frames --skip-frames --play-and-exit --no-daemon --adaptive-logic="${VLC_ADAPTIVE_LOGIC}" --adaptive-maxwidth=${VLC_ADAPTIVE_WIDTH} --adaptive-maxheight=${VLC_ADAPTIVE_HEIGHT} --adaptive-bw=${VLC_ADAPTIVE_BITRATE} --sout="${SOUT}" vlc://quit

Re: Quit VLC on loss of stream

Posted: 18 Jan 2021 22:10
by troykelly
Per Remi's suggestion - I've stopped using a VLM, but VLC does exactly the same thing.

Surely it's not impossible to get VLC to quit when it has given up streaming?

I still can't write an expect script either - because VLC still shows streaming via the telnet interface.

*Stream Dead*

Code: Select all

> is_playing 1 > show show media : ( 0 broadcast - 0 vod ) schedule > status ( new input: rtsp://user:password@rtsp.example.com/ ) ( audio volume: 256 ) ( state playing )
*Stream Alive*

Code: Select all

> is_playing 1 > show show media : ( 0 broadcast - 0 vod ) schedule > status ( new input: http://hls.example.com/stream/1234 ) ( audio volume: 256 ) ( state playing )

Re: Quit VLC on loss of stream

Posted: 19 Jan 2021 21:15
by EduardoP
urely it's not impossible to get VLC to quit when it has given up streaming. Thanks for your help

Re: Quit VLC on loss of stream

Posted: 20 Jan 2021 03:30
by troykelly
You have a solution @EduardoP ?

Re: Quit VLC on loss of stream

Posted: 20 Jan 2021 18:08
by Rémi Denis-Courmont
The simplest way is to add vlc://quit at the end of the playlist.

Re: Quit VLC on loss of stream

Posted: 20 Jan 2021 22:58
by troykelly
Per my example above @Remi - it is, and it doesn't quit.
Am I formatting it incorrectly?

Re: Quit VLC on loss of stream

Posted: 28 Jan 2021 21:36
by troykelly
So, there is no way to quit VLC when a stream ends?

Re: Quit VLC on loss of stream

Posted: 06 Feb 2021 00:53
by troykelly
Is there any way at all to get VLC to either automatically restart the stream/transcode or quit so it can be restarted as a service?
If there isn't - is there a way to test if VLC is transcoding, and if it isn't, kill it somehow?
I've tried VLM, Command like with vlc://quit at the end, telnet - I'm not sure what else to do?