1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

208 Commits

Author SHA1 Message Date
Anton Khirnov
faa366003b fftools/ffmpeg_mux_init: consolidate connecting source to mux stream 2024-09-30 09:29:18 +02:00
Anton Khirnov
ba06c7b08f fftools/ffmpeg_mux_init: move the ost_get_filters() call to ost_bind_filter()
That is a more appropriate place for it.
2024-09-30 09:29:18 +02:00
Anton Khirnov
71916aa107 fftools/ffmpeg_mux_init: move the check for filtering+streamcopy
To streamcopy_init().

This will allow to simplify the control flow in ost_add() by moving the
ost_get_filters() call (which previously had to handle both encoding and
streamcopy streams) to ost_bind_filter() (which is only called for
audio/video encoding).

Also, return EINVAL rather than ENOSYS, as trying to combine filtering
with streamcopy is a parameter error.
2024-09-30 09:29:18 +02:00
Anton Khirnov
e83b5b2cc8 fftools/ffmpeg_mux_init: do not export forced_keyframes_const_names[]
It is only used in this file.
2024-09-30 09:29:18 +02:00
Anton Khirnov
64f3feb849 fftools/ffmpeg_mux: move OutputStream.enc_ctx to Encoder
The encoding AVCodecContext is a part of the encoder, and so should live
there.
2024-09-30 09:29:18 +02:00
Anton Khirnov
f295b4d8a0 fftools/ffmpeg_demux: drop ist_output_add()
It is now a trivial wrapper over ist_use(), so export that directly.
2024-09-30 09:29:18 +02:00
Anton Khirnov
d103b61cd8 fftools/ffmpeg_filter: remove remaining OutputStream usage in init_simple_filtergraph()
With this, nothing in ffmpeg_filter acesses OutputStream anymore, thus
there are no more direct ties between filtering and muxing.

Rename init_simple_filtergraph() to fg_create_simple() for consistency.
2024-09-26 18:29:40 +02:00
Anton Khirnov
72cd0c20da fftools/ffmpeg_filter: drop the OutputStream parameter to ofilter_bind_ost()
It is no longer used for anything besides a sanity-checking assert.
Rename the function to ofilter_bind_enc(), as it no longer has any
assumptions about the target being an output stream.
2024-09-26 18:29:40 +02:00
Anton Khirnov
addc29f67a fftools/ffmpeg_filter: stop accessing OutputStream.[max_]frame_rate
Pass them to ofilter_bind_ost() via OutputFilterOptions, as is done for
most other data it needs. OutputStream.[max_]frame_rate/force_fps are no
longer used outside of ffmpeg_mux*, and so can be made private.

This is a step toward decoupling encoders from muxers.
2024-09-26 18:29:40 +02:00
Anton Khirnov
7f7fe2a10b fftools/ffmpeg_enc: move set_encoder_id() to ffmpeg_mux_init
This code uses no encoder properties or state besides its name, and is
mostly muxer logic, and thus belongs more properly into the muxer.

The results of several test change due to different metadata tag order
(the "encoder" tag is now set first).
2024-09-26 18:25:21 +02:00
Anton Khirnov
78038d51c5 fftools/ffmpeg_enc: do not set output stream codec parameters directly
Have the muxer code read them out of the encoder context in
of_stream_init() instead.

OutputStream.par_in no longer needs to be public, so can be moved to
MuxStream.

This is a step towards decoupling encoders from muxers.
2024-09-26 18:25:21 +02:00
Anton Khirnov
238f439992 fftools/ffmpeg_enc: do not set AVStream timebase directly
Instead, pass the encoder context to of_stream_init() and have the muxer
take the timebase from there. Note that the muxer can currently access
the codec context directly, but that will change in future commits.

This is a step towards decoupling encoders from muxers.
2024-09-26 18:25:21 +02:00
Anton Khirnov
70f7bbeade fftools/ffmpeg_enc: add an AVClass to Encoder
Log decoder messages to the encoder rather than OutputStream.

