[FFmpeg-user] Hardening ffmpeg stream download?

Carl Zwanzig cpz at tuunq.com
Fri Jun 10 22:41:53 EEST 2022


On 6/9/2022 2:59 PM, Bo Berglund wrote:
> 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?

I'd do the latter unless you need other specific parameters. Actually, you 
could just copy the streams into the output container if you want:

ffmpeg -hide_banner ${MODE} -i \"${M3U8URL}\" -c copy -t ${CAPTURETIME} 
${TARGETFILE}
where TARGETFILE ends with ".ts" -assuming- that the stream is a mpeg-ts.

Or force the output format to match the input. The point of copying is to 
avoid inserting another code/decode step. (What -is- the stream format? No 
output was included.)


> Or do I have to specify an encoding library?
That info is in the ffmpeg doc....


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

That's a different issue. You are hiding that processing time behind the 
download time.

Another option as mentioned before is to do all the cropping/etc on intake 
and use an output codec/muxer that doesn't require the finalize step, but I 
think that precludes x264 encoding. If you need x264, there's another step.

There are multiple paths to the same goal.

z!


More information about the ffmpeg-user mailing list