Anton Khirnov
cf121592c5
fftools/ffmpeg_mux_init: do not overwrite OutputStream.frame_rate for encoding
...
The values currently written into it are not used after
enc_open(), so it is better to confine them to that function.
2023-06-05 16:15:04 +02:00
Anton Khirnov
5bea8daa78
fftools/ffmpeg_enc: do not guess frame durations from output framerate
...
There is no reason to expect input frame durations to match output
framerate.
2023-06-05 16:15:04 +02:00
Anton Khirnov
2f92650c5d
fftools/ffmpeg_enc: inline init_encoder_time_base() into its callers
...
The function now reduces to a ternary operator, so it is shorter and
clearer to eliminate it.
2023-06-05 16:15:04 +02:00
Anton Khirnov
93e26a4db7
fftools/ffmpeg: handle -enc_time_base -1 during stream creation
...
There is no reason to postpone it until opening the encoder. Also, abort
when the input stream is unknown, rather than disregard an explicit
request from the user.
2023-06-05 16:15:04 +02:00
Anton Khirnov
58a64e3d54
fftools/ffmpeg_mux_init: only process -enc_time_base if the stream is encoded
...
It has no effect otherwise.
2023-06-05 16:15:04 +02:00
Anton Khirnov
2baae6434b
fftools/ffmpeg_enc: merge two adjacent video-specific blocks
...
There is no meaningful reason for them to be separated.
2023-06-05 16:15:04 +02:00
Anton Khirnov
c8a85d1b2f
fftools/ffmpeg_mux_init: do not overwrite OutputStream.frame_rate for streamcopy
...
The values currently written into it are not used after
streamcopy_init(), so it is better to confine them to that function.
2023-06-05 16:15:04 +02:00
Anton Khirnov
ccf219e361
fftools/ffmpeg_enc: avoid breaking exactly integer timestamps in vsync code
...
The code will currently add a small offset to avoid exact midpoints, but
this can cause inexact results when a float timestamp is exactly
representable as an integer.
Fixes off-by-one in the first frame duration in multiple FATE tests.
2023-06-05 16:15:04 +02:00
Anton Khirnov
c7a05ac117
fftools/ffmpeg_demux: do not set AVCodecContext.framerate
...
For decoding, this field is used by the decoder to export information
to the caller; it does not make sense for the caller to set it.
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
57021a68d9
fftools/ffmpeg_mux: set stream duration after the timebase is certainly known
...
Stop assuming the encoder knows the muxing timebase, which does not
always have to hold (e.g. due to bitstream filters).
2023-06-05 16:15:04 +02:00
Anton Khirnov
ba1141d8a9
fftools/ffmpeg_enc: move nb_frames{dup,drop} globals into OutputStream
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
106167374c
fftools/ffmpeg_mux: flush bsfs immediately on exceeding recoding time
...
Current code marks the output stream as finished and waits for a flush
packet, but that is both unnecessary and suspect, as in theory nothing
should be sent to a finished stream - not even flush packets.
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
f3e0a83e8e
fftools/ffmpeg_enc: stop configuring filters from encoder flush
...
There is no way for a filtergraph to have all input parameters, yet not
be configured, 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
Anton Khirnov
20cacfe493
fftools/ffmpeg: rework setting sub2video parameters
...
Set them in ifilter_parameters_from_dec(), similarly to audio/video
streams. This reduces the extent to which sub2video filters need to be
treated specially.
2023-05-31 16:20:19 +02:00
Anton Khirnov
ea5c39cef6
fftools/ffmpeg: tweak sub2video_heartbeat() arguments
...
This function should not take an InputStream, as it only uses it to get
the InputFile and the timebase. Pass those directly instead and avoid
confusion over dealing with multiple InputStreams.
2023-05-31 16:20:19 +02:00
Anton Khirnov
a6d67b11f5
fftools/ffmpeg_filter: move sub2video subtitle queue to InputFilterPriv
...
This queue should be associated with a specific filtergraph input - if
a subtitle stream is sent to multiple filters then each should have its
own queue.
2023-05-31 16:20:19 +02:00
Anton Khirnov
5d530e3a72
fftools/ffmpeg_dec: move sub2video submission to ffmpeg_filter
...
This code is a sub2video analogue of ifilter_send_frame(), so it
properly belongs to the filtering code.
Note that using sub2video with more than one target for a given input
subtitle stream is currently broken and this commit does not change
that. It will be addressed in following commits.
2023-05-31 16:19:49 +02:00
Anton Khirnov
3d35b73b2a
fftools/ffmpeg: constify AVSubtitle parameters as appropriate
2023-05-31 16:15:47 +02:00
Anton Khirnov
ad4efb9158
fftools/ffmpeg_filter: try to configure filtergraphs earlier
...
When the filtergraph has no inputs, it can be configured immediately
when all its outputs are bound to output streams. This will simplify
treating some corner cases.
2023-05-31 16:15:47 +02:00
Anton Khirnov
7520cd9f07
fftools/ffmpeg_mux_init: move OutputFilter setup code to ffmpeg_filter
...
That is a more appropriate place for it.
2023-05-31 16:15:47 +02:00
Anton Khirnov
87b576135e
fftools/ffmpeg_filter: factor out binding an output stream to OutputFilter
...
While the new function is trivial for now, it will become more useful in
future commits.
2023-05-31 16:15:47 +02:00
Anton Khirnov
dc5864a00c
fftools/ffmpeg_filter: create Input/OutputFilters together with FilterGraph
...
This way the list of filtergraph inputs/outputs is always known after
FilterGraph creation. This will allow treating simple and complex
filtergraphs in a more uniform manner.
2023-05-31 16:15:47 +02:00
Anton Khirnov
a1061d4bdc
fftools/ffmpeg_filter: move some functions higher up
...
Needed by the following commit.
2023-05-31 16:15:47 +02:00
Anton Khirnov
00183880aa
fftools/ffmpeg_filter: decouple allocating InputFilter and binding it to InputStream
...
Will be useful in future commits.
2023-05-31 16:15:47 +02:00
Anton Khirnov
7ea10bfef3
fftools/ffmpeg_filter: store just the link label in OutputFilter
...
Not the entire AVFilterInOut. This is simpler.
2023-05-31 16:15:47 +02:00
Anton Khirnov
da7ae627e1
fftools/ffmpeg_filter: always pass graph description to fg_create()
...
Currently NULL would be passed for simple filtergraphs, which would
make the filter code extract the graph description from the output
stream when needed. This is unnecessarily convoluted.
2023-05-31 16:15:47 +02:00
Anton Khirnov
badf959ed6
fftools/ffmpeg_filter: use a dedicated variable for marking simple filtergraphs
...
Do not use an unrelated graph property, which will change in future
commits.
2023-05-31 16:15:47 +02:00
Anton Khirnov
b56db2956b
fftools/ffmpeg: add logging for creating output streams
2023-05-31 16:15:47 +02:00
Anton Khirnov
eeb7d92ac7
fftools/ffmpeg_mux_init: merge ost_add_from_filter() to ost_add()
...
This way ost_add() knows about the complex filtergraph it is fed from,
which will become useful in future commits.
2023-05-31 16:15:47 +02:00
Anton Khirnov
163e3a299e
fftools/sync_queue: make sure non-limiting streams are not used as queue head
...
A non-limiting stream could mistakenly end up being the queue head,
which would then produce incorrect synchronization, seen e.g. in
fate-matroska-flac-extradata-update for certain number of frame threads
(e.g. 5).
Found-By: James Almer
2023-05-28 10:47:59 +02:00
Anton Khirnov
e9a868e9ee
fftools/sync_queue: add debug logging
2023-05-28 10:47:59 +02:00
Anton Khirnov
4e96a71626
fftools/ffmpeg_demux: log discontinuity warnings to stream context
...
Allows simplifying the log message.
2023-05-28 10:47:59 +02:00
Anton Khirnov
6abb4a28ef
fftools/ffmpeg: add InputStream.index
...
This allows to avoid access to the underlying AVStream in many places.
2023-05-28 10:47:59 +02:00
Anton Khirnov
cad59cccaf
fftools/ffmpeg_dec: move timestamp estimation state to Decoder
...
It is purely internal to decoding.
2023-05-28 10:47:59 +02:00
Anton Khirnov
5b05e9e32a
fftools/ffmpeg_dec: move InputStream.pkt to Decoder
...
It is purely internal to decoding.
2023-05-28 10:47:59 +02:00
Anton Khirnov
dadeb28e25
fftools/ffmpeg_dec: add decoder private data
...
Move InputStream.decoded_frame to it.
Analogous to what has been previously done for all the other major
components.
2023-05-28 10:47:59 +02:00
Anton Khirnov
335688a3d3
fftools/ffmpeg_demux: skip unused/attachment streams in final stats
...
No useful information can be printed for them.
2023-05-28 10:47:59 +02:00
Anton Khirnov
d43ae45de0
fftools/ffmpeg_demux: initialize nb_streams_warn
...
Fixes spurious new-stream warnings for unused streams after
9429624a76107020b5911f8307f366fed386b336
2023-05-28 10:47:59 +02:00
Anton Khirnov
6ee57fd2b6
fftools/ffmpeg_demux: only print demuxing stats if demuxing actually started
...
If the transcoding process never got to reading any packets from this
input then printing stats is just pointless noise.
2023-05-28 10:47:59 +02:00
Anton Khirnov
d9bcbf9200
fftools/ffmpeg: drop outdated comments
2023-05-28 10:47:59 +02:00
Anton Khirnov
ec75b79fe1
fftools/ffmpeg: fail earlier on text/bitmap subtitles mismatch
...
Checking whether the user requested an unsupported conversion between
text and bitmap subtitles can be done immediately when creating the
output stream.
2023-05-28 10:47:59 +02:00
Anton Khirnov
2b3905254e
fftools/ffmpeg_enc: use AVFrame.hw_frames_ctx for encoder hw setup
...
It should be the same as the one that can be extracted from the filter
and does not require access to outside data.
2023-05-28 10:47:59 +02:00