Commit Graph

863 Commits

Author SHA1 Message Date
Jan Ekström
be76a9bd32 ffprobe: expose AVAmbientViewingEnvironment side data in AVFrames 2023-01-13 21:26:27 +02:00
Zhao Zhili
52eb2396d7 fftools/ffmpeg_demux: prefer fd over pipe for seek support
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-11 18:50:36 +08:00
Zhao Zhili
244f3cfbe3 fftools/ffprobe: prefer fd over pipe for seek support
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-11 18:50:36 +08:00
Zhao Zhili
c926140558 fftools/ffplay: prefer fd over pipe for seek support
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-11 18:50:36 +08:00
Zhao Zhili
195ccf7ea8 fftools/ffmpeg_demux: disable stdin interaction for fd protocol
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-11 18:50:36 +08:00
Anton Khirnov
260f391893 fftools/ffmpeg: always generate CFR output when -r is used
Current code may, depending on the muxer, decide to use VSYNC_VFR tagged
with the specified framerate, without actually performing framerate
conversion. This is clearly wrong and against the documentation, which
states unambiguously that -r should produce CFR output for video
encoding.

FATE test changes:
* nuv-rtjpeg: replace -r with '-enc_time_base -1', which keeps the
  original timebase. Output frames are now produced with proper
  durations.
* filter-mpdecimate: just drop the -r option, it is unnecessary
* filter-fps-r: remove, this test makes no sense and actually
  produces broken VFR output (with incorrect frame durations).
2023-01-10 11:49:28 +01:00
Anton Khirnov
7655249f72 fftools/ffmpeg: reindent after previous commit 2023-01-10 11:49:28 +01:00
Anton Khirnov
a848a5a223 fftools/ffmpeg: move video frame dup/drop logic into its own function 2023-01-10 11:49:28 +01:00
Anton Khirnov
5874ca3650 fftools/ffmpeg: rename a variable to be more descriptive 2023-01-10 11:49:28 +01:00
Anton Khirnov
3b21f10639 fftools/ffmpeg: fix stream id in an error message.
Broken in 7ef7a22251
2023-01-10 11:49:28 +01:00
Anton Khirnov
c60941dfaf fftools/ffmpeg: stop using AVCodecContext.sample_rate in decode_audio()
Use the decoded frame's sample_rate instead, which is the authoritative
value.

Drop a now-obsolete check validating AVCodecContext.sample_rate.
2023-01-10 11:49:28 +01:00
Marvin Scholz
ece29ad0dc fftools: use av_dict_get_string
Instead of manually assembling the string, use av_dict_get_string
which handles things like proper escaping too (even though it is
not yet needed here).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Marvin Scholz
f1907faab4 fftools: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Anton Khirnov
becbb22eb0 fftools/ffmpeg: cosmetics
Reindent after previous commit and break/split some lines as
appropriate.
2022-11-28 10:28:14 +01:00
Anton Khirnov
d04ec7efe3 fftools/ffmpeg: remove a useless inner block
adjust_frame_pts_to_encoder_tb() is so small that this serves no useful
purpose.
2022-11-28 10:28:14 +01:00
Anton Khirnov
d60d6d819d fftools/ffmpeg: drop an always-false check 2022-11-28 10:28:14 +01:00
Anton Khirnov
8ee4365ad8 fftools/ffmpeg: only convert video frame pts if we have a frame
Calling adjust_frame_pts_to_encoder_tb() with a NULL frame does not
perform a meaningful action.
2022-11-28 10:28:14 +01:00
Anton Khirnov
617ea07c22 fftools/ffmpeg: call check_recording_time() with actual frame pts
Not its estimated value that will not necessarily be used.
2022-11-28 10:28:14 +01:00
Anton Khirnov
86a71d6b3c fftools/ffmpeg: stop calling adjust_frame_pts_to_encoder_tb() for audio
Almost none of that function's complexity is useful for audio, it can
be replaced by a simple av_rescale_q().
2022-11-28 10:28:14 +01:00
Anton Khirnov
a186360f27 fftools/ffmpeg: set AVFrame.time_base after filtering
Makes it easier to track what timebase are the frame timestamps in and
allows to stop accessing filters in code that shouldn't deal with
filtering.
2022-11-28 10:28:14 +01:00
Anton Khirnov
d9534ec84e fftools/ffmpeg: move logging filtered frame timestamps
Do it right after the frame is received from the filtergraph. This is a
more logical place for this and will simplify future commits.
2022-11-28 10:28:14 +01:00
Anton Khirnov
2fa2e146cc fftools/ffmpeg: avoid storing full forced keyframe spec
It is not needed after the spec is parsed. Also avoids ugly string
comparisons for each video frame.
2022-11-28 10:28:14 +01:00
Anton Khirnov
334e52e094 fftools/ffmpeg: parse forced keyframes in of_open()
Allows to remove the ugly of_get_chapters() wrapper.
2022-11-28 10:28:14 +01:00
Anton Khirnov
efe4423627 fftools/ffmpeg: store forced keyframe pts in AV_TIME_BASE_Q
Rather than the encoder timebase. Since the times are parsed as
microseconds, this will not reduce precision, except possibly when
chapter times are used and the chapter timebase happens to be better
aligned with the encoder timebase, which is unlikely.

This will allow parsing the keyframe times earlier (before encoder
timebase is known) in future commits.
2022-11-28 10:28:14 +01:00
Anton Khirnov
b1143330c8 fftools/ffmpeg: move force-keyframe-related vars to a separate struct
There are 8 of them and they are typically used together. Allows to pass
just this struct to forced_kf_apply(), which makes it clear that the
rest of the OutputStream is not accessed there.
2022-11-28 10:28:14 +01:00
Anton Khirnov
630fbdcc52 fftools/ffmpeg: stop explicitly closing decoders
It serves no purpose, they will be closed and freed in
avcodec_free_context() called from ist_free().
2022-11-28 10:28:14 +01:00
Anton Khirnov
95af0bcc34 fftools/ffmpeg_mux_init: postpone matching -disposition to streams
Do it in set_dispositions() rather than during stream creation.