This is a step towards decoupling encoders from muxers, similarly to
what was previously done to decoders and demuxers.
2024-09-26 18:25:21 +02:00
Anton Khirnov
da420ac6e1 fftools/ffmpeg: add support for multiview video
This extends the syntax for specifying input streams in -map and complex
filtergraph labels, to allow selecting a view by view ID, index, or
position. The corresponding decoder is then set up to decode the
appropriate view and send frames for that view to the correct
filtergraph input(s).
2024-09-23 17:15:02 +02:00
Anton Khirnov
68c198fae2 fftools/ffmpeg_sched: allow decoders to have multiple outputs
Will be useful for multilayer video.
2024-09-23 17:15:02 +02:00
Gyan Doshi
0d5b68c27c ffmpeg_mux_init: correct log suggestion
The option is enc_time_base, not enc_timebase
2024-09-19 15:35:15 +05:30
Marvin Scholz
3ebc68d25d fftools/ffmpeg_mux_init: fix variable shadowing 2024-09-13 19:38:40 +02:00
Marvin Scholz
bb91425eb8 fftools/ffmpeg_mux_init: remove unused variable
This dict is declared and freed but nothing is ever written to it.
2024-09-13 00:31:19 +02:00
Marvin Scholz
504c1ffcd8 fftools/ffmpeg: remove useless error check
When ret is checked here, it was never assigned anything, making this
check useless, as highlighted by Coverity.

It seems to be a copy paste mistake given that opt_match_per_stream_str
does not return an error code that could be checked and the previous
value assigned to ret is already checked above. So just remove this
check.

Fixes: CID1616292
2024-09-12 05:11:14 +02:00
Niklas Haas
8517ff2082 fftools/ffmpeg_filter: remove YUVJ hack
This is no longer needed, since we now correctly negotiate the required
range from the mjpeg encoder via avcodec_get_supported_config().

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-09-08 13:59:29 +02:00
Niklas Haas
a850f80e2c fftools/ffmpeg_filter: propagate codec yuv metadata to filters
To convert between color spaces/ranges, if needed by the codec
properties.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-09-08 13:59:29 +02:00
Niklas Haas
33d5a4ec4e fftools/ffmpeg_filter: switch to avcodec_get_supported_config()
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-09-08 13:59:29 +02:00
Anton Khirnov
f3e265c690 fftools/ffmpeg_mux_init: factor out binding filters to output streams 2024-09-08 13:59:29 +02:00
Niklas Haas
7b0eca1e51 fftools/ffmpeg_mux_init: switch to avcodec_get_supported_config() 2024-09-08 13:59:29 +02:00
Nicolas Gaullier
ee9ae4e8ba fftools/ffmpeg: Fix honor -r output option with streamcopy
Fix "ost->st->avg_frame_rate = ost->frame_rate" in streamcopy_init()
being reset to input's frame rate a few lines below.
Note that in current code, there are some discrepancies amongst the
muxers. For example, avienc relies on time_base, so it is not affected
by this patch, whereas mxfenc and matroskaenc do use avg_frame_rate,
so this patch fixes -r being honored.

In the updated fate test, the input is (wrongly) probed as 50fps. With
this patch, the correct value (25fps) is successfully forced with -r.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-09-04 13:01:37 +02:00
Anton Khirnov
d1bdd89c2f fftools/ffmpeg: use new stream specifier API in opt_match_per_stream*()
Removes a lot of error checking code, as matching cannot fail.
2024-08-13 10:28:54 +02:00
Anton Khirnov
93227a68f1 fftools/ffmpeg: replace remaining uses of MATCH_PER_STREAM_OPT() 2024-08-13 10:28:54 +02:00
Anton Khirnov
e218bde9f9 fftools/ffmpeg: replace MATCH_PER_STREAM_OPT(.., str, ..) with a function
This has multiple advantages:
* The macro has multiple parameters that often have similar or identical
  values, yet very different meanings (one is the name of the
  OptionsContext member where the parsed options are stored, the other
  the name of the variable into which the result is written); this
  change makes each of these explicit.

* The macro returns on failure, which may cause leaks - this was the
  reason for adding MATCH_PER_STREAM_OPT_CLEAN(), also ost_add()
  currently leaks encoder_opts. The new function returns failure to its
  caller, which decides how to deal with it. While that adds a lot of
  error checks/forwards for now, those will be reduced in following
  commits.

* new code is type- and const- correct

Invocations of MATCH_PER_STREAM_OPT() with other types will be converted
in following commits.
2024-08-13 10:28:54 +02:00
Anton Khirnov
10185e2d4c fftools/ffmpeg_mux_init: default to input timebase for streamcopy
Stop trying to invent some "framerate-based" timebase when there is no
reason to think the stream is CFR at all.
2024-07-09 11:14:08 +02:00
Anton Khirnov
901f7e3f72 fftools/ffmpeg_mux_init: make encoder_opts local to ost_add()
It is no longer needed after this function returns.
2024-07-03 11:38:52 +02:00
Anton Khirnov
9a7686e545 fftools/ffmpeg_mux_init: apply encoder options manually
Do not pass an options dictionary to the avcodec_open2() in enc_open().

