Anton Khirnov
99d2fa38ad
fftools/ffmpeg: make sure FrameData is writable when we modify it
...
Also, add a function that returns const FrameData* for cases that only
read from it.
2023-12-06 10:30:28 +01:00
Anton Khirnov
1d536e0283
fftools/ffmpeg_filter: track input/output index in {Input,Output}FilterPriv
...
Will be useful in following commits.
2023-12-06 10:01:21 +01:00
Anton Khirnov
26ebd96371
fftools/ffmpeg_filter: return an error on ofilter_alloc() failure
2023-11-09 11:25:17 +01:00
Anton Khirnov
5db07311a0
fftools/ffmpeg_filter: fail on ifilter_alloc() failure
2023-11-09 11:25:17 +01:00
Anton Khirnov
2ef50c17ab
fftools/ffmpeg_filter: fail on filtering errors
...
These should be considered serious errors - don't just print a log
message and continue as if nothing happened.
2023-10-10 12:41:31 +02:00
Anton Khirnov
9196be2fb1
fftools/ffmpeg_enc: move fps conversion code to ffmpeg_filter
...
Its function is analogous to that of the fps filter, so filtering is a
more appropriate place for this.
The main practical reason for this move is that it places the encoding
sync queue right at the boundary between filters and encoders. This will
be important when switching to threaded scheduling, as the sync queue
involves multiple streams and will thus need to do nontrivial
inter-thread synchronization.
In addition to framerate conversion, the closely-related
* encoder timebase selection
* applying the start_time offset
are also moved to filtering.
2023-10-10 12:41:31 +02:00
Anton Khirnov
e35d36eb72
ffools/ffmpeg_filter: stop trying to handle an unreachable state
...
ifilter_send_eof() will fail if the input has no real or fallback
parameters, so there is no need to handle the case of some inputs being
in EOF state yet having no parameters.
2023-10-10 12:41:31 +02:00
James Almer
3fd37b5268
fftools/ffmpeg: stop using AVStream.side_data
...
Signed-off-by: James Almer <jamrial@gmail.com >
2023-10-06 10:11:00 -03:00
Anton Khirnov
8d12762b42
fftools/ffmpeg: move derivation of frame duration from filter framerate
...
From ffmpeg_enc to ffmpeg_filter, which is a more appropriate
place for it.
2023-10-03 16:57:02 +02:00
Anton Khirnov
3c397a1d46
fftools/ffmpeg: move sending filtergraph commands to a separate function
...
Stop accessing filtergraph internals from keyboard reading code.
2023-08-30 11:53:50 +02:00
Anton Khirnov
d55262704e
fftools/ffmpeg_filter: shorten a variable name
2023-08-30 11:53:50 +02:00
Anton Khirnov
fbcecdec8a
fftools/ffmpeg_filter: reindent after previous commit
2023-08-30 11:53:50 +02:00
Anton Khirnov
d9c862b57f
fftools/ffmpeg_filter: factor processing a single frame out of reap_filters()
...
This is easier to read.
2023-08-30 11:53:50 +02:00
Anton Khirnov
82dd4dbe3f
fftools/ffmpeg_filter: sanitize framerate retrieved from the filtergraph
...
Lavfi uses 1/0 to signal unknown/VFR, which should not be passed to
encoders.
2023-08-30 11:53:50 +02:00
Anton Khirnov
6be4a29397
fftools/cmdutils: add error handling to allocate_array_elem()
2023-07-20 20:40:26 +02:00
Anton Khirnov
13ebc9a0a9
fftools/ffmpeg_filter: replace remaining report_and_exit() with error codes
2023-07-20 20:40:26 +02:00
Anton Khirnov
cb8242db8d
fftools/ffmpeg_filter: return error codes from set_channel_layout() instead of aborting
2023-07-20 20:40:26 +02:00
Anton Khirnov
5ba7aa2ce8
fftools/ffmpeg_filter: return error codes from fg_create() instead of aborting
2023-07-20 20:40:26 +02:00
Anton Khirnov
8db96808bc
fftools/ffmpeg_filter: return error codes from choose_pix_fmts() instead of aborting
2023-07-20 20:40:26 +02:00
Anton Khirnov
8815adfe75
fftools/ffmpeg_filter: replace remaining exit_program() with error codes
2023-07-20 20:39:42 +02:00
Anton Khirnov
a52ee1aa47
fftools/ffmpeg_filter: return error codes from init_input_filter() instead of aborting
2023-07-20 20:30:13 +02:00
Anton Khirnov
ab16e324ea
fftools/ffmpeg_filter: return error codes from ofilter_bind_ost() instead of aborting
2023-07-20 20:30:13 +02:00
Anton Khirnov
80a64800ea
fftools/ffmpeg_enc: return errors from enc_frame() instead of aborting
2023-07-20 20:30:13 +02:00
Anton Khirnov
3a89e6d352
fftools/ffmpeg_filter: restrict reap_filters() to a single filtergraph
...
This is more natural, as all except one of its callers require
processing only one filtergraph.
2023-07-20 20:30:13 +02:00
Anton Khirnov
9d44eb8af5
fftools/ffmpeg_filter: stop accessing encoder from pixfmt selection
...
ffmpeg CLI pixel format selection for filtering currently special-cases
MJPEG encoding, where it will restrict the supported list of pixel
formats depending on the value of the -strict option. In order to get
that value it will apply it from the options dict into the encoder
context, which is a highly invasive action even now, and would become a
race once encoding is moved to its own thread.
The ugliness of this code can be much reduced by moving the special
handling of MJPEG into ofilter_bind_ost(), which is called from encoder
init and is thus synchronized with it. There is also no need to write
anything to the encoder context, we can evaluate the option into our
stack variable.
There is also no need to access AVCodec at all during pixel format
selection, as the pixel formats array is already stored in
OutputFilterPriv.
2023-07-20 20:30:13 +02:00
Anton Khirnov
037d364797
fftools/ffmpeg_filter: move "smart" pixfmt selection to ffmpeg_mux_init
...
This code works on encoder information and has no interaction with
filtering, so it does not belong in ffmpeg_filter.
2023-07-20 20:30:04 +02:00
Anton Khirnov
75d0af388f
fftools/ffmpeg_filter: make OutputFilter.filter private
...
It should not be accessed from outside of filtering code.
2023-07-15 11:02:11 +02:00
Anton Khirnov
b295ec31f3
fftools/ffmpeg_filter: only flush vsync code if encoding actually started
...
Otherwise this has no effect.
Will be useful in following commits.
2023-07-15 11:02:11 +02:00
Anton Khirnov
0a6751a78a
fftools/ffmpeg: rework initializing encoders with no frames
...
When no frames were passed from a filtergraph to an encoder, but the
filtergraph is configured (i.e. has output parameters), encoder flush
code will use those parameters to initialize the encoder in a last-ditch
effort to produce some useful output.
Rework this process so that it is triggered by the filtergraph, which
now sends a dummy frame with parameters, but no data, to the encoder,
rather than the encoder reaching backwards into the filter.
This approach is more in line with the natural data flow from filters to
encoders and will allow to reduce encoder-filter interactions in
following commits.
This code is tested by fate-adpcm-ima-cunning-trunc-t2-track1, which (as
confirmed by Zane) is supposed to produce empty output.
2023-07-15 11:02:11 +02:00
Anton Khirnov
57a42a714b
fftools/ffmpeg_filter: consolidate calling avfilter_graph_set_auto_convert()
...
Do not call it from choose_pix_fmts(), as that function is not supposed
to modify random filtergraph properties.
2023-07-11 19:28:18 +02:00
Anton Khirnov
432399780a
fftools/ffmpeg_filter: make OutputFile.{formats,ch_layouts,sample_rates} private
...
They are not used outside of the filtering code.
2023-07-11 19:28:18 +02:00
Anton Khirnov
a3ab5bf80d
fftools/ffmpeg_filter: make OutputFile.width,height private
...
They are not used outside of the filtering code.
2023-07-11 19:28:18 +02:00
Anton Khirnov
c19aa9c28f
fftools/ffmpeg_filter: make OutputFile.ch_layout private
...
It is not used outside of the filtering code.
2023-07-11 19:28:18 +02:00
Anton Khirnov
42f3f54cf4
fftools/ffmpeg_filter: make OutputFile.format/sample_rate private
...
They are not used outside of the filtering code.
2023-07-11 19:28:18 +02:00
Anton Khirnov
c9a99ffe51
fftools/ffmpeg_filter: make sure no input or output is bound twice
2023-07-11 19:28:18 +02:00
Anton Khirnov
1617d1a752
fftools/ffmpeg: pass subtitle decoder dimensions to sub2video
...
Restores behavior from before 20cacfe493 .
Eventually this should be handled similarly to audio/video - with a
filtergraph reset or a manual scaler.
2023-06-19 09:48:56 +02:00
Anton Khirnov
88f80977eb
fftools/ffmpeg: use AVFrame to pass subtitles from decoders to filters
...
Allows to use the same buffering code for all media types. Will also be
important for the following commit.
2023-06-19 09:48:56 +02:00
Anton Khirnov
5293adb1a7
fftools/ffmpeg: attach bits_per_raw_sample information to frames
...
This way avoids encoders reaching into filters or decoders for this
information.
2023-06-19 09:48:55 +02:00
Anton Khirnov
1bdd53e2f9
fftools/ffmpeg_filter: make configure_filtergraph() static
...
It is no longer used outside of ffmpeg_filter.
2023-06-19 09:48:55 +02:00
Anton Khirnov
b1a213ab5d
fftools/ffmpeg_filter: reject filtergraphs with zero outputs
...
Nothing useful can be done with them currently.
2023-06-19 09:48:55 +02:00
Anton Khirnov
a7aa05c599
fftools/ffmpeg_filter: add an AVClass to FilterGraph
...
Use it for logging.
2023-06-19 09:48:55 +02:00
Anton Khirnov
568d414074
fftools/ffmpeg: attach filter framerate to frames
...
This way the encoder does not need to reach backward into the filter.
2023-06-05 16:15:04 +02:00
Anton Khirnov
d8c61ba723
fftools/ffmpeg_filter: drop a block disabled since 2012
2023-06-05 16:15:04 +02:00
Anton Khirnov
ad14bdbcfd
fftools/ffmpeg_filter: drop a write-only variable
2023-06-05 16:15:04 +02:00
Anton Khirnov
ba2c791627
fftools/ffmpeg_filter: do not flush encoders on parameter change
...
It makes no sense to do so.
2023-05-31 16:20:19 +02:00
Anton Khirnov
2674532eee
fftools/ffmpeg_filter: constify the argument of filtergraph_is_simple()
2023-05-31 16:20:19 +02:00
Anton Khirnov
3bfc2c589a
fftools/ffmpeg_filter: make InputStream.filter private
...
It is no longer accessed outside of ffmpeg_filter.
2023-05-31 16:20:19 +02:00
Anton Khirnov
5924b70075
fftools/ffmpeg_filter: make ifilter_has_all_input_formats() static
...
It is no longer used outside ffmpeg_filter.
2023-05-31 16:20:19 +02:00
Anton Khirnov
2262df5e8a
fftools/ffmpeg_filter: drop unreachable code
...
Filtergraphs with no inputs are initialized as soon as all their outputs
are bound, so this code should not be reachable.
2023-05-31 16:20:19 +02:00
Anton Khirnov
f8abab673c
fftools/ffmpeg: move sub2video handling to ffmpeg_filter
...
Make all relevant state per-filtergraph input, rather than per-input
stream. Refactor the code to make it work and avoid leaking memory when
a single subtitle stream is sent to multiple filters.
2023-05-31 16:20:19 +02:00