我目前正在使用HLS库将.mp4视频转换为HLS格式,输出如下:
ffmpeg.output(
mp4_input,
m3u8_name,
format='hls', start_number=0, hls_time=5,
hls_list_size=0,
),如何让ffmpeg-python输出多个码率的HLS,并为它们创建一个主播放列表?
发布于 2021-09-04 08:33:19
实际上,您可以在没有ffmpeg-python的情况下实现相同的效果。我是VidGear视频处理Python项目的创建者,该项目包含用于此目的的StreamGear应用程序接口。示例代码如下:
# 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()就是这样。祝你好运!
https://stackoverflow.com/questions/63995215
复制相似问题