VideoLAN主席Jean-Baptiste Kempf在FOSDEM 2023對ffmpeg版本5.0/5.1和新版本6.0的一些介紹

知名多媒體開發(fā)者/VideoLAN的主席Jean-Baptiste Kempf在FOSDEM 2023上做了一個演講, 回顧了 FFmpeg 5.0/5.1版本的改進,并對 FFmpeg 6.0 新版本中的內(nèi)容進行了分享,還對 VLC 及其依賴項使用 wasm 編譯到 Web 瀏覽器,并使用 Webcodecs 解碼視頻進行了演示。其中我比較關(guān)注的是關(guān)于FFmpeg的部分,尤其是關(guān)于FFmpeg CLI multithreading(FFmpeg命令行工具多線程化)的部分*

參考:https://fosdem.org/2023/schedule/event/om_vlc/
B站帶字幕視頻分享:https://www.bilibili.com/video/BV19o4y1Y7W6/

關(guān)于FOSDEM
FOSDEM(Free and Open source Software Developers' European Meeting,自由和開源軟件開發(fā)者歐洲會議) 是一個非商業(yè)的、由志愿者組織的歐洲活動,以自由和開源軟件開為中心。它面向開發(fā)人員和任何對自由和開源軟件運動感興趣的人。它旨在使開發(fā)人員能夠滿足并促進對自由和開源軟件的認識和使用。FOSDEM 每年舉辦一次,通常在二月的第一個周末,地點在比利時布魯塞爾東南部的布魯塞爾自由大學(xué)。

1. 為什么要在FOSDEM 2023上做這個演講呢?

Jean-Bapiste提到FFmepg作為多媒體領(lǐng)域開源和云轉(zhuǎn)碼都在普遍使用的工具,在FOSDEM上竟然沒過相關(guān)的討論。另外即使在 Hacker News 上發(fā)布 FFmpeg 新版本時,也不是頭條的新聞。

這意味著我們做錯了什么,關(guān)于FFmpeg 的溝通不夠,所以我來了。

2. 談?wù)?FFmpeg 5.0

一年前發(fā)布的FFmpeg 5.0很重要,F(xiàn)Fmpeg 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月發(fā)布)的一些修改

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(預(yù)計2023年冬天發(fā)布)

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 缺乏多線程。所以,他們發(fā)明了很多奇怪的框架來做到這一點,所以有很多工作可以直接在 FFmpeg 中完成。
  • 它會持續(xù)一整年,我認為是整個 2023 年,但這意味著很多東西會更好用。當(dāng)然,這樣做時,需要真正關(guān)心線程安全和清理,所以清理工作量很大。
  • 5.0 所做了一部分工作,是實現(xiàn)了muxer現(xiàn)在在它們自己的線程中工作。

5. 關(guān)于FFmpeg新版本release的節(jié)奏

● 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會議關(guān)于open media的更多演講請移步 https://fosdem.org/2023/schedule/track/open_media/

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容