[FFmpeg-user] Hardening ffmpeg stream download?
Bo Berglund
bo.berglund at gmail.com
Fri Jun 10 00:59:09 EEST 2022
On Thu, 9 Jun 2022 19:00:39 +0000, Carl Zwanzig <cpz at tuunq.com> wrote:
>On 6/9/2022 10:25 AM, Bo Berglund wrote:
>> Is there some way to let ffmpeg write the mpeg or ts stream to disk and then
>> immediately feed it to itself as an input to create the mp4?
>
>The "keep it simple" principle applies-
>
>Unless disk space is a big issue and you need the output immediately after
>recording, use a temp file for this and convert after the download*
>completes (as driven by your script). It'll be much easier all around and
>more tolerant of errors. If you choose to re-encode while downloading, you
>can run into the problem that the re-encoder catches up to the download and
>ends (the circular buffer problem).
>
>*if saving in the downloaded codec, there's no added conversion overhead or
>quality loss.
>
So given my original command in the script:
CMD="ffmpeg -hide_banner ${MODE} -i \"${M3U8URL}\" -vf scale=w=-4:h=480 -c:v
libx264 -preset fast -crf 26 -c:a aac -t ${CAPTURETIME} ${TARGETFILE}"
should I replace -c:v libx264 -preset fast -crf 26 with something else or simply
remove it and rely on ffmpeg to understand how to do based on me setting the
ouptput file extension to ts?
CMD="ffmpeg -hide_banner ${MODE} -i \"${M3U8URL}\" -vf scale=w=-4:h=480 -c:v
-preset fast -crf 26 -c:a aac -t ${CAPTURETIME} testfile.ts"
Or do I have to specify an encoding library?
Notice that early on I just downloaded the video and then applied the geometry
change and recoding to mp4 as a second step but it took a long time, almost half
the playing time of the video.
So that is why it all takes place during download now.
--
Bo Berglund
Developer in Sweden
More information about the ffmpeg-user
mailing list