本帖最后由 营养快线 于 2020-9-6 20:49 编辑
- decode = Decode.query.get(1)
- hls_time = decode.d_hls_time
- ff = FFmpeg(
- inputs={input_video: None},
- outputs={output_file: '-ss 5 -vframes 5 -r 0.5 out%d.jpg -c copy -f hls -bsf:v h264_mp4toannexb %s' % hls_time}
- )
- ff.run()
复制代码
用了ffmpy 这个库,%d 为输出图片的名称,%s 是从数据取到的参数来拼接 ffmpeg 命令
这么写的话会报错
- TypeError: %d format: a number is required, not str
复制代码
怎么实现 截图后自动命名图片 和 动态传入参数呢?
先感谢大佬出手!
------------------------------------------------------------
- ffmpeg_code = '-ss 5 -vframes 5 -r 0.5 out%d.jpg -c copy -f hls -bsf:v h264_mp4toannexb {}'
- ffmpeg_code = ffmpeg_code.format(hls_time)
复制代码
这样就对了 |