[FFmpeg-user] Is there a way to set 'closed_gop' in FFmpeg?
Mark Filipak
markfilipak.imdb at gmail.com
Wed Jun 5 18:59:59 EEST 2024
On 05/06/2024 09.44, Paul B Mahol wrote:
>
> What is OFFmpeg ? and how to use it?
It is Object-FFmpeg. It is a fully video-object-oriented language, not functions pasted into python.
Objects are video/audio/subtitle/chapter streams, frames, fields, pictures, halfpics, scans.
There's very few global functions. Objects own methods, instead, of course.
Methods are owner-specific, so they 'know' how to work on the object type that owns them. So,
similar methods of two different objects can have the same name -- they don't need different names
or calling options to differentiate them -- and there are _no_ calling parameters. Methods are
simple, simple, simple.
New use-case patches do not add function code. They add new properties and new methods to handle the
things in the object type that are unique to the use-case but was previously unknown and not covered.
Properties are also owner-specific. All the MPEG tags are properties for example.
Properties and methods are inherited, so streams that are spawned (constructed) from parent streams
are already defined and already know how to do almost everything. For example, child pictures know
what their parent frame's MPEG tags were because it inherited the tags.
Constructors are methods that spawn children that inherit properties and methods _plus_ are given
those properties and methods that make them different from their parents. Constructors act like
structs but they make objects.
OFFmpeg execution -- the process pipe -- is state-machine driven. State machines are encapsulated
and functionally complete by design. State-machines have 100% coverage and are 100% testable. When a
state-machine works, it's done _forever_. When you are done writing code, you know you're done!
There are two unique global methods: stride-match and ?-test. They are very powerful and complete.
Stride-match was inspired by '-vf shuffleframes' but greatly expanded. ?-test was inspired by
var=val?yes():no() but greatly expanded.
There are global datatypes. For example,
"pts" is the same as "x=pts" where 'x' is a temporary anonymous object upon which operations that
follow that line work on until the end of code or until a different object is invoked or spawned.
"pts'12345'" is the same as "pts=12345".
"pts'+12345'" is the same as "pts+=12345".
"?pts'12345'(abc:xyz)" is the same as "if (pts==12345) abc(); else xyz();"
(though OFFmpeg methods don't pass parameters).
"..n" means "from zero through n by indexing an owner's property" and it provokes automatic looping.
So, for example,
?pts'..67890'(pts'+123':pts'-456')
is the same as something like this:
for (i=0, I=pts[0]; pts[i]; i++) {
if (pts<=67890) pts[i]+=123;
else pts-=456;
}
(I apologize for the 'C'-sh code above. I know the array indexes should really be pointers to a
struct, but I don't know pointers to structs, I don't know 'C'. So, I tried to convey the 'flavor'
of what I'm writing about.)
There are drawbacks to OFFmpeg:
It is very terse, very cryptic, hard to learn.
OOP is difficult for folks used to functions.
There will be a lot of pushback, especially against state machines. That will be true even though
'-filter_complex' is already a partially implemented state machine.
OFFmepg is easier than other OOP languages because there is only 1 level of ownership, and because
the sole datatype is string.
OFFmpeg is more accurate than other languages because It uses exact numerical expansions denoted
like this: "23.[976023..]" and "3753.75[0..]" -- remember, all values are strings. (Yes, FFmpeg has
24000/1001 and 90090/24, but 23.[976023..] and 3735.75[0..] are easier to turn into decimals having
the best native precision.)
Finally, OFFmpeg has a ton of operators.
Kindly forgive me if I've made any inadvertent mistakes above.
--Mark.
More information about the ffmpeg-user
mailing list