Since at this point all other stream information is known, this allows
setting disposition based on metadata, which implements #10015. This
also avoids an extra allocated string in OutputStream that was unused
after of_open().
2022-11-23 10:36:23 +01:00
Anton Khirnov
3da5c60aa9 fftools/ffmpeg: _-prefix variables in MATCH_PER_STREAM_OPT()
Avoids conflicts, e.g. when 'i' is used in the outvar expression.
2022-11-23 10:36:23 +01:00
Anton Khirnov
996fed5235 fftools/ffmpeg: declare loop variables inside loops in transcode_init() 2022-11-23 10:36:23 +01:00
Anton Khirnov
005f4e1caf fftools/ffmpeg: do not assume input streams exist
There can be zero input streams, with input provided by lavfi complex
filtergraphs.
2022-11-23 10:36:23 +01:00
Anton Khirnov
fd8bf8d3b5 fftools/ffmpeg: remove the input_streams global
Replace it with an array of streams in each InputFile. This is a more
accurate reflection of the actual relationship between InputStream and
InputFile.

Analogous to what was previously done to output streams in
7ef7a22251.
2022-11-23 10:36:23 +01:00
Anton Khirnov
86e2ffedfe fftools/ffmpeg_mux_init: simplify inner loop in map_auto_{video,audio}
Skip unusable streams early and do not compute any scores for them.
2022-11-23 10:36:23 +01:00
Anton Khirnov
4c40581614 fftools/ffmpeg: replace OutputStream.source_index with a pointer to InputStream
This is simpler. The indirection via an index exists for historical
reasons that longer apply.
2022-11-23 10:36:23 +01:00
Anton Khirnov
bda06c60fe fftools/ffmpeg: stop inventing fake source information
This code was supposed to affect copying stream dispositions, but it
does not achieve that after bd55552d69, since dispositions are set
earlier.
2022-11-23 10:36:23 +01:00
Anton Khirnov
50ecba7e84 fftools/ffmpeg: drop an arbitrary condition
Encoding init code will currently fall back to a 25fps default when no
framerate is known or specified, but only if there is a known source
input stream. There is no good reason for this condition, so drop it.
2022-11-23 10:36:23 +01:00
Anton Khirnov
9654df1336 fftools/ffmpeg: move freeing an input stream into a separate function 2022-11-23 10:36:23 +01:00
Zhao Zhili
c0c0a5f106 fftools/ffmpeg_demux: set default hwaccel_output_format for mediacodec
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2022-11-21 23:57:10 +08:00
Anton Khirnov
b58264217b fftools/ffmpeg_mux_init: drop an always-false check
It cannot be true since 1959351aec. Effectively reverts 6a3833e141.
2022-11-17 10:52:58 +01:00
Anton Khirnov
13947aff3f fftools/ffmpeg_mux_init: use av_dict_iterate() where appropriate 2022-11-17 10:52:58 +01:00
Anton Khirnov
19e192eae6 fftools/ffmpeg_mux_init: do not call av{codec,format}_get_class() repeatedly 2022-11-17 10:52:58 +01:00
Anton Khirnov
52380a055b fftools/ffmpeg_mux_init: move validating codec avoptions to a separate function 2022-11-17 10:52:58 +01:00
Anton Khirnov
0fb7d111e8 fftools/ffmpeg: move OutputStream.max_frames to MuxStream
It no longer needs to be visible outside of the muxing code.
2022-11-17 10:52:58 +01:00
Anton Khirnov
25620b69e0 fftools/ffmpeg: stop handling max_frames in do_video_out()
Frame limiting is now handled using sync queues. This code prevents the
sync queue from triggering EOF, resulting in unnecessarily many frames
being decoded, filtered, and then discarded.

Found-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2022-11-17 10:52:58 +01:00
Anton Khirnov
6a8145a4b1 fftools/ffmpeg_mux_init: move more code from of_open() to create_streams()
Specificaly, the of_add_attachments() call (which can add attachment
streams to the output) and the check whether the output file contains
any streams. They both logically belong in create_streams().
2022-11-17 10:52:58 +01:00
Anton Khirnov
1b076556c6 fftools/ffmpeg: simplify ost_iter()
The inner loop never goes through more than 1 iteration, and so can be
replaced by an if().

Found-by: Andreas Rheinhardt
2022-11-17 10:52:58 +01:00
Anton Khirnov
822da7a317 fftools/ffmpeg: make demuxing with one file always blocking 2022-11-16 08:41:14 +01:00
Anton Khirnov
c15eb2773a fftools/ffmpeg_[de]mux: constify all uses of OptionsContext 2022-11-16 08:41:14 +01:00
Anton Khirnov
4119480681 fftools/ffmpeg_mux_init: stop using OptionsContext as storage in copy_metadata()
It should be input-only to this code. Will allow making it const in
future commits.
2022-11-16 08:41:14 +01:00
Anton Khirnov
3c7dd5ed37 fftools/ffmpeg_mux_init: drop a duplicated block in copy_metadata()
It does the same thing as the block right below it.
2022-11-16 08:41:14 +01:00
James Almer
b119b3da1e fftools/ffprobe: support 2D arrays in print_list_fmt()
Should fix undefined behavior.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-11-15 23:18:48 -03:00
Derek Buitenhuis
d1366c4167 fftools/ffprobe: Loop over correct number of streams when flushing decoders
Some formats like FLV can dynamically add streams during packet reading.
FFprobe does check for this and reallocates the global stream info, but does
not reallocate InputFrame's streams and decoders when this happens, which,
as a result, could have caused flushing to occur on an out of bounds stream
index, since the flush loop iterates over fmt_ctx's nb_streams, and not
ifile's, despite using ifile's streams.

This fixes an out of bounds read and segfult.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2022-11-07 16:13:45 +00:00
Gyan Doshi
5ccd4d3060 ffmpeg: fix implementation of updated input start time
The current adjustment of input start times just adjusts the tsoffset.
And it does so, by resetting the tsoffset to nullify the new start time.
This leads to breakage of -copyts, ignoring of input_ts_offset, breaking
of -isync as well as breaking wrap correction.

Fixed by taking cognizance of these parameters, and by correcting start times
just before sync offsets are applied.
2022-11-03 14:38:42 +05:30
Gyan Doshi
93faba449c ffmpeg: shift start time correction to ffmpeg_opt
In preparation for applying start time correction that accounts for all
factors such as copyts, input_ts_offset ..etc
2022-11-03 14:38:24 +05:30
Anton Khirnov
7aa5ea237f fftools/ffmpeg_demux: stop modifying OptionsContext
It should be input-only to this code.
2022-10-25 11:13:03 +02:00
Anton Khirnov
0d821edb40 fftools/ffmpeg_mux_init: stop modifying OptionsContext.*_disable
The current code will override the *_disable fields (set by -vn/-an
options) when creating output streams for unlabeled complex filtergraph
outputs, in order to disable automatic mapping for the corresponding
media type.

