gpt4 book ai didi

python - 使用 ffmpeg-python 的多比特率 HLS

转载 作者:行者123 更新时间:2023-12-04 23:01:53 24 4
gpt4 key购买 nike

我目前正在使用 ffmpeg-python库来转换 .mp4视频转换为 HLS 格式,输出如下所示:

ffmpeg.output(
mp4_input,
m3u8_name,
format='hls', start_number=0, hls_time=5,
hls_list_size=0,
),
如何制作 ffmpeg-python以多种比特率输出 HLS 并为它们创建主播放列表?

最佳答案

实际上你可以在没有 ffmpeg-python 的情况下达到同样的效果。 .我是 VidGear 的创建者包含 StreamGear 的视频处理 Python 项目用于此目的的 API。示例代码如下:

# import required libraries
from vidgear.gears import StreamGear

# activate Single-Source Mode and also define various streams
stream_params = {
"-video_source": "foo.mp4",
"-streams": [
{"-resolution": "1920x1080", "-video_bitrate": "4000k"}, # Stream1: 1920x1080 at 4000kbs bitrate
{"-resolution": "1280x720", "-framerate": 30.0}, # Stream2: 1280x720 at 30fps framerate
{"-resolution": "640x360", "-framerate": 60.0}, # Stream3: 640x360 at 60fps framerate
{"-resolution": "320x240", "-video_bitrate": "500k"}, # Stream3: 320x240 at 500kbs bitrate
],
}
# describe a suitable master playlist location/name and assign params
streamer = StreamGear(output="hls_out.m3u8", format = "hls", **stream_params)
# trancode source
streamer.transcode_source()
# terminate
streamer.terminate()
就是这样。祝你好运!

关于python - 使用 ffmpeg-python 的多比特率 HLS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63995215/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com