编程与软件工程github.com
硬核学习 FFmpeg
Learn FFmpeg the hard way
2018 — 2020,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这是 GitHub 上的一个 FFmpeg/libav 教程,从视频的基本构成(帧、呈现时间戳、时间基)讲起,逐步进入用 libav 处理视频的代码示例和常见专业用例。它面向想理解底层原理、而不只是背命令行参数的人。
为什么经久不衰:FFmpeg/libav 的文档常常只给接口不给实践,这篇教程补上了“参数到底该怎么设”的经验,而视频基础概念多年未变,所以今天仍然值得读。
HN 评论精选
教程对帧和 PTS 的概括不错,但“恒定帧率”假设在手机视频上不成立。
简而言之,视频的基本概念就是一系列以给定速率播放的图片/帧。因此需要一些逻辑来平滑播放每一帧:每帧有一个呈现时间戳(PTS),它是在一个时间基(有理数,分母称为 timescale)中递增的数字,且时间基要能被帧率整除。把恒定帧率当作前提非常危险。专业摄像机录制的视频确实如此,但大多数手机录制的视频并非如此。
anonymfus查看英文原文
>In summary this is the very basic idea behind a video: a series of pictures / frames running at a given rate. >Therefore we need to introduce some logic to play each frame smoothly. For that matter, each frame has a presentation timestamp (PTS) which is an increasing number factored in a timebase that is a rational number (where the denominator is know as timescale) divisible by the frame rate (fps). Constant framerate is a very dangerous assumption to make. It's true for video recorded by professional cameras, but if you check video recorded by most mobile phones you notice that it's wrong.
用过 libav 的开发者认为及时更新的教程很有价值。
我做过使用 ffmpeg 库(以及 x264)的程序,不得不说,当年如果有这样一份紧跟现状的教程会非常有帮助。很高兴看到有人在做这件事。
fndrplayer13查看英文原文
Having built programs that used the ffmpeg libraries (as well as x264) I have to say that a tutorial that is up to date and recent like this would have been very helpful at the time. Glad to see somebody is undertaking this effort.
H.264/VP9 内部本质是可变码率,广播里的恒定码率靠空包填充实现。
总的来说是一篇不错的入门教程,涉及了一些常见专业用例。关于“恒定码率”的假设以及后面的讨论:任何变换加熵编码的编解码器(如 VP9 或 H264)内部永远是可变码率。在专业广播领域,不能超过 FCC 分配的射频频宽哪怕一点(否则会收到警告和罚款),做法是让编码器实际输出低于目标码率(比如目标是 5 Mbit/s),再用空包填充到整齐的 5 Mbit/s。LTE 广播也类似。能可靠做到这一点的编码器非常昂贵,而且是机架式设备。
opticalflow查看英文原文
All and all a good intro tutorial that gets into some of the common professional use cases. On "constant bitrate" assumptions and some of the subsequent discussion here, ANY transform-and-entropy codec like VP9 or H264 will ALWAYS be variable bitrate internally. In the pro broadcast world, where you can't go over your FCC-allocated radio frequency bandwidth allocation by even one iota (or nastygrams and fines ensue), this is "handled" by actually having the encoder understoot the actual target (say it's 5mbit), and then the stream is padded with null packets to get a nice even 5mbit/s. This also happens with LTE broadcast as well. The encoders that do this reliably are fabulously expensive and of a rackmount flavor.
FFmpeg/libav 功能多但参数陷阱多,教程能帮助理解该填什么。
我做过类似的 h264 转分片 mp4 的事情,要得到能在大多数播放器里正常播放的“正确”输出,有大量坑、奇怪的设置和标志需要处理。FFmpeg/libav 提供了大量功能,但有时读起来像看 javadoc:你拿到了接口,却完全不知道该填什么。
doppel查看英文原文
Having done something similar to transcode h264 to fragment mp4, there are a ton of pitfalls, weird settings and flags that need to be set to get a "correct" output that will play in most players. FFmpeg/libav provides a ton of functionality, but sometimes it's like reading javadocs, where you get the interface but have no idea of what to put in.
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选