However, this will apply not only to automatic mappings, but to manual
ones as well, which should not happen. Avoid this by adding local
variables that are used only for automatic mappings.
2022-10-25 11:12:22 +02:00
Anton Khirnov
69da53ade9 fftools/ffmpeg_mux_init: move code creating streams into a new function
Makes it easy to see where all the streams are created. Will also be
useful in the following commit.
2022-10-25 11:12:05 +02:00
Anton Khirnov
006df0b6fe fftools/ffmpeg_mux_init: stop modifying some OptionsContext fields
Specifically recording_time and stop_time - use local variables instead.
OptionsContext should be input-only to this code. Will allow making it
const in future commits.
2022-10-25 11:11:35 +02:00
Anton Khirnov
ccab823559 fftools/ffmpeg_mux_init: constify metadata specifier arguments 2022-10-25 11:04:42 +02:00
Anton Khirnov
aa0ce91f57 fftools/ffmpeg_mux_init: avoid modifying OptionsContext.chapters_input_file
Use a local variable instead. This will allow making OptionsContext
const in future commits.
2022-10-25 11:04:42 +02:00
Anton Khirnov
5ccc151bf2 fftools/ffmpeg: factor out copying metadata/chapters from of_open()
This code shares variables like OptionsContext.metadata_*_manual, so it
makes sense to group it together.
2022-10-25 11:04:42 +02:00
Anton Khirnov
21ef1f2cec fftools/ffmpeg_demux: log when the demuxer thread terminates
Similar to what is done for muxing, may be useful for debugging.
2022-10-25 11:04:42 +02:00
Anton Khirnov
5c1a096d02 fftools/ffmpeg: move nb_streams_warn from InputFile to Demuxer
It is private to the demuxer and do not need to be visible outside of
it.
2022-10-25 11:04:42 +02:00
Anton Khirnov
d8f7ce38da fftools/ffmpeg_demux: do not log to the demuxer context
Only the demuxer itself is supposed to do that.
2022-10-25 11:04:42 +02:00
Anton Khirnov
541104f3a3 fftools/ffmpeg: move duration/time_base from InputFile to Demuxer
They are private to the demuxer and do not need to be visible outside of
it.
2022-10-25 11:04:42 +02:00
Anton Khirnov
5bc1f177d3 fftools/ffmpeg: move threading fields from InputFile to Demuxer
They are private to the demuxer and do not need to be visible outside of
it.
2022-10-25 11:04:42 +02:00
Anton Khirnov
c20977c4e0 fftools/ffmpeg: drop free_input_threads()
Stop demuxer threads in ifile_close() instead. Simplifies the demuxer
API.
2022-10-25 11:04:42 +02:00
Anton Khirnov
295848bacb fftools/ffmpeg: move closing the input file into a separate function
For now this is just closing the format context and freeing InputFile,
but will contain more in the future.
2022-10-25 11:04:42 +02:00
Anton Khirnov
09cd147dcc fftools/ffmpeg: drop init_input_threads()
Start threads implicitly when ifile_get_packet() is called. Simplifies
the demuxer API.
2022-10-25 11:04:42 +02:00
Anton Khirnov
6975320506 fftools/ffmpeg_demux: add demuxer private data
Move InputFile.loop into it.
2022-10-25 11:04:42 +02:00
Anton Khirnov
78efefa9a5 fftools/ffmpeg_opt: move opening input files to ffmpeg_demux.c
This is similar to what was done before for output files and will allow
introducing demuxer-private state in future commits

Unlike for muxing, the code is moved to existing ffmpeg_demux.c rather
than to a new file. The reason is just file size - the demuxing code is
much smaller than muxing.
2022-10-25 11:04:42 +02:00
Anton Khirnov
874a6f2090 fftools/ffmpeg: set thread names 2022-10-24 02:00:31 +02:00
Anton Khirnov
4cfffdd551 fftools/ffmpeg: rename read_file() to avoid conflict with libass
libass defines a non-static read_file() symbol, which causes conflicts
with static linking.
2022-10-21 10:13:16 +02:00
Jan Ekström
b9058765d7 ffmpeg: Deprecate display rotation override with a metadata key
Now that we have proper options for defining display matrix
overrides, this should no longer be required.

fftools does not have its own versioning, so for now the define is
just set to 1 and disables the functionality if set to zero.
2022-10-19 11:53:52 +02:00
Jan Ekström
c889248647 ffmpeg: Add display_{rotation, hflip, vflip} options
This enables overriding the rotation as well as horizontal/vertical
flip state of a specific video stream on the input side.

Additionally, switch the singular test that was utilizing the rotation
metadata to instead override the input display rotation, thus leading
to the same result.
2022-10-19 11:53:52 +02:00
Andreas Rheinhardt
ff2c37d449 fftools/ffmpeg_opt: Move stuff only used by ffmpeg_mux_init to it
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-18 14:19:11 +02:00
Anton Khirnov
c5d7b6f49b fftools/ffmpeg_mux: move muxing queue fields from OutputStream to MuxStream
They are private to the muxer and do not need to be visible outside of
it.
2022-10-18 14:19:11 +02:00
Anton Khirnov
f0cd68eea0 fftools/ffmpeg_mux: move bsf_ctx from OutputStream to MuxStream
It is private to the muxer and does not need to be visible outside of
it.
2022-10-18 14:19:11 +02:00
Anton Khirnov
2266e04834 fftools/ffmpeg_mux: embed OutputStream in a MuxStream
This is now possible since OutputStream is a child of OutputFile and the
code allocating it can access MuxStream. Avoids the overhead and extra
complexity of allocating two objects instead of one.