This is cleaner and more robust, as previously various bits of code
would try to interpret the contents of the options dictionary, with
varying degrees of correctness. Now they can just access the encoder
AVCodecContext directly.

Cf. 372c78dd42 - analogous change for
decoding.

A non-progressive field order is now written on the container level in
interlaced ProRes encoding tests.
2024-07-03 11:38:52 +02:00
Anton Khirnov
f1664aabb1 fftools/ffmpeg: rewrite checking whether codec AVOptions have been used
Share the code between encoding and decoding. Instead of checking every
stream's options dictionary (which is also used for other purposes),
track all used options in a dedicated dictionary.
2024-07-03 11:38:52 +02:00
Michael Niedermayer
68f6063e04
fftools/ffmpeg_mux_init: Cleanup on error return in set_dispositions()
Fixes: CID1539099 Resource leak

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-02 21:57:19 +02:00
Thomas Siedel
c75940db29 avcodec: add external enc libvvenc for H266/VVC
Add external encoder VVenC for H266/VVC encoding.
Register new encoder libvvenc.
Add libvvenc to wrap the vvenc interface.
libvvenc implements encoder option: preset,qp,qpa,period,
passlogfile,stats,vvenc-params,level,tier.
Enable encoder by adding --enable-libvvenc in configure step.

Co-authored-by: Christian Bartnik chris10317h5@gmail.com
Signed-off-by: Thomas Siedel <thomas.ff@spin-digital.com>
2024-06-15 21:00:05 +08:00
Andreas Rheinhardt
6ae1a337f2 fftools/ffmpeg_mux_init: Fix leak when using non-encoding option
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-11 14:32:25 +02:00
Andreas Rheinhardt
c84e40d9e6 fftools/ffmpeg_mux_init: Return error upon error
Currently it may return an uninitialized value.
Introduced in 840f2bc18e.
Fixes Coverity issue #1603565.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-11 08:16:42 +02:00
Michael Niedermayer
840f2bc18e
fftools/ffmpeg_mux_init: Free pts on error
Fixes: CID1538863 Resource leak

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-07 21:42:26 +02:00
James Almer
8c27cdd2d4 fftools/ffmpeg_mux_init: add missing IAMF Param Definition copies
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-24 18:12:00 -03:00
James Almer
f684228407 fftools/ffmpeg_mux_init: remove leftover debug log messages
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-24 17:37:13 -03:00
James Almer
ecf87dd230 fftools/ffmpeg_mux_init: allow mapping a stream group from one of the inputs
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-23 23:54:46 -03:00
Anton Khirnov
d74cbcb963 fftools/ffmpeg_filter: drop OutputFilter.ost
All remaining code accessing it only needs to know whether this
filtergraph output has been bound or not.
2024-04-09 10:34:18 +02:00
Anton Khirnov
f2c919252d fftools/ffmpeg_filter: accept encoder thread count through OutputFilterOptions
Stop digging through encoder options manually.

Will allow decoupling filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
bfeb751171 fftools/ffmpeg_mux: drop OutputFile.format
It is no longer used outside of the muxing code (where we can access the
muxer directly).
2024-04-09 10:34:18 +02:00
Anton Khirnov
5b0589c8c3 fftools/ffmpeg_mux: drop OutputFile.shortest
It is no longer needed outside of of_open() and its children.
2024-04-09 10:34:18 +02:00
Anton Khirnov
a4c940c86a fftools/ffmpeg_filter: move most of -apad logic to the muxer
The decision whether -apad actually does anything is made based on muxer
properties, and so more properly belongs there. Filtering code only
receives the result.
2024-04-09 10:34:18 +02:00
Anton Khirnov
a2892dbe06 fftools/ffmpeg_filter: pass trim parameters through OutputFilterOptions
Do not read them from OutputStream directly.

Will allow decoupling filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
83304f7c1f fftools/ffmpeg_filter: pass autoscale through OutputFilterOptions
Do not read it from OutputStream directly.

Will allow decoupling filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
b8e6802023 fftools/ffmpeg_filter: pass sws/swr opts through OutputFilterOptions
Do not read them from OutputStream directly.

Will allow decoupling filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
da80e0b077 fftools/ffmpeg_filter: accept a caller-provided output name
Do not construct it from OutputStream manually.

Will allow decoupling filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
82c7c21b18 fftools/ffmpeg: drop OutputStream.is_cfr
It is used in a single place in the filtering code, so it is better to
inline it there.
2024-04-09 10:34:18 +02:00