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

Anatoly anatoly at kazanfieldhockey.ru
Thu Sep 2 11:38:06 EEST 2021


On Wed, 01 Sep 2021 19:00:52 +0200
Bo Berglund <bo.berglund at gmail.com> wrote:

> On Wed, 1 Sep 2021 16:30:00 +0300, anatoly at kazanfieldhockey.ru wrote:
> 
> >> Is there a command line call I can make to extract the m3u8 URL
> >> automatically so
> >> it can be used in a script only supplied the main page URL?  
> >To get url of the first m3u8 from the page (this page actually has
> >only one) curl "https://www.livenewsmag.com/msnbc-news-live-stream/"
> >| grep -o -e "https://.\+m3u8" | head -n 1  
> 
> Thanks, this works inasmuch as it shows the URL on screen from where
> I can copy the URL manually.
> 
> However it looks like this when executed:
> 
> $ curl "https://www.livenewsmag.com/msnbc-news-live-stream/" | grep
> -o -e "https://.\+m3u8" | head -n 1
>   % Total    % Received % Xferd  Average Speed   Time    Time
> Time  Current Dload  Upload   Total   Spent    Left  Speed
> 100 86975  100 86975    0     0   375k      0 --:--:-- --:--:--
> --:--:--  374k
> https://1420543146.rsc.cdn77.org/tsOQo0dAAnGr5jKtXe_k5g==,1630526780/LS-ATL-54548-10/index.m3u8
> 
> So curl is outputting stuff during its probe that is also on the
> terminal output...
Extra stuff is otput to stderr, you see it in terminal, but it isn't
subject to '>' redirection or `` capture.
> But changing it to this:
> 
> $ curl -s "https://www.livenewsmag.com/msnbc-news-live-stream/" |
> grep -o -e "https://.\+m3u8" | head -n 1
> 
> removes all that fluff and I get exactly the end result!
> 
> I have now cereated a script, which updates the URL-file with the
> current items for the given URL.
Actually, you may do all in one script like this
#!/bin/sh
msnurl="https://www.livenewsmag.com/msnbc-news-live-stream/"
recdate=`date "+%Y%m%d-%H%M"`
m3u8url=`curl "https://www.livenewsmag.com/msnbc-news-live-stream/" |
grep -o -e "https://.\+m3u8" | head -n 1`
ffmpeg -referer $msnurl -i $m3u8url -c copy "msnbc-${recdate}.mp4"



More information about the ffmpeg-user mailing list