Similar to what was previously done for OutputFile/Muxer.
2022-10-18 14:19:11 +02:00
Anton Khirnov
709b47f8a4 fftools/ffmpeg: free output streams in of_close()
Output streams are now children of OutputFile, so it makes more sense to
free them there.
2022-10-18 14:19:11 +02:00
Anton Khirnov
fe304c0694 fftools/ffmpeg: remove a cleanup block at the end of transcode()
Some of it is already duplicated in ost_free() - those parts can be just
dropped. The rest is moved to ost_free(), as it properly belongs there.
2022-10-18 14:19:07 +02:00
Anton Khirnov
7ef7a22251 fftools/ffmpeg: remove the output_streams global
Replace it with an array of streams in each OutputFile. This is a more
accurate reflection of the actual relationship between OutputStream and
OutputFile. This is easier to handle and will allow further
simplifications in future commits.
2022-10-18 13:57:43 +02:00
Anton Khirnov
0baed07f74 fftools/ffmpeg_mux_init: pass Muxer to new_output_stream()
And intermediate functions. Will be useful in the following commit.
2022-10-18 13:57:43 +02:00
Anton Khirnov
18d96e8703 fftools/ffmpeg: reindent after previous commit 2022-10-18 13:57:43 +02:00
Anton Khirnov
2dcedd9af8 fftools/ffmpeg: move freeing an output stream into a separate function 2022-10-18 13:57:43 +02:00
Anton Khirnov
9f9bf8703b fftools/ffmpeg: move init_output_bsfs() to ffmpeg_mux
Bitstream filtering is done as a part of muxing, so this is the more
proper place for this.
2022-10-18 13:57:43 +02:00
Anton Khirnov
ee0a900e58 fftools/ffmpeg_mux: move sq_mux from OutputFile to Muxer
It is internal to ffmpeg_mux* and does not need to be visible to other
code.
2022-10-18 13:57:43 +02:00
Anton Khirnov
d6195c88e2 fftools/ffmpeg_mux: inline mux_free() into of_close()
mux_free() is no longer called from anywhere else.
2022-10-18 13:57:43 +02:00
Anton Khirnov
36ce335d46 fftools/ffmpeg_mux: inline of_muxer_init() into of_open()
A separate muxer init is no longer necessary, now that of_open() has
access to Muxer.
2022-10-18 13:57:43 +02:00
Anton Khirnov
a55ca682e2 fftools/ffmpeg_mux: allocate sq_pkt in setup_sync_queues()
This is now possible since setup_sync_queues() can interact with Muxer.
2022-10-18 13:57:43 +02:00
Anton Khirnov
65d106933a fftools/ffmpeg_mux: embed OutputFile in a Muxer
This is now possible since the code allocating OutputFile can see
sizeof(Muxer). Avoids the overhead and extra complexity of allocating
two objects instead of one.

Similar to what is done e.g. for AVStream/FFStream in lavf.
2022-10-18 13:57:43 +02:00
Anton Khirnov
24098c6c8d fftools/ffmpeg_mux: move Muxer and MuxStream to a new header
This will allow ffmpeg_mux_init.c to work with these structs.
2022-10-18 13:57:43 +02:00
Anton Khirnov
18d6c07267 fftools/ffmpeg_opt: move opening output files into a new file
ffmpeg_opt.c currently contains code for
- parsing the options provided on the command line
- opening and initializing input files based on these options
- opening and initializing output files based on these options

The code dealing with each of these is for the most part disjoint, so it
makes sense to move them to separate files. Beyond reducing the quite
considerable size of ffmpeg_opt.c, this will also allow exposing muxer
internals (currently private to ffmpeg_mux.c) to the initialization
code, thus removing the awkward separation currently in place.
2022-10-18 13:57:42 +02:00
Anton Khirnov
965bff37b6 fftools/ffmpeg: move some stream initialization code to ffmpeg_mux
The code in question is muxing-specific and so belongs there. This will
allow make some objects private to the muxer in future commits.
2022-10-18 13:57:42 +02:00
Anton Khirnov
731246ae8f fftools/ffmpeg_mux: drop the of_ prefix from of_submit_packet()
This function is now static.
2022-10-18 13:57:42 +02:00
Anton Khirnov
a7028d7fa8 fftools/ffmpeg_mux: rename submit_packet() to thread_submit_packet()
This is more descriptive, and the submit_packet() name will be reused in
following commits.
2022-10-18 13:57:42 +02:00
Anton Khirnov
d579a70291 fftools/ffmpeg: move output_packet() to ffmpeg_mux
This function is common to both transcoding and streamcopy, so it
properly belongs into the muxing code.
2022-10-18 13:57:42 +02:00
Anton Khirnov
072e3f710e fftools/ffmpeg_mux: do not unref a NULL packet
The packet submitted to of_submit_packet() may be NULL to signal EOF.
2022-10-18 13:57:42 +02:00
Marvin Scholz
fed841f6f9 fftools/ffmpeg_opt: Use av_err2str
This simplifies the code as there is no other place the error buffer
is needed, so the av_err2str helper macro can be used.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-10-14 12:19:13 +02:00
Marvin Scholz
88635c7f95 fftools/ffprobe: Use av_err2str
av_err2str which is a wrapper for av_strerror already calls
strerror_r if available and if not has a fallback for the other
error codes that would be handled by that, so manually calling
strerror again if it fails is not necessary.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-10-14 12:19:13 +02:00
Marvin Scholz
3eab2c1af1 fftools/cmdutils: Use av_err2str
av_err2str which is a wrapper for av_strerror already calls
strerror_r if available and if not has a fallback for the other
error codes that would be handled by that, so manually calling
strerror again if it fails is not necessary.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-10-14 12:19:13 +02:00
Marvin Scholz
3ce1616106 ffmpeg: Make find_stream_info behave like a normal per-file option
Currently it would essentially change the find_stream_info setting for
the file it was specified for and all following files, which is unusual
and somewhat unexpected behaviour for a per-file option and not even
documented to behave like this.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-10-13 10:19:13 +02:00
Anton Khirnov
044d70736e fftools/ffmpeg: move some code from init_output_stream() to init_output_stream_encode()
The code is subtitle-encoding-specific, so this is a more appropriate
place for it.
2022-10-04 11:55:03 +02:00
Anton Khirnov
29188f9c62 fftools/ffmpeg: rename OutputStream.sync_opts to next_pts
The current name is confusing.
2022-10-04 11:55:03 +02:00
Anton Khirnov
3c0f532cbc fftools/ffmpeg: pass the timestamp to check_recording_time()
Stop setting OutputStream.sync_opts for subtitle encoding, as it is now
unused.
2022-10-04 11:55:03 +02:00
Anton Khirnov
69f770f77c fftools/ffmpeg: stop setting OutputStream.sync_opts for streamcopy
It is not used for anything.
2022-10-04 11:55:03 +02:00
Anton Khirnov
76678b7137 fftools/ffmpeg: drop never-set OutputStream.first_pts 2022-10-04 11:55:03 +02:00
Anton Khirnov
5188aeaffb fftools/ffmpeg: cosmetics
Reindent after previous commit, apply some style fixes.
2022-10-04 11:55:03 +02:00
Anton Khirnov
c75be06148 fftools/ffmpeg: move forced keyframe processing into its own function 2022-10-04 11:55:03 +02:00
Anton Khirnov
7a994c8701 fftools/ffmpeg: drop always-true conditions
in_picture->pts cannot be AV_NOPTS_VALUE, as it is set to ost->sync_opts
a few lines above. ost->sync_opts is never AV_NOPTS_VALUE.
2022-10-04 11:55:03 +02:00
Anton Khirnov
3d86a13b47 fftools/ffmpeg: drop the -async option
It has been deprecated in favor of the aresample filter for almost 10
years.

