【问题标题】:Multiple bitrates HLS with ffmpeg-python使用 ffmpeg-python 的多比特率 HLS
【发布时间】:2020-09-21 15:17:03
【问题描述】:

我目前正在使用 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 并为其创建主播放列表?

【问题讨论】:

    标签: python ffmpeg mp4 http-live-streaming bitrate


    【解决方案1】:

    实际上你可以在没有ffmpeg-python 的情况下达到同样的效果。我是 VidGear 视频处理 Python 项目的创建者,其中包含用于此目的的 StreamGear 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()
    

    就是这样。祝你好运!

    【讨论】:

      猜你喜欢
      • 2011-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-24
      • 2017-10-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多