I have a script to download streaming videos where I use ffmpeg and in the process I have set up ffmpeg to scale the size into 480p and produce 30 fps video with keyframes on even seconds.
I cannot get ffmpeg to work for live streams on SVTPlay, but for that site I can use streamlink instead for the capture.
Here the timeout stops streamlink after the set time in $CAPTURETIME in seconds.Code:timeout --signal=2 $CAPTURETIME streamlink \"$URL\" 540p -o \"${TARGETFILE}\"
So now I want to send the streamlink output stream into ffmpeg as input so the output file will be written in the wanted format.
My ffmpeg based download command looks like this:
whereCode:CMD="ffmpeg -hide_banner ${MODE} -i \"${M3U8URL}\" -r 30 -vf scale=w=-4:h=${VIDEORES} -c:v libx264 -preset fast -crf 26 -x264-params keyint=30:scenecut=0:open-gop=0 -c:a aac -t ${CAPTURETIME} ${TARGETFILE}"
$MODE and $M3U8URL are the source definition
$VIDEORES="480"
$CAPTURETIME=video cut in seconds
$TARGETFILE= output file name (mp4)
So I want streamlink hook into the stream and send it on as input to ffmpeg and observe the CAPTURETIME value (in seconds).
How can I do this? I am pretty new to streamlink and its help is overwhelmingly big...
+ Reply to Thread
Results 1 to 2 of 2
-
-
Reply to self:
This works fine on first test:
Code:$ streamlink svt1-d.akamaized.net/se/svt1/manifest.mpd 540p --stdout | ffmpeg -i pipe:0 -r 30 -vf scale=w=-4:h=480 -c:v libx264 -preset fast -crf 26 -x264-params keyint=30:scenecut=0:open-gop=0 -c:a aac -t 120 streamtest_2_svt1.mp4
The file size is 13 Mb for 2 minutes.
The only issue I have is that when ffmpeg stops processing, thanks to the -t 240 argument, it kills streamlink, which prints an error message:
Code:error: Error when writing to output: [Errno 32] Broken pipe, exiting [cli][info] Closing currently open stream...
UPDATE:
It really does not matter since the video is closed by ffmpeg and works perfectly.
Streamlink can say what it wants, it does not affect the final product.Last edited by BosseB; 30th Jan 2024 at 16:59.
Similar Threads
-
download this video using streamlink or ffmpeg with explanation
By whittaker1212 in forum Video Streaming DownloadingReplies: 8Last Post: 14th Mar 2023, 17:19 -
Need Help: Streamlink with mpd and --ffmpeg-dkey
By boino2006 in forum Video Streaming DownloadingReplies: 3Last Post: 13th Jan 2023, 07:37 -
how do i send files from an android phone to an ubuntu laptop using wifi?
By oduodui in forum LinuxReplies: 10Last Post: 3rd Jul 2022, 13:21 -
how do i add libx264 and hevc to ffmpeg when i compile ffmpeg for ubuntu 21
By oduodui in forum Newbie / General discussionsReplies: 2Last Post: 17th Jul 2021, 04:12