Another thing this option can do is drop audio timestamps and have them
generated by the encoding code or the muxer, but
- for encoding, this can already be done with the setpts filter
- for muxing this should almost never be done as timestamp generation by
  the muxer is deprecated, but people who really want to do this can use
  the setts bitstream filter
2022-10-04 11:55:03 +02:00
Marvin Scholz
cc48454561 fftools/ffmpeg: Remove unused frame_bits_per_raw_sample variable
Unused since the bits_per_raw_sample was made a per-output-stream
option in 4258893961

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-10-02 11:59:25 +02:00
Marvin Scholz
793953f44a fftools/ffmpeg: Remove unused do_deinterlace variable
Unused since removal of the -deinterlace option in
d013453caa

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-10-02 11:59:25 +02:00
Marvin Scholz
1c8e95bd99 fftools: Remove unused videotoolbox_init declaration
The code that defined videotoolbox_init was removed in
4b54818981

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-10-02 11:59:25 +02:00
Marvin Scholz
d2cf6d1665 fftools: Remove unused qsv declarations
The code that uses these was removed in
ecee3b07cd

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-10-02 11:59:25 +02:00
Derek Buitenhuis
f5cd00bf52 ffprobe: Check for invalid matrix error when printing rotation
av_display_rotation_get will return NAN when the display matrix is invalid,
which would end up printing NAN as an integer in the rotation field. This
is poor for multiple reasons:

* Users of ffprobe have no way of discerning "valid but ugly rotation from
  display matrix" from "invalid display matrix".
* It can have unintended consequences on some platforms, such as Linux x86_64,
  where NAN is equal to INT64_MIN, which, for example, when printed as JSON,
  which uses floating point for all numbers, can end up as invalid JSON or wit
  a number that cannot be reserialized as an integer at all.

Since NAN is av_display_rotation_get's error case, just print 0 (no rotation)
when that happens.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2022-09-27 17:37:21 +01:00
Zhao Zhili
686096739b fftools/ffmpeg_filter: configure min_hard_comp unconditionally
There are two issues here. Firstly, the floating-point comparison
is always true. Seconly, the code depends on the default value of
min_hard_comp implicitly, which can be dangerous.

Partially fixes ticket 9859.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2022-09-23 19:58:08 +08:00
Zhao Zhili
af919cf780 fftools/ffmpeg: fix av_display_rotation_set() type cast
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2022-09-22 20:03:57 +08:00
Wang Yaqiang
3f0fac9303 fftools/ffplay: fix rotation incorrect when frame contains the displaymatrix
For example, if the jpeg contains exif information
and the rotation direction is included in the exif,
the displaymatrix will be set on the side_data of the frame when decoding.
However, when ffplay is used to play the image,
only the side data in the stream will be determined.
It does not check whether the frame also contains rotation information,
causing it to play in the wrong direction

Reviewed-by: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Wang Yaqiang <wangyaqiang03@kuaishou.com>
2022-09-15 16:16:16 +08:00
James Almer
130483449e fftools/opt_common: check the return value of av_hwdevice_get_type_name before printing it
It may be NULL, as is the case for D3D11VA_VLD.

Running "ffmpeg -h decoder=h264" on a Windows build

Before:
Decoder h264 [H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10]:
    Supported hardware devices: dxva2 (null) d3d11va cuda

After:
Decoder h264 [H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10]:
    Supported hardware devices: dxva2 d3d11va cuda

Signed-off-by: James Almer <jamrial@gmail.com>
2022-09-14 09:54:19 -03:00
Andreas Rheinhardt
5c16df1b92 fftools/ffprobe: Report initial and trailing padding
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-05 20:32:12 +02:00
Andreas Rheinhardt
90aa2a88f9 fftools/ffmpeg_opt: Check creation of new program
Fixes Coverity issue #1512413.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-01 14:26:01 +02:00
Andreas Rheinhardt
601faaed92 fftools: Use report_error_then_exit_program() for allocation failures
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-01 14:26:00 +02:00
Andreas Rheinhardt
e157b21a90 fftools/cmdutils: Add function to report error before exit
This is designed to improve and unify error handling for
allocation failures for the many (often small) allocations that we have
in the fftools. These typically either don't return an error message
or an error message that is not really helpful to the user
and can be replaced by a generic error message without loss of
information.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-01 14:21:56 +02:00
Anton Khirnov
4fce3bab64 fftools/ffmpeg: use a separate counter for encoded packet data size
update_video_stats() currently uses OutputStream.data_size to print the
total size of the encoded stream so far and the average bitrate.
However, that field is updated in the muxer thread, right before the
packet is sent to the muxer. Not only is this racy, but the numbers may
not match even if muxing was in the main thread due to bitstream
filters, filesize limiting, etc.

Introduce a new counter, data_size_enc, for total size of the packets
received from the encoder and use that in update_video_stats(). Rename
data_size to data_size_mux to indicate its semantics more clearly.

