[FFmpeg-user] Can ffmpeg record video from this kind of URL?

Bo Berglund bo.berglund at gmail.com
Thu Nov 18 22:25:08 EET 2021


On Sat, 9 Oct 2021 03:23:52 +0300, Anatoly <anatoly at kazanfieldhockey.ru> wrote:

>"There's often a lot of magic involved in extracting the video URLs from
>webpages - parsing JavaScript, downloading and parsing JSON files,
>re-using cookies and referrers, and so on."
>
>So this is very hard, nearly to impossible to create a tool or
>receipe that will automatically extract video urls on *any* arbitrary
>page. Last time I just took a quick look at www.livenewsmag.com and
>found a simple solution for you, because that page is simple enough.
>Now let's do the same:
>
>#!/bin/sh
>#resolution here may be: prem, 720, 480, 240
>resolution="480"
>sdate=`date "+%Y%m%d-%H%M"`
>filename="rec-msnbc1-${sdate}.mp4"
>msn1url="https://msnbcdailyshows.com/"
>ggid=`curl $msn1url | grep -o -e "https://goodgame\.ru/player?[0-9]\+"
>| grep -o -e "[0-9]\+"`
>m3u8url="https://hls.goodgame.ru/hls/${ggid}_${resolution}.m3u8"
>ffmpeg -user_agent "Mozilla" -i $m3u8url -c copy $filename

Thanks for this example, I have now extracted parts of the code and put it into
my download script as a way in order to find the m3u8 URL at the beginning of
the download:

VIDEOURL="https://msnbcdailyshows.com/"
ggid=`curl $VIDEOURL | grep -o -e "https://goodgame\.ru/player?[0-9]\+" | grep
-o -e "[0-9]\+"`
VIDEOSTR="https://hlss.goodgame.ru/hls/${ggid}.m3u8"

And then I have used these for ffmpeg as follows:

CMD="ffmpeg -hide_banner -user_agent \"Mozilla\" -i $VIDEOSTR -vf
scale=w=-4:h=480 -c:v libx264 -preset fast -crf 26 -c:a copy -t $CAPTURETIME
$TARGETFILE"
eval $CMD

I could not use the resolution flag you showed because it did not work properly
for me. But the re-formatting code was already done and working so I kept that
instead.

Thanks again!


-- 
Bo Berglund
Developer in Sweden



More information about the ffmpeg-user mailing list