Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On Tue, 06 Jul 2021 09:00:47 +0200, Bo Berglund wrote: >Can this be done using youtube-dl or straight ffmpeg? Self-answer: It seems like this will do what I need: eval "youtube-dl -F $VIDEOURL" if [ $? -eq 0 ] then exit 0 else exit 1 fi -- Bo Berglund Developer in Sweden ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
ffmpeg [global_options] {[input_file_options] -i input_url} ... {[output_file_options] output_url} ... ffmpeg reads from an arbitrary number of input "files" (which can be regular files, pipes, network streams, grabbing devices, etc.), specified by the -i option, and writes to an arbitrary number of output "files", which are specified by a plain output url. Anything found on the command line which cannot be interpreted as an option is considered to be an output url. ... Get it: https://www.pdfdrive.com/ffmpeg-documentation-e201036326.html On 7/6/21, Bo Berglund wrote: > Before I run my Linux script for download a youtube video stream I would > like to > be able to check if the URL supplied is valid, i.e. it does not display an > error > message like this video does: > https://youtu.be/21qP3flYoic > > Can this be done using youtube-dl or straight ffmpeg? > > I need a bash script or function "validytvideo" which returns 0 if the URL > is OK > and 1 if not. > > I am using ffmpeg in scripts to download news videos unattended and I want > to be > notified when a YouTube URL has become unavailable... > > Please suggest a bash script solution rather than python, which I do not > master... > > > -- > Bo Berglund > Developer in Sweden > > ___ > ffmpeg-user mailing list > ffmpeg-user@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-user > > To unsubscribe, visit link above, or email > ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On Tue, 06 Jul 2021 10:14:46 +0200, Bo Berglund wrote: >On Tue, 06 Jul 2021 09:00:47 +0200, Bo Berglund wrote: > >>Can this be done using youtube-dl or straight ffmpeg? > >Self-answer: > >It seems like this will do what I need: > >eval "youtube-dl -F $VIDEOURL" >if [ $? -eq 0 ] >then > exit 0 >else > exit 1 >fi This works well if a Youtube URL disappears or is replaced with the YT error message about copyright. But whenever the video stalls and just continuously displays one single image for minutes on end the test above does not detect it. So is there a way to check if a video is static and generate an error in that case? Something like: ffmpeg -i input_url -checkstaticvideo Is this possible? -- Bo Berglund Developer in Sweden ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On Wed, 07 Jul 2021 14:21:15 +0200, Bo Berglund wrote: >But whenever the video is stalled and just continuously displays one single >image >for minutes on end the test above does not detect it. >So is there a way to check if a video is static and generate an error in that >case? >Something like: >ffmpeg -i input_url -checkstaticvideo > >Is this possible? Follow-up: I found the following documentation for freezedetect: https://ffmpeg.org/ffmpeg-all.html#freezedetect However there is no example for using it and when I try it on a stalled Youtube video like this I get a result I cannot interpret (on Ubuntu 18): $ ffmpeg -i https://youtu.be/sAt6nY2BWNw -f freezedetect -d 5 -n 0.01 ffmpeg version 4.3.2-0york0~18.04 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04) configuration: --prefix=/usr --extra-version='0york0~18.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libzimg --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat58. 45.100 / 58. 45.100 libavdevice58. 10.100 / 58. 10.100 libavfilter 7. 85.100 / 7. 85.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc55. 7.100 / 55. 7.100 https://youtu.be/sAt6nY2BWNw: Invalid data found when processing input Lacking an example I cannot proceed What I want is for ffmpeg to check the video and if it is frozen exit with result 1 and if the video is not frozen exit with result 0. What should be the correct call syntax? The test should be done for a time of say 5 seconds and if the video is the same for that time it should exit with code 1 whereas if it is not stalled exit with code 0. So it can be utilized in a script. -- Bo Berglund Developer in Sweden ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On Wed, 07 Jul 2021 14:43:27 +0200, Bo Berglund wrote: >Lacking an example I cannot proceed > >What I want is for ffmpeg to check the video and if it is frozen exit with >result 1 and if the video is not frozen exit with result 0. >What should be the correct call syntax? > >The test should be done for a time of say 5 seconds and if the video is the >same >for that time it should exit with code 1 whereas if it is not stalled exit with >code 0. So it can be utilized in a script. I found one example for which I adapted my test: https://superuser.com/questions/1313070/way-to-detect-frozen-video-with-ffmpeg But still teh same error: $ ffmpeg -i https://youtu.be/sAt6nY2BWNw -vf "freezedetect=n=0.01:d=5" -map 0:v:0 -f null - ffmpeg version 4.3.2-0york0~18.04 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04) configuration: --prefix=/usr --extra-version='0york0~18.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libzimg --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat58. 45.100 / 58. 45.100 libavdevice58. 10.100 / 58. 10.100 libavfilter 7. 85.100 / 7. 85.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc55. 7.100 / 55. 7.100 https://youtu.be/sAt6nY2BWNw: Invalid data found when processing input -- Bo Berglund Developer in Sweden ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On Wed, 7 Jul 2021 at 13:43, Bo Berglund wrote: > On Wed, 07 Jul 2021 14:21:15 +0200, Bo Berglund wrote: > >So is there a way to check if a video is static and generate an error in > >that case? > >Something like: > >ffmpeg -i input_url -checkstaticvideo > > > >Is this possible? If you cannot get freezedetect to work, a workaround could be to extract two images from a video stream separated in time, and use imagemagick's 'compare' to get a numerical difference between them. The documentation on that should be sufficient for you to wrangle up a script to your liking. https://imagemagick.org/script/compare.php https://legacy.imagemagick.org/Usage/compare/ In the meantime, there is an example on this SuperUser answer from 2019: https://superuser.com/a/1429300/461558 Cheers, Rob ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On Wed, 7 Jul 2021 at 13:52, Bo Berglund wrote: > But still teh same error: > > $ ffmpeg -i https://youtu.be/sAt6nY2BWNw -vf "freezedetect=n=0.01:d=5" -map > 0:v:0 -f null - > [...] > https://youtu.be/sAt6nY2BWNw: Invalid data found when processing input Have you successfully used ffmpeg on a YouTube video *page* URL before? I haven't done this in a while, but I seem to recall having to use youtube-dl to grab the video [1], or the video URL [2]. [1]: https://superuser.com/a/1305473/461558 [2]: https://unix.stackexchange.com/a/282413/227308 Note that the latter may no longer work and return a 403 Forbidden error nowadays. Cheers, Rob ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On Wed, 7 Jul 2021 13:54:11 +0100, Rob Hallam wrote: >On Wed, 7 Jul 2021 at 13:43, Bo Berglund wrote: >> On Wed, 07 Jul 2021 14:21:15 +0200, Bo Berglund >> wrote: >> >So is there a way to check if a video is static and generate an error in >> >that case? >> >Something like: >> >ffmpeg -i input_url -checkstaticvideo >> > >> >Is this possible? > >If you cannot get freezedetect to work, a workaround could be to >extract two images from a video stream separated in time, and use >imagemagick's 'compare' to get a numerical difference between them. >The documentation on that should be sufficient for you to wrangle up a >script to your liking. > >https://imagemagick.org/script/compare.php >https://legacy.imagemagick.org/Usage/compare/ > >In the meantime, there is an example on this SuperUser answer from 2019: > >https://superuser.com/a/1429300/461558 > >Cheers, >Rob Like the examples I have seen before all examples suppose that you have the video available as a file, whereas I am checking a *live stream* on YouTube which freezes from time to time and just shows a still (often just a blue triangle on black background). I have an automatic download scheme running on Linux to get the 1-hour segment videos from the stream so I can view them later, but I want to have a check for the times the stream stops so I can do something about it (like switching stream). So my "takedown detect" script checks if the stream is being blocked by Youtube and this works using youtube-dl with the -F switch. Works OK, I get an email if it is blocked. But now I saw a different error I also want to check for, this is when the stream semingly works fine but the video has frozen. Then my earlier detection does not catch it so I have to add a new detect to see the frozen video case too So ffmpeg must accept the -i argument as an on-line stream somehow... Unless there is some other way to detect that a stream sends a still image. -- Bo Berglund Developer in Sweden ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On 7/7/2021 8:48 AM, Bo Berglund wrote: But now I saw a different error I also want to check for, this is when the stream semingly works fine but the video has frozen. Does that mean youtube continues to send duplicate frames (which are received w/o error) or that no frames are received at all? The latter could be noticed by watching the process network i/o (no received packets = no received stream). z! ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On Wed, 7 Jul 2021 at 16:49, Bo Berglund wrote: > So ffmpeg must accept the -i argument as an on-line stream somehow... Please see my other reply to your other message- ffmpeg does not (to my knowledge) operate on web pages, as opposed to multimedia files. Cheers, Rob PS It may be worth checking to see that no-one else has done what you are trying to do so that you don't have to reinvent the wheel- it seems possible that someone has created a utility / wrapper / library for interacting with livestreams which gracefully handles errors (eg something similar to livestreamer [https://docs.livestreamer.io/index.html], which may not be suitable for your case but gives you an idea of what is out there) ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On Wed, 7 Jul 2021 09:02:47 -0700, Carl Zwanzig wrote: >On 7/7/2021 8:48 AM, Bo Berglund wrote: >> But now I saw a different error I also want to check for, this is when the >> stream semingly works fine but the video has frozen. > >Does that mean youtube continues to send duplicate frames (which are >received w/o error) or that no frames are received at all? The latter could >be noticed by watching the process network i/o (no received packets = no >received stream). What happens is that the stream continues unabated but there is only a blue triangle on the screen. I downladed such a video and cut it down in size to about 3 minutes (bluearrow.mp4) and ran the test on that local video just to see what would happen. Here is the complete result including my test of the exit code of ffmpeg: $ ffmpeg -i bluearrow.mp4 -vf "freezedetect=n=0.01:d=5" -map 0:v:0 -f null - ffmpeg version 4.3.2-0york0~18.04 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04) configuration: --prefix=/usr --extra-version='0york0~18.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libzimg --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat58. 45.100 / 58. 45.100 libavdevice58. 10.100 / 58. 10.100 libavfilter 7. 85.100 / 7. 85.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc55. 7.100 / 55. 7.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'bluearrow.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.45.100 Duration: 00:03:10.01, start: 0.00, bitrate: 145 kb/s Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 854x480 [SAR 1:1 DAR 427:240], 9 kb/s, 30 fps, 30 tbr, 90k tbn, 60 tbc (default) Metadata: handler_name: VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default) Metadata: handler_name: SoundHandler Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native)) Press [q] to stop, [?] for help Output #0, null, to 'pipe:': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.45.100 Stream #0:0(und): Video: wrapped_avframe, yuv420p, 854x480 [SAR 1:1 DAR 427:240], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default) Metadata: handler_name: VideoHandler encoder : Lavc58.91.100 wrapped_avframe [freezedetect @ 0x55ce112ce980] lavfi.freezedetect.freeze_start: 0 frame= 5700 fps=940 q=-0.0 Lsize=N/A time=00:03:10.00 bitrate=N/A speed=31.3x video:2984kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown $ echo $? 0 --- Notice that the exit code was 0 ($?) even though the video was frozen regarding the image. So now at least ffmpeg did something (while doing so it displayed something like 30x indicating it did the processing at 30 times normal speed. Yet it did not output a finding of "frozen" or similar. How is this filter supposed to output a result and what does that result look like? I do not want another video, just a verdict that it is frozen or not. -- Bo Berglund Developer in Sweden ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On Wed, 7 Jul 2021 17:08:37 +0100, Rob Hallam wrote: >Please see my other reply to your other message- ffmpeg does not (to >my knowledge) operate on web pages, as opposed to multimedia files. I am looking for a *quick* test method just looking at the stream and deciding in about 5 seconds weather there is a freeze or not. The test is supposed to be run by cron at regular intervals and if a freeze is found it will send me an alert email. The URL it uses is in a disk file and is read from the file like the download script does. This is designed so I can easily modify the URL if it changes even when there are scheduled download jobs not yet executing. (I use at scheduling for the downloads) -- Bo Berglund Developer in Sweden ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
Bo Berglund writes: > Here is the complete result including my test of the exit code of ffmpeg: > > > $ ffmpeg -i bluearrow.mp4 -vf "freezedetect=n=0.01:d=5" -map 0:v:0 -f null - > [freezedetect @ 0x55ce112ce980] lavfi.freezedetect.freeze_start: 0 ^ > $ echo $? > 0 > --- > > Notice that the exit code was 0 ($?) even though the video was frozen > regarding > the image. ffmpeg exited without error, so the exit code should be 0. Indeed, finding or not finding a freeze should not be signalled via exit code, I think. > Yet it did not output a finding of "frozen" or similar. It did. See the line I highlighted above. All you need to do now is something like filter the output of ffmpeg like: ffmpeg -i bluearrow.mp4 -vf "freezedetect=n=0.01:d=5" -map 0:v:0 -f null - | grep -q 'lavfi.freezedetect.freeze_start: ' nofreeze=$? O! ffmpeg sends stuff to stdout and stderr in random ways, so you will need to redirect stderr to stdout, I suspect. Leo ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On Thu, 08 Jul 2021 15:22:24 -0500, Leo Butler via ffmpeg-user wrote: >> Yet it did not output a finding of "frozen" or similar. > >It did. See the line I highlighted above. All you need to do now is >something like filter the output of ffmpeg like: > >ffmpeg -i bluearrow.mp4 -vf "freezedetect=n=0.01:d=5" -map 0:v:0 -f null - | >grep -q 'lavfi.freezedetect.freeze_start: ' >nofreeze=$? I tested the command using two different video snippets as input (with and without the blue arrow) and the screen output shows the line: [freezedetect @ 0x555be8939800] lavfi.freezedetect.freeze_start: 0 for *only* the bluearrow.mp4 video so this is a step forward! However, the grep command does the same (nothing) in both cases! I tested by replacing the | grep ... stuff with a redirect to file instead ffmpeg -hide_banner -i bluearrow.mp4 -vf "freezedetect=n=0.01:d=5" -map 0:v:0 -f null - > freezeoutput.txt This showed the same screen output but the freezeoutput.txt file is created but is empty! So grep has no chance of ever detecting anything Strange that the ffmpeg execution puts a lot of stuff on screen but nothing comes out in an output redirect file!! How can I programmatically check what is shown on screen when it does not reach the output? Is this what you mean by: > >O! ffmpeg sends stuff to stdout and stderr in random ways, so you will >need to redirect stderr to stdout, I suspect. Note that I am testing this in an ssh command line session to the linux box using PuTTY. -- Bo Berglund Developer in Sweden ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
* Bo Berglund on Friday, July 09, 2021 at 08:14:28 +0200: wrote: It did. See the line I highlighted above. All you need to do now is something like filter the output of ffmpeg like: ffmpeg -i bluearrow.mp4 -vf "freezedetect=n=0.01:d=5" -map 0:v:0 -f null - | grep -q 'lavfi.freezedetect.freeze_start: ' nofreeze=$? I tested the command using two different video snippets as input (with and without the blue arrow) and the screen output shows the line: [freezedetect @ 0x555be8939800] lavfi.freezedetect.freeze_start: 0 for *only* the bluearrow.mp4 video so this is a step forward! However, the grep command does the same (nothing) in both cases! ffmpeg writes the log output to stderr, so redirect it to stdout: ffmpeg -i bluearrow.mp4 -vf "freezedetect=n=0.01:d=5" -map 0:v:0 -f null - 2>&1 | grep -q 'lavfi.freezedetect.freeze_start: ' I tested by replacing the | grep ... stuff with a redirect to file instead ffmpeg -hide_banner -i bluearrow.mp4 -vf "freezedetect=n=0.01:d=5" -map 0:v:0 -f null - > freezeoutput.txt This showed the same screen output but the freezeoutput.txt file is created but is empty! So grep has no chance of ever detecting anything See above. But for writing the log into a file look into ffmpeg's -report option, that's what it's for. -- LAST SHIP HOME --->> https://lastshiphome.de Official Selection DOK.fest München 2018 German Ocean Film AwardCineMare Kiel 2019 Best Documentary Feature Wales International Film Festival 2020 ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
Christian Ebert (12021-07-09): > But for writing the log into a file look into ffmpeg's -report option, that's > what it's for. You can use it that way, but it is not what it is for. My advice for this thread: don't try to run before you can walk. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On Fri, 9 Jul 2021 10:10:11 +0100, Christian Ebert wrote: >> However, the grep command does the same (nothing) in both cases! > >ffmpeg writes the log output to stderr, so redirect it to stdout: > >ffmpeg -i bluearrow.mp4 -vf "freezedetect=n=0.01:d=5" -map 0:v:0 -f null - >2>&1 | grep -q 'lavfi.freezedetect.freeze_start: ' I ran this: ffmpeg -hide_banner -i bluearrow.mp4 -vf "freezedetect=n=0.01:d=5" -map 0:v:0 -f null - 2>&1 > freezeoutput.txt And the freezeoutput.txts still empty... -- Bo Berglund Developer in Sweden ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On Fri, 9 Jul 2021 11:46:19 +0200, Nicolas George wrote: >My advice for this thread: don't try to run before you can walk. What kind of help is that? Are you a troll? -- Bo Berglund Developer in Sweden ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On Fri, 9 Jul 2021 10:10:11 +0100, Christian Ebert 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 ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On 7/9/2021 3:05 AM, Bo Berglund wrote: On Fri, 9 Jul 2021 11:46:19 +0200, Nicolas George wrote: My advice for this thread: don't try to run before you can walk. What kind of help is that? Are you a troll? In idiomatic English, it means to start with the simple, not with the complex. This sounds like one of those places where cobbling something together out of command line programs is an exercise in frustration and the time might be better spent on working with the source code and libraries to get something that does exactly what you want. Or at least reading the source code to see what messages come from where. z! ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
Carl Zwanzig (12021-07-09): > In idiomatic English, it means to start with the simple, not with the complex. Thank you very much. > This sounds like one of those places where cobbling something together out > of command line programs is an exercise in frustration and the time might be > better spent on working with the source code and libraries to get something > that does exactly what you want. Or at least reading the source code to see > what messages come from where. That would be trying to fly ;-) I'd rather suggest getting a good book or course on Unix shell, file descriptors, redirections, etc., and come back to FFmpeg once this aspect of the issue is no longer a problem. For example, anybody skilled enough can tell that the reason "... 2>&1 > freezeoutput.txt" produces an empty file is that the order of the redirections matters. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to check if a youtube URL is valid before starting download?
On Fri, 09 Jul 2021 13:00:39 +0200, Bo Berglund wrote: >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. > > To simplify things I decided to use youtube-dl inside the script to download 15-20 s of the stream to a video file: timeout --signal=2 20s youtube-dl -f 94 -o $TESTFILE $VIDEOURL Then if this succeeds it would apply the ffmpeg command shown earlier to the testfile to determine if it contains a frozen video: FFREPORT=file=ffreport.log:level=32 ffmpeg -hide_banner -t 15 -i $TESTFILE -vf "freezedetect=n=0.01:d=5" -map 0:v:0 -f null - And finally the grep to check if it had a positive: grep "lavfi.freezedetect.freeze_start: " ffreport.log if [ $? -eq "0" ] then echo "Video frozen" exit 1 else echo "Video streaming OK" exit 0 fi This way I don't have to mess with making ffmpeg read the live stream directly. -- Bo Berglund Developer in Sweden ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".