Commit Graph

67 Commits

Author SHA1 Message Date
Carl Eugen Hoyos
26c7f91e66 ffmpeg: Do not print "SDP:" on top of sdp files.
Fixes ticket #7068.
2020-01-27 22:45:06 +01:00
Gyan Doshi
5d82c078ea ffmpeg: don't force source-tracked keyframes for duplicates
Prevents a run of consecutive duplicate frames from all being encoded
as keyframes, when force_key_frames is set to source.
2020-01-05 12:01:46 +05:30
Gyan Doshi
fa3ad7bbc6 ffmpeg: remove premature rescaling of forced_keyframe times
The user-set forced KF times are parsed *after* this deleted
loop and rescaled right after parsing.
2020-01-05 10:55:36 +05:30
Nicolas Gaullier
1fcbaa37e6 fftools/ffmpeg: Reindent after last commit
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-21 15:02:06 +01:00
Nicolas Gaullier
f40fb7963e fftools/ffmpeg: Fix forward CPB props in to out
CPB side_data is copied when stream-copying (see init_output_stream_streamcopy()),
but it shall not be copied when the stream is decoded.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-21 14:46:12 +01:00
Andreas Rheinhardt
6f2a3958cf fftools/ffmpeg: Free swresample dictionary during cleanup
Freeing this was forgotten in ad899522.

Fixes #8315 and #8316.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-10-25 00:22:33 +02:00
Andreas Rheinhardt
223a2c2a60 fftools/ffmpeg: Improve streamcopy
do_streamcopy() has a packet that gets zero-initialized first, then gets
initialized via av_init_packet() after which some of its fields are
oerwritten again with the actually desired values (unless it's EOF): The
side data is copied into the packet with av_copy_packet_side_data() and
if the source packet is refcounted, the packet will get a new reference
to the source packet's data. Furthermore, the flags are copied and the
timestamp related fields are overwritten with new values.

This commit replaces this by using av_packet_ref() to both initialize
the packet as well as populate its fields with the right values (unless
it's EOF again in which case the packet will still be initialized). The
differences to the current approach are as follows:
a) There is no call to a deprecated function (av_copy_packet_side_data())
any more.
b) Several fields that weren't copied before are now copied from the source
packet to the new packet (e.g. pos). Some of them (the timestamp related
fields) may be immediately overwritten again and some don't seem to be
used at all (e.g. pos), but in return using av_packet_ref() allows to forgo
the initializations.
c) There was no check for whether copying side data fails or not. This
has been changed: Now the program is exited in this case.

Using av_packet_ref() does not lead to unnecessary copying of data,
because the source packets are already always refcounted (they originate
from av_read_frame()).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-10-12 13:39:45 +02:00
Gyan Doshi
fa697aa92f ffmpeg: switch to avformat_seek_file for stream_loop
Fixes stream_loop with very short files where seeking is generic index
search
2019-09-05 23:23:11 +05:30
Andreas Hakon
e750dc9de6 libavformat: improve logs with cur_dts
This patch improves the logs when the message "cur_dts is invalid" appears.
If helps to identify which stream generates the trouble,
and the status of the stream.
A lot of users suffers with the message, and the origin varies.
The improved message can help to discover the cause.

Signed-off-by: Andreas Hakon <andreas.hakon@protonmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-04-19 17:14:44 +02:00
Thierry Foucu
0ac3befd47 fftools/ffmpeg: Check if we do have also a filter_complex filter.
Right now, the code check for no filter description, but if we use a
filter_complex, the code will use the AVFrame.duration which could be
wrong in case of using fps filter.

How to reproduce the problem:
ffmpeg -f lavfi -i testsrc=duration=1 -vf fps=fps=50 -vsync 1 -f null -
output 50 frames

ffmpeg -f lavfi -i testsrc=duration=1 -filter_complex fps=fps=50 -vsync 1 -f null -
output 51 frames

