python - FFMPEG Streaming,使用列表进行多个演示

标签 python python-3.x ffmpeg

我目前正在使用第三方库将视频从 mp4 转码为 HLS。 https://video.aminyazdanpanah.com/python/start?r=hls#hls很棒的文档并且工作正常但是我通过将列表传递给 hls.representations() 有一个问题,我认为这是我做的错误。这是我运行代码的方式。

presetList = []
rep_1  = Representation(Size(1920,1080), Bitrate(4096 * 1024, 320 * 1024))
                    presetList.append(rep_1)
rep_2 = Representation(Size(1440, 900), Bitrate(2048 * 1024, 320 * 1024))
                    presetList.append(rep_2)

video =  "file.mp4"
video = ffmpeg_streaming.input(video)
completed_destination = "completed.m3u8"
hls = video.hls(Formats.h264())
hls.representations(presetList)
hls.output(completed_destination)
当我运行它时,我得到以下错误,这是由我的列表中的库含义值未正确传递引起的?
  File "/var/www/transcoder/transcoder/env/lib/python3.8/site-packages/ffmpeg_streaming/_hls_helper.py", line 87, in stream_info
    f'BANDWIDTH={rep.bitrate.calc_overall}',
AttributeError: 'list' object has no attribute 'bitrate'
如果我改为运行相同的代码,只进行如下更改,它就像一个魅力:
hls.representations(rep_1, rep_2)
我在这里做错了什么?谢谢

最佳答案

事实证明,我需要在传递给函数时包含 *args。例如,我应该做 hls.representations(*presetList) 而不是 hls.representations(presetList)

关于python - FFMPEG Streaming,使用列表进行多个演示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65545015/

相关文章:

python - 如何使 x,y 轴出现在 python matplotlib 中的轴中

python - Django:尝试读取模板 500.html 时出现 UnicodeDecodeError

python - 如何仅绘制具有数组某些值的某些单元格,而其他单元格则不使用 matplotlib.pyplot?

c++ - ffmpeg 包含问题 - 缺少某些功能

python - 使用 ipywidgets FileUpload 小部件时,我可以定义文件上传操作吗

python selenium 无法清除输入字段

python - matplotlib 中适当的突变比例值

python-3.x - Python 相当不错,没有模块,但模块是存在的

video - FFMPEG 批处理中的多个步骤

FFmpeg 会在音频覆盖前后创建一个小的可听 dropout_transition,我该如何删除它?