No synchronization is needed for data_size_mux, because it is only read
in the main thread in print_final_stats(), which runs after the muxer
threads are terminated.
2022-08-29 15:42:11 +02:00
Anton Khirnov
0dd7347963 fftools/ffmpeg: drop OutputStream.fps_mode
It is only used within new_video_stream(), so make it a local variable
there.
2022-08-29 15:42:11 +02:00
Anton Khirnov
d0f767f81f fftools/ffmpeg: drop OutputStream.enc
It is either equal to OutputStream.enc_ctx->codec, or NULL when enc_ctx
is NULL. Replace the use of enc with enc_ctx->codec, or the equivalent
enc_ctx->codec_* fields where more convenient.
2022-08-29 15:42:11 +02:00
Anton Khirnov
4a4a206304 fftools/ffmpeg_filter: remove an always-true check
ost->enc is always non-NULL here, since
- this code is never called for streamcopy
- opening the output file will fail if an encoder cannot be found, so
  filters are never initialized
2022-08-29 15:42:11 +02:00
Anton Khirnov
c97bb940c2 fftools/ffmpeg_filter: remove an always-false check
This code cannot be triggered, since after 90944ee3ab opening the
output file will abort if an encoder cannot be found and streamcopy was
not explicitly requested.
2022-08-29 15:42:11 +02:00
Anton Khirnov
7c8737548f fftools/ffmpeg: remove a stale extern declaration
Forgotten in 8cbf229c94
2022-08-29 15:42:11 +02:00
Anton Khirnov
8d26a21bf6 fftools/ffmpeg: stop accessing av_stream_get_parser() from the main thread
It races with the demuxing thread. Instead, send the information along
with the demuxed packets.

Ideally, the code should stop using the stream-internal parsing
completely, but that requires considerably more effort.

Fixes races, e.g. in:
- fate-h264-brokensps-2580
- fate-h264-extradata-reload
- fate-iv8-demux
- fate-m4v-cfr
- fate-m4v
2022-08-29 15:42:11 +02:00
James Almer
f5a663f2a9 fftools/ffmpeg_opt: try to propagate the requested output channel layout
Don't silently replace it with the default layout for the amount of channels
from the requested layout.

Should fix ticket #9869

Signed-off-by: James Almer <jamrial@gmail.com>
2022-08-23 13:03:56 -03:00
Anton Khirnov
f23e3ce858 fftools/ffmpeg: call av_guess_frame_rate() when opening the file
It is currently called when configuring the filter, which races with the
demuxer thread.
2022-08-22 11:36:43 +02:00
Gyan Doshi
d5544f6457 ffprobe: restore reporting error code for failed inputs
c11fb46731 led to a regression whereby the return code for missing
input or input probe is overridden by writer close return code and
hence not conveyed in the exit code.
2022-08-17 16:46:05 +05:30
Anton Khirnov
ab31473830 fftools/ffmpeg: store a separate copy of input codec parameters
Use it instead of AVStream.codecpar in the main thread. While
AVStream.codecpar is documented to only be updated when the stream is
added or avformat_find_stream_info(), it is actually updated during
demuxing. Accessing it from a different thread then constitutes a race.

Ideally, some mechanism should eventually be provided for signalling
parameter updates to the user. Then the demuxing thread could pick up
the changes and propagate them to the decoder.
2022-08-16 11:09:09 +02:00
Timo Rothenpieler
f85e0673c3 fftools: add DPI awareness manifest
Some filters, like gdigrab, rely on this to be set to see and report
proper dimensions.
2022-08-13 14:42:52 +02:00
Anton Khirnov
6ded80af92 fftools/ffmpeg: move packet timestamp processing to demuxer thread
Discontinuity detection/correction is left in the main thread, as it is
entangled with InputStream.next_dts and related variables, which may be
set by decoding code.

Fixes races e.g. in fate-ffmpeg-streamloop after
aae9de0cb2.
2022-08-13 12:41:05 +02:00
Anton Khirnov
3b2beceae1 fftools/ffmpeg: use a separate variable for discontinuity offset
This will allow to move normal offset handling to demuxer thread, since
discontinuities currently have to be processed in the main thread, as
the code uses some decoder-produced values.
2022-08-13 12:41:05 +02:00
Anton Khirnov
ca38fe927e fftools/ffmpeg: simplify conditions in ts_discontinuity_process 2022-08-13 12:41:05 +02:00
Anton Khirnov
aa6d4a53e3 fftools/ffmpeg: move inter-stream ts discontinuity handling to ts_discontinuity_process() 2022-08-13 12:41:05 +02:00
Anton Khirnov
e2d784a5b7 fftools/ffmpeg: move timestamp discontinuity correction out of process_input() 2022-08-13 12:41:05 +02:00
Anton Khirnov
274c8d5882 fftools/ffmpeg: pre-compute the streamcopy start pts before transcoding starts
InputFile.ts_offset can change during transcoding, due to discontinuity
correction. This should not affect the streamcopy starting timestamp.

Cf. bf2590aed3
2022-08-13 12:41:05 +02:00
Anton Khirnov
86e9cef77b fftools/ffmpeg: move stream-dependent starttime correction to transcode_init()
Currently this code is located in the discontinuity handling block,
where it does not belong.
2022-08-13 12:41:05 +02:00
Anton Khirnov
ee2092ddec fftools/ffmpeg_mux: avoid leaking pkt on errors 2022-08-13 12:41:05 +02:00
Anton Khirnov
5d499d3250 fftools/ffmpeg: mark all encode sync queues as done before flushing encoders 2022-08-13 12:41:05 +02:00
Anton Khirnov
a5e025e826 fftools/ffmpeg: move handling corrupt packets to the input thread 2022-08-08 16:20:58 +02:00
Anton Khirnov
61d9f34c70 fftools/ffmpeg_demux: do not store demux packet in the context
Its use is local to input_thread().
2022-08-08 16:20:58 +02:00
Anton Khirnov
de9fb9fba7 fftools/ffmpeg_demux: factorize signalling end of demuxing 2022-08-08 16:20:58 +02:00
Anton Khirnov
aae9de0cb2 fftools/ffmpeg: move -stream_loop handling to the demuxer thread
-stream_loop is currently handled by destroying the demuxer thread,
seeking, then recreating it anew. This is very messy and conflicts with
the future goal of moving each major ffmpeg component into its own
thread.

