美文网首页
VideoLAN主席Jean-Baptiste Kempf在FO

VideoLAN主席Jean-Baptiste Kempf在FO

作者: smallest_one | 来源:发表于2023-02-25 19:10 被阅读0次

    知名多媒体开发者/VideoLAN的主席Jean-Baptiste Kempf在FOSDEM 2023上做了一个演讲, 回顾了 FFmpeg 5.0/5.1版本的改进,并对 FFmpeg 6.0 新版本中的内容进行了分享,还对 VLC 及其依赖项使用 wasm 编译到 Web 浏览器,并使用 Webcodecs 解码视频进行了演示。其中我比较关注的是关于FFmpeg的部分,尤其是关于FFmpeg CLI multithreading(FFmpeg命令行工具多线程化)的部分*

    参考:https://fosdem.org/2023/schedule/event/om_vlc/
    B站带字幕视频分享:https://www.bilibili.com/video/BV19o4y1Y7W6/

    关于FOSDEM
    FOSDEM(Free and Open source Software Developers' European Meeting,自由和开源软件开发者欧洲会议) 是一个非商业的、由志愿者组织的欧洲活动,以自由和开源软件开为中心。它面向开发人员和任何对自由和开源软件运动感兴趣的人。它旨在使开发人员能够满足并促进对自由和开源软件的认识和使用。FOSDEM 每年举办一次,通常在二月的第一个周末,地点在比利时布鲁塞尔东南部的布鲁塞尔自由大学。

    1. 为什么要在FOSDEM 2023上做这个演讲呢?

    Jean-Bapiste提到FFmepg作为多媒体领域开源和云转码都在普遍使用的工具,在FOSDEM上竟然没过相关的讨论。另外即使在 Hacker News 上发布 FFmpeg 新版本时,也不是头条的新闻。

    这意味着我们做错了什么,关于FFmpeg 的沟通不够,所以我来了。

    2. 谈谈 FFmpeg 5.0

    一年前发布的FFmpeg 5.0很重要,FFmpeg 5.0可能是FFmpeg有史以来对API破坏最大的版本,移除了很多废弃的API。

    Changes
    ● Avcodec encoding+decoding change
      ○ Audio & Video single API
      ○ Decoupled codec input & output
      ○ Encoders to output data into user-managed buffers
    ● AVFrame based API in swscale
    ● New bitstream filtering API
      ○ allows modifying encoded data without decoding it (e.g. analyzers)
    
    Changes - 2
    ● Disentangled avformat and avcodec
      ○ Demuxers no longer embed an entire decoder context
    ● Frames and packets always reference-counted
    ● Slice-threaded scaling in swscale
    ● IMF demuxing
    ● Dolby Vision metadata
    ● Hardware-accelerated ProRes and VP9 decoding on MacOS
      ○ Hardware-accelerated ProRes encoding
    ● libplacebo
    ● Numerous filters and game decoders
    

    旧的编解码的API

    
    // decoding single video packet in old API
    while (pkt->size > 0) {
       //decode pkt into frame, consumes <ret> bytes
       int ret = avcodec_decode_video2(dec, pkt, frame, &got_output);
      if (got_output)
         <proces output>
      // need to manually offset the buffer
      pkt->data += ret;
      pkt->size -= ret;
    }
    

    新的编解码的API

    // decoding single video packet in new API
    avcodec_send_packet(dec, pkt);
    ret = 0;
    while (ret >= 0) {
       ret = avcodec_receive_frame(dec, frame);
       if (ret < 0)
         break;
       <process frame>
    }
    

    3. FFmpeg5.1(2022年7月发布)的一些修改

    FFmpeg5.1 是一个LTS(Long Term Support,长期支持)的版本

    FFmpeg 5.1 "Riemann" (summer 2022)
    Release
    ● 130 contributors, ~3k files changed, ~150kLoC touched
    ● LTS
    Changes
    ● New more flexible and extensible channel layout API
    ● Expanded fuzzing coverage
    ● VDPAU-accelerated AV1 decoding
    ● SIMD optimization for HEVC on ARM64
    ● JPEG-XL decoding
    ● Enhanced support for SVT-AV1 encoding options
    ● Numerous fixes (and new filters)
    

    音频channel layouts API的修改

    Channel Layouts API
    ● Developed since 2013… 
      ○ Did not make it for 5.0
    ● Arbitrary number of channels in a layout (Previously only 64)
    ● Support for Ambisonics and NGA
    ● Conceptually a list of channels
    ● flexible internal representation
      ○ unspecified ordering
      ○ mask-based ordering (same as the old API, WAVEFORMATEX-compatible)
      ○ fixed-order ambisonics
      ○ explicit list of channels (allows edge cases like dual-mono)
    

    4. FFmpeg 6.0(预计2023年冬天发布)

    ongoing
    ● 191 contributors, ~3.5k files changed, ~220kLoC touched
    ● Numerous API changes (and break)
    Current Changes
    ● FFmpeg CLI multithreading (WIP), muxers
    ● RISC-V optimizations
    ● AV1 hw decoding for Intel, nVidia & AMD
    ● New highly-optimized FFT code with SIMD for x86 and ARM
    ● new API for output of reconstructed frames from encoders (currently implemented 
    for x264 and libaom)
    ● API breaks for deprecations, numerous YUV pix_fmt changes, AVFrame, opacification, channel layouts, H.274
    
    Current Hardware Changes
    ● AV1 hw decoding for Intel, nVidia & AMD
    ● Hardware-friendly high bit-depth and chroma-resolution pixel formats
    ● Android MediaCodec though NDKMediaCodec
    ● Android MediaCodec encoders
    ● Intel 10/12 4:2:2 & 4:4:4 with VAAPI and QSV + Filters
    Codecs
    ● New Decoders: Bonk, APAC, APAC, Mi-SC4, 100i, VQC, FTR
    PHM, WBMP, XMD ADPCM, WADY DPCM, CBD2 DPCM
    ● New Filters: adrc, afdelaysr, showcwt, a3dscope
    Ssim360, corr, backgroundkey
    ● dts2pts bitstream filter: generate timestamps for raw H.264 (extensible to HEVC 
    and other codecs
    

    FFmpeg命令行工具的多线程化

    FFmpeg CLI multithreading
    ● FFmpeg CLI is used everywhere
      ○ very flexible
      ○ architecture still based on the original code from 2000 
    ● Major architectural changes needed
      ○ code maintainable
      ○ efficient one-to-many transcoding
      ○ gathering metrics
    ● Every component in the transcoding pipeline
    (demuxing, decoding, filtering, encoding, muxing) will run in its 
    own thread
    ● Improves latency and new use cases
    
    • 主要变化之一也是我们见过的最困难的事情之一是多线程 FFmpeg CLI。
    • YouTube、Vimeo 和 Facebook 的所有大人物,以及所有 FFmpeg 漂亮 UI 的提供者,他们基本都会抱怨的一件事是 FFmpeg 缺乏多线程。所以,他们发明了很多奇怪的框架来做到这一点,所以有很多工作可以直接在 FFmpeg 中完成。
    • 它会持续一整年,我认为是整个 2023 年,但这意味着很多东西会更好用。当然,这样做时,需要真正关心线程安全和清理,所以清理工作量很大。
    • 5.0 所做了一部分工作,是实现了muxer现在在它们自己的线程中工作。

    5. 关于FFmpeg新版本release的节奏

    ● One major per year ABI/API breakage
    ● One or two minor per year, with no API changes
    ● Small security releases regularly
    ● One LTS every 2 year
    

    FOSDEM 2023会议关于open media的更多演讲请移步 https://fosdem.org/2023/schedule/track/open_media/

    相关文章

      网友评论

          本文标题:VideoLAN主席Jean-Baptiste Kempf在FO

          本文链接:https://www.haomeiwen.com/subject/uvofldtx.html