With this commit, the same command will always output 50 frames.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-03-28 21:29:20 +01:00
Jan Ekström
3a36b0c4b8 ffmpeg: improve the intra stream discontinuity message
Now it actually tells which stream from which input and of
which type had an absolute DTS discontinuity larger than
dts_delta_threshold.
2018-12-18 21:04:57 +02:00
Carl Eugen Hoyos
698574ac5d ffmpeg: Avoid duplicating Closed Captions when increasing frame rate.
Fixes ticket #7506.
2018-11-27 18:38:09 +01:00
Jun Zhao
1ffac23885 fftools/ffmpeg: delete the unused code.
There are come from 2012 ago and have never been used from this
time.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-11-27 10:45:25 +08:00
Michael Niedermayer
3504004879 fftools/ffmpeg: Repair reinit_filter feature
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-11-16 10:13:42 +01:00
Jun Zhao
e24a754916 fftools/ffmpeg: Indent the code
Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-11-11 09:12:50 +08:00
Jun Zhao
3eccf5be92 fftools/ffmpeg: Put the variable declaration at uppper for block.
move the variable declaration at start of upper for block and
remove the redundant brace.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-11-11 09:12:39 +08:00
Jun Zhao
81f2a9f136 fftools/ffmpeg: Remove the micor like "#if 1"
They are come from 2003 and delete them.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-11-11 09:12:26 +08:00
Marton Balint
f099946faf ffmpeg: log corrupted packets and frames
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-10-14 23:52:41 +02:00
Marton Balint
6e6ecdf44d ffmpeg: check return value of avcodec_parameters_from_context
Fixes Coverity CID 1427273.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-10-09 21:46:28 +02:00
Gyan Doshi
26dc763245 ffmpeg: add correct field for raw pts in -progress report
PTS is in microseconds, so correct field name is out_time_us.

Old field out_time_ms kept for now - will be removed after a suitable transition
period.

Fixes #7345
2018-08-28 10:11:01 +05:30
James Almer
b955a33314 ffmpeg: simplify refcounting packets for the muxing queue
Signed-off-by: James Almer <jamrial@gmail.com>
2018-08-07 18:42:35 -03:00
Marton Balint
da36bcbeb7 ffmpeg: fix -stream_loop with multiple inputs
The input thread needs to be properly cleaned up and re-initalized before we
can start reading again in threaded mode. (Threaded input reading is used when
there is mode than one input file).

Fixes ticket #6121 and #7043.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-07-02 11:58:08 +02:00
Marton Balint
b181cd359b ffmpeg: factorize input thread creation and destruction
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-07-02 11:58:08 +02:00
Gyan Doshi
07987404a8 ffmpeg: make loglevel verbose for frame duration warning 2018-06-28 14:08:51 +05:30
Hans Carlson
a790813739 ffmpeg: Treat subtitles like audio and video for non-monotonic dts.
Fixes ticket #4450.
Fixes ticket #6248.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-06-23 01:06:29 +02:00
Jun Zhao
24be912827 fftools/ffmpeg: Replace the number by macro for bprint init
Replace the number by macro for bprint init.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-06-17 09:59:33 +08:00
Michael Niedermayer
28d33c252e ffmpeg: assert that audio packet duration in process_input_packet() is non negative
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-06-14 18:55:45 +02:00
Michael Niedermayer
16d8b13b3b fftools/ffmpeg: Fallback to duration if sample rate is unavailable
Regression since: af1761f7
Fixes: Division by 0
Fixes: ffmpeg_crash_1

Found-by: Thuan Pham, Marcel Böhme, Andrew Santosa and Alexandru Razvan Caciulescu with AFLSmart
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-06-14 18:55:45 +02:00
Carl Eugen Hoyos
5686c4489a ffmpeg: Fail if the user requested impossible subtitle encoding.
Fixes ticket #7239.
2018-06-09 21:34:27 +02:00
Vishwanath Dixit
146cdf7e4b fftools/ffmpeg: fix for all forced key frames when 'copyts' is enabled
Forced key frames generation functionality was assuming the first PTS
value as zero, but, when 'copyts' is enabled, the first PTS can be any
big number. This was eventually forcing all the frames as key frames.
To resolve this issue, update has been made to use first input pts as
reference pts.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-06-04 22:26:55 +02:00
Tobias Rapp
a150b2e3a0 fftools/ffmpeg: properly initialize output stream field order
Fixes stream field order written by avformat_write_header when "top"
option is specified on the command-line.

Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2018-05-02 08:35:08 +02:00
James Almer
e3866ea20d fftools/ffmpeg: fix mixed code and declarations
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2018-04-30 18:22:51 -03:00
André Camargo
1322b00060 fftools/ffmpeg: change fps progress log message to show two decimal digits
Useful when transcoding videos at 29.97 fps because delivers a more accurate result for monitoring.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-04-28 18:08:52 +02:00
Mark Wachsler
9d75354963 fftools/ffmpeg: Add system time and real time to benchmarking.
The -benchmark and -benchmark_all options now show user, system, and real time,
instead of just user time.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-04-28 18:08:52 +02:00
Timo Teräs
94d831f388 ffmpeg: allow setting attached_pic disposition
This is used to signal that image should be stored in metadata
as cover image.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-04-04 19:09:28 +02:00
Josh de Kock
89029bd2c7 lav*,tests: remove several register_all calls
avdevice_register_all() is still required to register devices into
lavf (this is required due to lavd being somewhat of a hack).