Handle -stream_loop directly in the demuxer thread. Looping requires the
demuxer to know the duration of the file, which takes into account the
duration of the last decoded audio frame (if any). Use a thread message
queue to communicate this information from the main thread to the
demuxer thread.
2022-08-08 16:20:58 +02:00
Anton Khirnov
b99462cd27 fftools/ffmpeg: move seek_to_start() to ffmpeg_demux.c
Reduces the diff in the following commit.
2022-08-08 16:20:58 +02:00
Anton Khirnov
57d75ca031 fftools/ffmpeg: move get_input_packet() to ffmpeg_demux.c
Also rename it to use the ifile_* namespace.
2022-08-08 16:20:58 +02:00
Anton Khirnov
07da07ddb0 fftools/ffmpeg: report new streams from the input thread
This avoids a potential race with the demuxer adding new streams. It is
also more efficient, since we no longer do inter-thread transfers of
packets that will be just discarded.
2022-08-08 16:20:58 +02:00
Anton Khirnov
9c16310fe5 fftools/ffmpeg: handle dumping input packets in input_thread()
This is a more appropriate place for this.
2022-08-08 16:20:58 +02:00
Anton Khirnov
b1f24afe7e fftools/ffmpeg: drop the 'h' key handling
This undocumented feature runtime-enables dumping input packets. I can
think of no reasonable real-world use case that cannot also be
accomplished in a different way. Keeping this functionality would
interfere with the following commit moving it to the input thread (then
setting the variable would require locking or atomics, which would be
unnecessarily complicated for a feature that probably nobody uses).
2022-08-08 16:20:58 +02:00
Anton Khirnov
7b6622705e fftools/ffmpeg: move the input thread into its own file
It will contain more demuxing-specific code in the future.
2022-08-08 16:20:58 +02:00
Anton Khirnov
c3b8d59d2f fftools/ffmpeg: drop a write-only variable 2022-08-08 16:20:58 +02:00
Anton Khirnov
d8bf53710f fftools/ffmpeg: always read input in a thread
This will be required by the following architecture changes.
2022-08-08 16:20:58 +02:00
Anton Khirnov
cc2b7f4625 fftools/ffmpeg: store the input file index in InputFile
Use it to simplify some code and fix two off-by-one errors.

Similar to what was previously done for OutputFile.
2022-08-08 16:20:58 +02:00
Anton Khirnov
9139ea4c8d fftools/ffmpeg: drop a superfluous stack variable 2022-08-08 16:20:58 +02:00
Anton Khirnov
fee249b30a fftools/ffmpeg: deprecate specifying a sync stream with -map
It has not had any effect whatsoever for over 10 years.
2022-08-08 16:20:58 +02:00
Anton Khirnov
49123dd058 fftools/ffmpeg: remove OutputStream.sync_ist
It is not actually used for anything.
2022-08-08 16:20:58 +02:00
Anton Khirnov
8e092c3eac fftools/ffmpeg: remove OutputStream.encoding_needed
It is unnecessary, as it is always exactly equivalent to !!ost->enc_ctx
2022-08-08 16:20:58 +02:00
Anton Khirnov
80e7feb48b fftools/ffmpeg: remove OutputStream.stream_copy
There are currently three possible modes for an output stream:
1) The stream is produced by encoding output from some filtergraph. This
   is true when ost->enc_ctx != NULL, or equivalently when
   ost->encoding_needed != 0.
2) The stream is produced by copying some input stream's packets. This
   is true when ost->enc_ctx == NULL && ost->source_index >= 0.
3) The stream is produced by attaching some file directly. This is true
   when ost->enc_ctx == NULL && ost->source_index < 0.

OutputStream.stream_copy is currently used to identify case 2), and
sometimes to confusingly (or even incorrectly) identify case 1). Remove
it, replacing its usage with checking enc_ctx/source_index values.
2022-08-08 16:20:58 +02:00
Anton Khirnov
4f2b946c19 fftools/ffmpeg_opt: drop redundant decoder selection
A decoder is already selected above, in choose_decoder().
2022-08-08 16:20:58 +02:00
Anton Khirnov
a1da77bd71 fftools/ffmpeg: stop accessing the decoder context unnecessarily
The same information is available from AVStream.codecpar. This will
allow to stop allocating a decoder unless decoding is actually
performed.
2022-08-08 16:20:58 +02:00
Anton Khirnov
04b340e6b8 fftools/ffmpeg_hw: stop logging to the decoder context
Only the decoder itself should do that. Use NULL as is done by all other
logging code in ffmpeg.
2022-08-08 16:20:58 +02:00
Anton Khirnov
20ba49c1a4 fftools/ffmpeg_opt: move adding metadata out of open_output_file() 2022-08-08 16:20:58 +02:00
Anton Khirnov
7cafea59bc fftools/ffmpeg_opt: move adding programs out of open_output_file() 2022-08-08 16:20:58 +02:00
Anton Khirnov
aad68ab0e0 fftools/ffmpeg_opt: move adding attachments out of open_output_file() 2022-08-08 16:20:58 +02:00
Haihao Xiang
ad67ea9eee ffmpeg_opt: consider HW acceleration method when selecting decoder
Usually a HW decoder is expected when user specifies a HW acceleration
method via -hwaccel option, however the current implementation doesn't
take HW acceleration method into account, it is possible to select a SW
decoder.

For example:
$ ffmpeg -hwaccel vaapi -i av1.mp4 -f null -
$ ffmpeg -hwaccel nvdec -i av1.mp4 -f null -
$ ffmpeg -hwaccel vdpau -i av1.mp4 -f null -
[...]
Stream #0:0 -> #0:0 (av1 (libdav1d) -> wrapped_avframe (native))

libdav1d is selected in this case even if vaapi, nvdec or vdpau is
specified.

After applying this patch, the native av1 decoder (with vaapi, nvdec or
vdpau support) is selected for decoding(libdav1d is still used for
probing format).
$ ffmpeg -hwaccel vaapi -i av1.mp4 -f null -
$ ffmpeg -hwaccel nvdec -i av1.mp4 -f null -
$ ffmpeg -hwaccel vdpau -i av1.mp4 -f null -
[...]
Stream #0:0 -> #0:0 (av1 (native) -> wrapped_avframe (native))

Tested-by: Mario Roy <marioeroy@gmail.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-08-03 11:10:57 +08:00
Haihao Xiang
df5defe15a ffmpeg_opt: select a decoder after getting values for per-stream hwdec options
After applying this patch, the desired HW acceleration method is known
before selecting decoder, so we may take HW acceleration method into
account when selecting decoder for input stream in the next commit

