TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Learn FFmpeg the hard way

586 pointsby dreampeppers99over 7 years ago

21 comments

anonymfusover 7 years ago
&gt;In summary this is the very basic idea behind a video: a series of pictures &#x2F; frames running at a given rate.<p>&gt;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).<p>Constant framerate is a very dangerous assumption to make. It&#x27;s true for video recorded by professional cameras, but if you check video recorded by most mobile phones you notice that it&#x27;s wrong.
评论 #16193950 未加载
评论 #16193320 未加载
评论 #16197069 未加载
评论 #16193265 未加载
评论 #16193923 未加载
评论 #16195258 未加载
评论 #16193260 未加载
fndrplayer13over 7 years ago
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.
评论 #16195166 未加载
opticalflowover 7 years ago
All and all a good intro tutorial that gets into some of the common professional use cases. On &quot;constant bitrate&quot; 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&#x27;t go over your FCC-allocated radio frequency bandwidth allocation by even one iota (or nastygrams and fines ensue), this is &quot;handled&quot; by actually having the encoder understoot the actual target (say it&#x27;s 5mbit), and then the stream is padded with null packets to get a nice even 5mbit&#x2F;s. This also happens with LTE broadcast as well. The encoders that do this reliably are fabulously expensive and of a rackmount flavor.
评论 #16195807 未加载
评论 #16194562 未加载
spythonover 7 years ago
I wrote about creating adaptive streaming over HTTP (MPEG-DASH) using ffmpeg and mp4box before [1]. It is nice to see that ffmpeg is incorporating more and more of the same features.<p>Has anybody got ffmpeg to create HLS out of mp4 fragments as well? It would save some conversion time and space, since the same MP4 fragments could be used with the two different manifest files, DASH and HLS. Mp4box is not quite there yet, sadly.<p>[1] <a href="https:&#x2F;&#x2F;rybakov.com&#x2F;blog&#x2F;mpeg-dash&#x2F;" rel="nofollow">https:&#x2F;&#x2F;rybakov.com&#x2F;blog&#x2F;mpeg-dash&#x2F;</a>
评论 #16193505 未加载
qwerty456127over 7 years ago
Why exactly do people call good explanatory manuals &quot;the hard way&quot;? The hard way to learn something is using nothing but the official reference manual or the man pages. What I have found by the link is what I would rather call &quot;for dummies&quot; :-)
评论 #16194782 未加载
评论 #16195512 未加载
评论 #16194691 未加载
sbarreover 7 years ago
This looks pretty awesome..<p>I was hoping this was about the command-line tool, which is quite daunting to learn once you start getting into the filters and combining&#x2F;merging multiple audio and video sources.<p>In a recent project I eventually had to write a script to do 2 passes of ffmpeg after spending a good day trying to figure my way through all the filter documentation to do a 5-step process in one pass..<p>This isn&#x27;t a knock against ffmpeg, which is an amazing open source package, but it&#x27;s complicated, so I&#x27;m sure this repo will be of great help to many.
评论 #16193334 未加载
pselbertover 7 years ago
I’ve spent a large portion of the past month working with ffmpeg. We are using it to repair, concat, and mux an arbitrary number of overlapping audio and video streams recorded via WebRTC. While this sounds straight forward on the face of it, the interplay of filters and controls is impossible to predict without extensive experience.<p>To my knowledge ffmpeg is the only tool that could possibly do this. It took a whole lot of reading man pages, bug trackers, stack exchange and various online sources to stitch together the necessary info. This seems like a great resource to learn what the tool is really doing and skip scrambling for information so much.
评论 #16193452 未加载
评论 #16193515 未加载
评论 #16195536 未加载
ameliusover 7 years ago
Sidenote: over the years I haven&#x27;t seen a Linux utility crash so often as ffmpeg; not by a wide margin. So when calling this library, it is probably wise to assume that it may not return.
评论 #16193643 未加载
评论 #16193551 未加载
评论 #16195143 未加载
评论 #16193970 未加载
dvirskyover 7 years ago
About 10 years ago I wrote a video encoding app with libavcodec&#x2F;libavformat. Beyond very simple examples with everything set to default, there was almost zero material on how to use it. There was maybe one trivial example of decoding a file where all the parameters are guessed automatically. But I needed to encode a live video stream from a webcam. I spent a couple of weeks reading the code and hacking away until I got it right. I wish there was stuff like that back then.
ourcatover 7 years ago
When ffmpeg came along nearly 20 years ago, it seemed to be the absolute video toolbox I was looking for.<p>It was, but you needed what seemed to be &#x27;dark arts&#x27; to use it. And that took a long long time.<p>I owe years of my career to working out how to use this.
Xeoncrossover 7 years ago
I would gladly donate to anyone that wants to statically bind this for use with Go. I really would love to see the power of FFmpeg open to more apps.<p>I&#x27;ve used FFmpeg libs dynamically linked, but it requires FFmpeg be installed on the system.
评论 #16194783 未加载
评论 #16193920 未加载
评论 #16194667 未加载
评论 #16193946 未加载
billconanover 7 years ago
This is great! my experience with libav is very frustrating. There was no document&#x2F;tutorial. The most useful thing was the example programs. but if a problem is not covered by the examples, then I would be doomed.<p>The worst part is that when the api doesn&#x27;t work, you receive meaningless error messages. You don&#x27;t know what&#x27;s wrong.
aurelian15over 7 years ago
I wrote a small wrapper library a decade ago that wraps the decoding capabilities of libavcodec&#x2F;libavformat in way that makes it relatively easy to use from other programming languages (Pascal in this particular case)<p><a href="https:&#x2F;&#x2F;github.com&#x2F;astoeckel&#x2F;acinerella" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;astoeckel&#x2F;acinerella</a><p>Note that this was one of the first C programs I ever wrote and the API is suboptimal (relies on structs being passed around instead of providing access via getter&#x2F;setter functions). I don&#x27;t really recommend that people use it, yet looking at the code might help people to get started with ffmpeg.<p>Also note that the libavcodev&#x2F;libavformat libraries have gone a long way in terms of ease of use. If you have a look at the first versions of my wrapper library, it required really weird hacks (registering a protocol) to get a VIO interface (i.e. have callbacks for read, write, seek).<p>All that being said, today I usually just spawn subprocesses for ffmpeg&#x2F;ffprobe if I need to read multimedia-files, and I think that for most server-side applications this is the best method (it also allows to sandbox ffmpeg&#x2F;ffprobe).
评论 #16194849 未加载
mdipover 7 years ago
About a year ago I wrote a zsh script to analyse files in my collection and format&#x2F;selectively re-encode them based on a set of rules. Basically, I wanted .mp4 files that the Roku Plex app could play back without having to do any kind of re-encoding (stream&#x2F;container or otherwise).<p>That started me on a 2-week mission of understanding the command-line. Good God is it a nightmare! All my script was doing was reading the existing file, deciding on the &quot;correct&quot; video and audio track, creating an AC-3 if only a DTS existed, and adding a two-channel AAC track. It would also re-encode the video track if the bitrate was too high or the profile was greater than the Roku could handle.<p>Here&#x27;s the thing that I discovered, as much as I swore at the command-line interface, I couldn&#x27;t come up with a more elegant solution that would still allow the application to be controlled entirely from the CLI. Ffmpeg is capable of <i>so much</i> that figuring out a way to just &quot;tell it what to do&quot; from a CLI ends up with an interface that&#x27;s ... that difficult to use. The program, very nearly, handles <i>everything</i>[0] as it relates to media files and simplifying the application to improve the CLI would necessarily involve eliminating features. It&#x27;s one of those cases where a light-weight DSL would provide a superior interface (and to a certain extent, the command-line of ffmpeg nearly qualifies as a DSL).<p>[0] The &quot;very nearly&quot; was necessary because of the <i>one</i> feature I found that it didn&#x27;t handle. It&#x27;s not possible in the current version to convert subtitle tracks from DVDs to a format that is &quot;legal&quot; in an mp4 file because the DVD subtitles are images rather than text, whereas the only formats that are legal for the mp4 container are text. I found some utilities that can handle this, but didn&#x27;t try any, opting instead to simply download them when I encountered a file with subtitles in this format.
评论 #16198390 未加载
Teknoman117over 7 years ago
Always wondered why there were never any stellar guides for the underlying libraries of FFmpeg. Had to do a couple of projects with hardware encoding and decoding and the best example I found of how to use it was ripping apart mpv. At least it has samples of how to use the hardware encode features...
jsdirover 7 years ago
My project ran into a limitation that required only the use of FFmpeg libav without the command line tool. This is exactly what I needed. I&#x27;m eager to read the rest.
seertaakover 7 years ago
This is awesome -- I read the first few pages and I&#x27;m really looking forward to reading the rest. Very clearly explained; thanks for creating&#x2F;sharing!
FraKtusover 7 years ago
I use FFmpeg since more than 10 years and I am amazed at how stable it is. Even when we say to our users drop anything in our apps we will do our best to handle it .. it&#x27;s exceptional to have an issue with it. Because the API is always evolving the best advice is to read the headers, the best documentation is there and its accurate.
mmanfrinover 7 years ago
Question related to FFMpeg: In the first few examples, there are input options defining the video and audio encoding -- why is this needed? Shouldn&#x27;t a video container be self evident of things like that?
评论 #16196287 未加载
评论 #16197479 未加载
jakalahover 7 years ago
i have used it on the commandline really gives you fine grained control. winff is a easy way and almost as good within the front end.nice article on it.
imageticover 7 years ago
Thank you!