Signed-off-by: Josh de Kock <josh@itanimul.li>
2018-04-02 03:26:22 +01:00
Jan Ekström
e760c12aee ffmpeg: prevent premature EOF in sub2video with nullptr AVSubtitles
With certain types of input and the filter chain getting re-initialized
or re-configured, multiple nullptr AVSubtitles can get pushed into
sub2video_update() in a row from sub2video_heartbeat.

This causes end_pts, and on the next round pts, to become INT64_MAX,
latter of which signals EOF in framesync, leading to complete loss of
subtitles from that point on.

Thus, check that the sub2video.end_pts is smaller than INT64_MAX
in a similar fashion to sub2video_flush before sending out the
nullptr AVSubtitle. This keeps premature EOFs from happening in
framesync and the subtitle overlay is kept past the filter chain
re-initializations/configurations.
2018-04-01 13:56:31 +03:00
Carl Eugen Hoyos
11f8f9547d fftools/ffmpeg: Remove an unused variable.
Fixes a warning:
fftools/ffmpeg.c:2201:22: warning: unused variable 'fg'
2018-03-30 12:01:58 +02:00
Marton Balint
0031eab61c ffmpeg: do not finish output streams manually on eof even if no input is provided
The generic code should be able to finish the streams just fine initializing
and flushing the filters and codecs properly.

Fixes the following command:

ffmpeg -f lavfi -i "testsrc=d=0.1[out0];aevalsrc=0:d=0[out1]" -af apad -shortest -f framecrc -

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-29 00:07:39 +02:00
Marton Balint
60c9a25530 ffmpeg: fallback to codecpar parameters on input filter eof
Fixes ticket #6854 and the following simpler case:

ffmpeg -f lavfi -i testsrc=d=1 -f lavfi -i testsrc=d=0 -filter_complex overlay -f null none

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-29 00:07:39 +02:00
James Almer
231a73308f ffmpeg: pass reference counted packet on codec copy when possible
Should prevent unnecessary copy of data in cases where new references
to the packet are created within the muxer or a bitstream filter.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2018-03-23 22:05:25 -03:00
James Almer
f5ceb15bb6 ffmpeg: remove dead call to av_parser_change()
It's been a noop for years, and it's been argued that in-band headers
should not be forcedly removed without the user's explicit request.

Also, as the FIXME line stated, this is a job for a bitstream filter
like extract_extradata, remove_extradata, dump_extradata, and
filter_units.

Signed-off-by: James Almer <jamrial@gmail.com>
2018-03-23 22:03:22 -03:00
Gyan Doshi
8ad83044b4 ffmpeg.c - drain all decoded frames during stream_loop flush
When a decoded stream is being looped, after each post-EOF rewind,
decoders are flushed in seek_to_start(). This only drains 1 frame, and
thus the output has a few frames missing at the tail of each iteration
except the last.

With this patch, process_input is looped till process_input_packet
reaches EOF.

Fixes #7081

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-03-20 22:59:40 +01:00
Tobias Rapp
69995a94d8 fftools/ffmpeg: update print_report to use AVBPrint API
Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2018-03-05 09:24:55 +01:00
Tobias Rapp
a194e9c415 fftools/ffmpeg: fix progress log message in case pts is not available
Also fixes sign prefix for progress report.

Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2018-03-05 09:24:40 +01:00
Tobias Rapp
fa0c9d69d3 fftools/ffmpeg: replace call to av_strerror with av_err2str
Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2018-02-27 08:34:35 +01:00
Tomas Härdin
5caae27979 Don't complain about codec2's 700 bit/s modes in ffmpeg.c 2018-02-24 17:06:31 +01:00
Aman Gupta
4f40d64e00 avformat/mpegts: set AV_DISPOSITION_DEPENDENT for mix_type=0 supplementary audio
Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-02-23 13:47:29 -08:00
Marton Balint
25a2d269bd fftools, tools, examples: migrate to AVFormatContext->url
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-01-28 23:06:43 +01:00
Mark Thompson
74cf4a75f7 ffmpeg: Ignore SIGPIPE
On systems which deliver SIGPIPE (Unices), a broken pipe will currently
result in the immediate termination of the ffmpeg process (the default
disposition as required by POSIX).  This is undesirable, because while
the broken pipe is likely fatal to useful cleanup of whatever component
is writing to it, there might be other components which can do useful
cleanup - for example, a muxer on another stream may still need to write
indexes to complete a file.  Therefore, set the signal disposition for
SIGPIPE to ignore the signal - the call which caused the signal will
fail with EPIPE and the error will be propagated upwards like any other
I/O failure on a single stream.
2018-01-25 22:54:10 +00:00