There should be no functional changes in this patch

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-08-03 09:54:20 +08:00
Andreas Rheinhardt
d9cd192ddd fftools/ffmpeg_opt: Fix copyinkf
Broken in 9c2b800203.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-02 09:02:11 +02:00
Anton Khirnov
6b12208646 fftools/ffmpeg_opt: reindent 2022-07-28 16:37:16 +02:00
Anton Khirnov
ac3e461348 fftools/ffmpeg_opt: factor manually mapping streams out of open_output_file() 2022-07-28 16:37:16 +02:00
Anton Khirnov
753195944a fftools/ffmpeg_opt: reindent 2022-07-28 16:37:16 +02:00
Anton Khirnov
85692aeecb fftools/ffmpeg_opt: factor auto-mapping data streams out of open_output_file() 2022-07-28 16:37:16 +02:00
Anton Khirnov
6bd98d9ed8 fftools/ffmpeg_opt: reduce indentation in map_auto_subtitle()
Fix indentation after the previous commit. Also use an early return to
save one extra indentation level.
2022-07-28 16:37:16 +02:00
Anton Khirnov
6ab412ef9c fftools/ffmpeg_opt: factor auto-mapping subtitles out of open_output_file() 2022-07-28 16:37:16 +02:00
Anton Khirnov
ff40d9e8ed fftools/ffmpeg_opt: reduce indentation in map_auto_audio()
Fix indentation after the previous commit. Also use an early return to
save one extra indentation level.
2022-07-28 16:37:16 +02:00
Anton Khirnov
b898dc8934 fftools/ffmpeg_opt: factor auto-mapping audio out of open_output_file() 2022-07-28 16:37:16 +02:00
Anton Khirnov
74176f3cd6 fftools/ffmpeg_opt: reduce indentation in map_auto_video()
Fix indentation after the previous commit. Also use an early return to
save one extra indentation level.
2022-07-28 16:37:16 +02:00
Anton Khirnov
1a464efae3 fftools/ffmpeg_opt: factor auto-mapping video out of open_output_file() 2022-07-28 16:37:16 +02:00
Anton Khirnov
ecfdab20e4 fftools/ffmpeg: do not log to the decoder context
That should only be done from inside the decoder. Log to NULL instead,
as is the current convention in ffmpeg.
2022-07-28 16:37:16 +02:00
Anton Khirnov
d6cbc04229 fftools/ffmpeg_mux: move some functions closer to their only callers 2022-07-28 16:37:16 +02:00
Anton Khirnov
df5ea28b3c fftools/ffmpeg_filter: drop a block commented out since 2012
Since the option it relates to is deprecated, it is highly unlikely to
become useful.
2022-07-28 16:37:16 +02:00
Anton Khirnov
98ece428e3 fftools/ffmpeg: deprecate the -map_channel option
It is now entirely redundant with audio filters, and is in fact
implemented by setting up a 'pan' filter instance.
2022-07-28 16:37:16 +02:00
Anton Khirnov
4f91782fcd fftools/ffmpeg: move guess_input_channel_layout() to ffmpeg_opt.c
That is the only place where it is used. Also make it static.
2022-07-28 16:37:16 +02:00
Anton Khirnov
6353b28042 fftools/ffmpeg: drop unused hwaccel variables 2022-07-28 16:37:16 +02:00
Anton Khirnov
cb045f7f5a fftools/ffmpeg_opt: drop a redundant assignment
The codec type will be set by avcodec_alloc_context3(), there is no
reason to set it manually.
2022-07-28 16:37:16 +02:00
Anton Khirnov
8384d8403f fftools/ffmpeg: stop allocating an encoder context when not encoding 2022-07-28 16:37:16 +02:00
Anton Khirnov
1a378b8274 fftools/ffmpeg: deprecate -psnr
It is entirely redundant with -flags +psnr.
2022-07-28 16:37:16 +02:00
Anton Khirnov
1eae0ee02e fftools/ffmpeg: do not use the encoder context for streamcopy
The streamcopy initialization code briefly needs an AVCodecContext to
apply AVOptions to. Allocate a temporary codec context, do not use the
encoding one.
2022-07-28 16:37:16 +02:00
Anton Khirnov
61e42e04ed fftools/ffmpeg: drop OutputStream.ref_par
It serves no purpose, codec parameters can be written directly to
AVStream.codecpar with the same effect.
2022-07-28 16:37:16 +02:00
Anton Khirnov
8cbf229c94 fftools/ffmpeg: drop the -vol option
It has been deprecated in favor of the volume filter since 2012.
2022-07-28 16:37:16 +02:00
Anton Khirnov
a04d83181a fftools/ffmpeg_filter: do not pass the entire AVCodecContext to choose_pixel_fmt()
It only uses strict_std_compliance, so pass just that value. Makes it
more clear what fields are accessed.
2022-07-28 16:37:16 +02:00
Anton Khirnov
7650d34367 fftools/ffmpeg_filter: remove unused function argument 2022-07-28 16:37:16 +02:00
Anton Khirnov
1cd60d3b35 fftools/ffmpeg: remove an unnecessary avcodec_close() call
No encoders can possibly be opened at this point. And even if some were,
they would be closed in ffmpeg_cleanup().
2022-07-28 16:37:16 +02:00
Anton Khirnov
c2f2dd0296 fftools/ffmpeg: stop accessing the encoder context unnecessarily
The same information is available from AVStream.codecpar. This will
allow to stop allocating an encoder unless encoding is actually
performed.
2022-07-28 16:37:16 +02:00
Anton Khirnov
34cbda3ee1 fftools/ffmpeg: replace AVFrame.pkt_duration with duration
Mistakenly reintroduced in 4740fea7dd.
2022-07-24 08:46:16 +02:00
Andreas Rheinhardt
b0ae5d02f3 fftools/ffmpeg: Zero subtitle packet padding
Fixes uninitialized reads in the sub-lrc-remux test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-23 19:01:44 +02:00
Andreas Rheinhardt
8136ab8e76 fftools/objpool: Don't use return with expression when returning void
Using tail calls with functions returning void is forbidden
(C99/C11 6.8.6.4: "A return statement with an expression shall not appear
in a function whose return type is void.") GCC emits a warning
because of this when using -pedantic: "ISO C forbids ‘return’ with
expression, in function returning void"

Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-23 18:58:35 +02:00