S
S
sm1tt2018-09-24 16:50:22
linux
sm1tt, 2018-09-24 16:50:22

How to force VLC not to create a file if there is no broadcast?

Hello! Please help with a small problem, I record using the vlc broadcast with the following script:

#!/bin/bash
while true
do
file_time=`date +%H.%M.%S`
cvlc http://localhost:8080 --network-caching=10 --sout file/ts:./$file_time.ts --run-time 300 --play-and-exit
done
exit 0

I divide the entire stream by 5 minutes, and in case of a break, the recording starts again. But if there is no broadcast, then a bunch of zero-size files start to be created every second. How to win it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sm1tt, 2018-09-24
@sm1tt

In general, I did this, files of zero size are simply deleted, and if the script detects such files, then it sets a random time delay, after which it restarts the cycle again in an attempt to record the broadcast

#!/bin/bash
while true
do
file_time=`date +%H.%M.%S`
cvlc http://localhost:8080 --network-caching=10 --sout file/ts:./$file_time.ts --run-time 300 --play-and-exit
null=`stat -c %s *.ts | grep -w 0 | head -1`
rand=`shuf -i 5-15 -n 1`
if [ $null -eq 0 ]
then
sleep $rand
fi
find . -size 0 -delete
done
exit 0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question