[FFmpeg-user] How to check if a youtube URL is valid before starting download?
Bo Berglund
bo.berglund at gmail.com
Fri Jul 9 14:00:39 EEST 2021
On Fri, 9 Jul 2021 10:10:11 +0100, Christian Ebert <bcc at phloxic.productions>
wrote:
>But for writing the log into a file look into ffmpeg's -report option, that's
>what it's for.
Thanks!
I changed the command like this:
FFREPORT=file=ffreport.log:level=32 ffmpeg -hide_banner -i input.mp4 -vf
"freezedetect=n=0.01:d=5" -map 0:v:0 -f null - ; grep
"lavfi.freezedetect.freeze_start: " ffreport.log
Now if I call with bluearrow as input file then grep finds the string and exits
with $? = 0
But when there is no freeze then grep does not find the string and exits with $?
= 1. So this now seems to work even if it is a bit complex.
Another issue:
I noted that ffmpeg reads the entire disk file to find the freeze, that is not
what I want...
It should only read a short part of the video, say 5 seconds, before finishing,
because I want to detect if there is a freeze right now.
But this could be fixed by using the -t argument:
FFREPORT=file=ffreport.log:level=32 ffmpeg -hide_banner -t 15 -i bluearrow.mp4
-vf "freezedetect=n=0.01:d=5" -map 0:v:0 -f null - ; grep
"lavfi.freezedetect.freeze_start: " ffreport.log
Note that the -t parameter must be longer than the freezedetect duration,
otherwise it will not detect the freeze.
Final problem is how to run ffmpeg with an input that is a live stream currently
playing on Youtube?
I need to detect (in a script) if the stream has frozen before I start the
download, so my plan is to run the detection and then start the download only if
it reports that the stream is not frozen.
--
Bo Berglund
Developer in Sweden
More information about the ffmpeg-user
mailing list