VideoHelp Forum




+ Reply to Thread
Results 1 to 2 of 2
  1. Member
    Join Date
    Feb 2021
    Location
    Sweden
    Search Comp PM
    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.
    Code:
    timeout --signal=2 $CAPTURETIME streamlink \"$URL\" 540p -o \"${TARGETFILE}\"
    Here the timeout stops streamlink after the set time in $CAPTURETIME in seconds.

    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:

    Code:
    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}"
    where
    $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...
    Quote Quote  
  2. Member
    Join Date
    Feb 2021
    Location
    Sweden
    Search Comp PM
    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
    It gets a stream with 540p resolution (480 is not available) and converts it to a file with 480p resolution and 30fps and keyframes on even seconds to simplify any editing necessary (cut on even seconds, no artifacts).
    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...
    So how can I make streamlink accept this without throwing an error?

    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.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!