News for hackers. Stuff that matters.
Re:Learn FFmpeg the hard way by anonymfus on Saturday January 20, 2018 @07:36AM (#16193137)
>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.

Re:Learn FFmpeg the hard way by orev on Saturday January 20, 2018 @11:33AM (#16193950)
Any tutorial will not get very far if every corner case is spelled out every time. The point of “learning” documents is to give enough concepts and useful information for the reader to have a basis to start building additional knowledge on top of. Getting into the weeds quickly derails this process.
Re:Learn FFmpeg the hard way by ouid on Saturday January 20, 2018 @02:57PM (#16195099)
what's wrong with presenting everything in the correct abstraction to start with?

Whether you a public school math class, or a git tutorial online, you always get the same thing. A list of procedures for using the tools in the most common cases you are likely to encounter. This seems like a good idea in the move fast and break things ideology, but what do we notice about people's skills in the real world? No one knows how git works, and no one knows any math by the time they leave high school.

Give people a set of tools and prove to them that it solves every problem in some domain. If they can't solve the problems using the most primitive, complete toolset you can give them, then the case where they solve the problem is the edge case.

As an example, often, we will have students write fractions in "lowest terms", then only present students with fractions in which the numerators and denominators only share a few, small common prime factors. But checking prime factors is absolutely the hardest way of solving this problem, and unless you're exhaustive in your search, you can't have any confidence that you actually have solved it.

Students are intrinsically aware that this wold be tedious in general, and it gives them anxiety to know that they could have missed something, or not tried sufficiently large divisors. They have no confidence in their tools, and rightly so. The only reason they can solve these problems at all is because the instructor gives them problems which can be solved this way.

The origin of the question "when will I use this in the real world?" is the instinct that the tool you have been given is only for edge cases, and cannot be relied upon.

I think you are exactly wrong in your assessment. Getting into the weeds is the only way to learn, because almost everything in the world is weeds, some of those weeds just happen to be called crops.

Re:Learn FFmpeg the hard way by dfabulich on Saturday January 20, 2018 @04:38PM (#16195555)
> what's wrong with presenting everything in the correct abstraction to start with?

Nobody can retain the material that way. Each thing you learn has to be attached to other concepts you already have, and your skills build on one another.

Nobody teaches Peano's axioms of arithmetic to kindergarteners; they're still learning how to identify shapes, to compare quantities. When they eventually learn even the simplest proofs, they'll build on the basis of careful attention to detail that they learned while mastering basic arithmetic.

Nobody teaches general relativity on the first day of college-level physics class. Students are still learning calculus at that point; even if they already had a calculus course, this is their first opportunity to apply it.

And nobody teaches the fundamental proofs of calculus on the first day of calculus class; you can use sloppy language like "infinitesimals" to establish a good intuition for how to use derivatives and integrals.

If you tried introducing this material from the bottom up, it wouldn't take. But if I'm wrong, sure, go try it and see how it works.

Re:Learn FFmpeg the hard way by ouid on Saturday January 20, 2018 @05:30PM (#16195785)
You're right, I shouldn't have said the correct abstraction, but you should at least provide a complete one. You don't have to build from the most fundamental possible assumptions to build from a set of tools that is provably complete for some domain of problems.

Doing otherwise is like giving someone a screwdriver that only turns clockwise.

Also, I challenge the notion that "no one can retain material that way". Have you ever met anyone who has retained the material any other way who didn't do it despite the system?

Re:Learn FFmpeg the hard way by CrystalLangUser on Sunday January 21, 2018 @08:25AM (#16197950)
Essentially, this is impossible for anything that’s not easily explainable all at once- so it’s useless for any advanced domain.

You can’t just give people a firehose of information. When you learn acoustic engineering, you have to first learn the prerequisite math needed to understand later concepts such as room architecture. It simply does not make sense to jam pack it all in at once, because 1) it won’t make sense and 2) nobody has that kind of memory.

Next, if you want to cover all possible use cases, that could take forever in certain domains.

Last, some of this stuff is objective as to what’s necessary, or what cases need to be covered.

No, what’s better is to give general knowledge as needed, and the student can seek out knowledge for various corner cases. It would be ridiculous otherwise.

Re:Learn FFmpeg the hard way by nailer on Monday January 22, 2018 @07:22AM (#16203830)
>> not true for videos shot with mobile phones

> Any tutorial will not get very far if every corner case is spelled out every time.

Is mobile phone video a corner case?

Re:Learn FFmpeg the hard way by JustSomeNobody on Saturday January 20, 2018 @12:48PM (#16194362)
I wouldn't consider options other than constant bit rate (variable bit rate) as corner cases, but your other points stand.
Re:Learn FFmpeg the hard way by innagadadavida on Saturday January 20, 2018 @01:32PM (#16194637)
Parent said frame rate, not bitrate. They are orthogonal to each other.
Re:Learn FFmpeg the hard way by lovelearning on Saturday January 20, 2018 @08:55AM (#16193320)
[1] is a useful list of such assumptions. Found it very handy when programming AV handling.

[1]: https://haasn.xyz/posts/2016-12-25-falsehoods-programmers-be...

Re:Learn FFmpeg the hard way by jsheard on Saturday January 20, 2018 @09:21AM (#16193418)
See also: this talk from a Vimeo engineer about the video encoding horrors they've encountered in the wild.

https://www.youtube.com/watch?v=cRSO3RtUOOk / https://speakerdeck.com/demuxed/things-developers-believe-ab...

Re:Learn FFmpeg the hard way by zerokernel on Saturday January 20, 2018 @06:48PM (#16196095)
Honestly I don't quite know how or why engineers keep working in a "all of this is fundamentally broken always has been and never will be fixed" domain, on a motivational basis.
Re:Learn FFmpeg the hard way by ouid on Saturday January 20, 2018 @06:34PM (#16196033)
"all frame timestamps are monotonically increasing"

wow...

Re:Learn FFmpeg the hard way by userbinator on Sunday January 21, 2018 @01:09AM (#16197069)
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.

It's unfortunate that so many tools assume constant framerate, because VFR is a useful compression technique in itself --- for sequences where there's basically no change between frames (few-second black scenes, for example), the encoder can stop continually encoding "no change" and just wait until there is.

Re:Learn FFmpeg the hard way by jiggunjer on Saturday January 20, 2018 @08:33AM (#16193265)
In my experience even cameras with constant framerates aren't really constant, if you look at the timestamps the delay between frames typically varies a few (dozen) ms. So on average you might have 30fps, but if you sample a random second you might end up with 28-32 frames.
Re:Learn FFmpeg the hard way by colund on Saturday January 20, 2018 @09:16AM (#16193395)
29.97?
Re:Learn FFmpeg the hard way by djsumdog on Saturday January 20, 2018 @10:22AM (#16193628)
That comes from the old NTSC standard and the history of adding colour in a backwards compatible way:

https://www.youtube.com/watch?v=3GJUM6pCpew

In the case that the above posters are mentioning, this probably has less to do with NTSC compatibility and more to do with bad timing hardware or cameras that attempt to do too much in PIO mode instead of using real encoding hardware.

Re:Learn FFmpeg the hard way by jiggunjer on Sunday January 21, 2018 @01:45AM (#16197142)
I wouldn't say bad timing means bad hardware though, even expensive scientific cameras suffer from this. You need rather complex electronics to capture at a high and consistent rate. I think normally the encoding is done by software.
Re:Learn FFmpeg the hard way by mikepurvis on Saturday January 20, 2018 @10:35AM (#16193676)
Glad to see that video linked; it's a terrific explanation.
Re:Learn FFmpeg the hard way by fest on Saturday January 20, 2018 @11:29AM (#16193923)
This really hits if you try to merge audio which has been recorded separately from video (e.g. Raspberry Pi where at least a few years ago software did not support recording audio synchronously with video).

And the worst thing is- it could vary from one device to other because the crystal oscillators used for image sensor clock have slightly different resonant frequency (which is caused by manufacturing tolerances when cutting the crystals).

Re:Learn FFmpeg the hard way by thearn4 on Saturday January 20, 2018 @03:32PM (#16195258)
This was something I had to find out the hard way in the process of writing this

https://github.com/thearn/webcam-pulse-detector

Without interpolative resampling, it didn't work well for me at all.

Re:Learn FFmpeg the hard way by gowan on Saturday January 20, 2018 @08:33AM (#16193260)
to be fair it is possible to do this from the command line with ffmpeg when using concat[1][2]. i did this when creating real time video from screencast in the chrome remote debugger.

[1] https://ffmpeg.org/ffmpeg-formats.html#concat

[2] https://trac.ffmpeg.org/wiki/Slideshow