Commit Graph

2317 Commits

Author SHA1 Message Date
Anton Khirnov
8db301dead ffmpeg: set the encoding framerate when the output is CFR
(cherry picked from Libav commit d10102d23c)

Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2017-03-17 11:54:38 +01:00
Clément Bœsch
a283665693 Merge commit 'e46a6fb7732a7caef97a916a4f765ec0f779d195'
* commit 'e46a6fb7732a7caef97a916a4f765ec0f779d195':
  avconv: Check that muxing_queue exists before reading from it

Mostly noop. This was fixed in FFmpeg in 7f7c494a3.

The merge makes the cosmetics match but does not include the weird
av_log().

Merged-by: Clément Bœsch <cboesch@gopro.com>
2017-03-15 14:28:43 +01:00
Clément Bœsch
993a9a3d72 Merge commit 'b0f36a0043d76436cc7ab8ff92ab99c94595d3c0'
* commit 'b0f36a0043d76436cc7ab8ff92ab99c94595d3c0':
  avconv: stop using setpts for input framerate forced with -r

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-12 13:08:04 +01:00
wm4
808ab2fd0b ffmpeg: remove unnecessary hack for decoders which refuse to drain
Now the previous commit takes care of this instead.
2017-03-06 11:08:03 +01:00
wm4
7dd44cde2a ffmpeg: delay processing of subtitles before filters are initialized
If a subtitle packet came before the first video frame could be fully
decoded, the subtitle packet would get discarded. This puts the subtitle
into a queue instead, and processes it once the attached filter graph is
initialized.
2017-03-03 08:45:43 +01:00
Timo Rothenpieler
736f4af4fe ffmpeg_cuvid: adapt for recent filter graph initialization changes 2017-03-03 08:45:43 +01:00
Anton Khirnov
76e13bdeaa ffmpeg: restructure sending EOF to filters
Be more careful when an input stream encounters EOF when its filtergraph
has not been configured yet. The current code would immediately mark the
corresponding output streams as finished, while there may still be
buffered frames waiting for frames to appear on other filtergraph
inputs.

This should fix the random FATE failures for complex filtergraph tests
after a3a0230a98

This merges Libav commit 94ebf55. It was previously skipped.

This is the last filter init related Libav commit that was skipped, so
this also removes the commits from doc/libav-merge.txt.

Signed-off-by: wm4 <nfxjfg@googlemail.com>
2017-03-03 08:45:43 +01:00
Anton Khirnov
cb884f8d7e ffmpeg: move flushing the queued frames to configure_filtergraph()
This is a more appropriate place for it, and will also be useful in the
following commit.

This merges Libav commit d2e56cf. It was previously skipped.

Signed-off-by: wm4 <nfxjfg@googlemail.com>
2017-03-03 08:45:43 +01:00
Anton Khirnov
af1761f7b5 ffmpeg: init filtergraphs only after we have a frame on each input
This makes sure the actual stream parameters are used, which is
important mainly for hardware decoding+filtering cases, which would
previously require various weird workarounds to handle the fact that a
fake software graph has to be constructed, but never used.
This should also improve behaviour in rare cases where
avformat_find_stream_info() does not provide accurate information.

This merges Libav commit a3a0230. It was previously skipped.

The code in flush_encoders() which sets up a "fake" format wasn't in
Libav. I'm not sure if it's a good idea, but it tends to give
behavior closer to the old one in certain corner cases.

The vp8-size-change gives different result, because now the size of
the first frame is used. libavformat reported the size of the largest
frame for some reason.

The exr tests now use the sample aspect ratio of the first frame. For
some reason libavformat determines 0/1 as aspect ratio, while the
decoder returns the correct one.

The ffm and mxf tests change the field_order values. I'm assuming
another libavformat/decoding mismatch.

Signed-off-by: wm4 <nfxjfg@googlemail.com>
2017-03-03 08:45:43 +01:00
Anton Khirnov
4ee5aed122 ffmpeg: do packet ts rescaling in write_packet()
This will be useful in the following commit, after which the muxer
timebase is not always available when encoding.

This merges Libav commit 3e265ca. It was previously skipped.

There are some changes with how/when the mux_timebase field is set,
because the Libav approach often causes a too imprecise time base
to be set. This is hard, because the muxer's write_header function
can readjust the timebase, at which point we might already have
encoded packets buffered. (It might be better to buffer them after
the encoder, instead of after all the timestamp handling logic
before muxing.)

The two FATE tests change because the output time base is raised
for subtitles. (Needed to avoid certain rounding issues in other
cases.)

Includes a minor merge fix by Mark Thompson, and

    avconv: Move rescale to stream timebase before monotonisation

also by Mark Thompson <sw@jkqxz.net>.

Signed-off-by: wm4 <nfxjfg@googlemail.com>
2017-03-03 08:45:43 +01:00
wm4
33580a8625 ffmpeg: make sure packets put into the muxing FIFO are refcounted
Some callers (like do_subtitle_out()) call this with an AVPacket that is
not refcounted. This can cause undefined behavior.

Calling av_packet_move_ref() does not make a packet refcounted if it
isn't yet. (And it can't be made to, because it always succeeds,
and can't return ENOMEM.)

Call av_packet_ref() instead to make sure it's refcounted.

I couldn't find a case that is fixed by this with the current code. But
it will fix the fate-pva-demux test with the later patches applied.

Signed-off-by: wm4 <nfxjfg@googlemail.com>
2017-03-03 08:45:43 +01:00
Carl Eugen Hoyos
f8d2079a67 ffmpeg: Add a linebreak to an error message. 2017-02-27 10:28:00 +01:00
Michael Niedermayer
dfc6e30cd4 ffmpeg: Remove redundant null check
Fixes CID1396245

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-02-06 01:01:33 +01:00
Carl Eugen Hoyos
ac0863146b ffmpeg: Add a missing line break when requesting a sample. 2017-02-02 09:45:15 +01:00
Sasi Inguva
03e42a4fec ffmpeg.c: Add output file index and stream index to vstats file.
Signed-off-by: Sasi Inguva <isasi@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-01-27 22:16:37 +01:00
Tobias Rapp
c324e2c5db ffmpeg: pass output stream duration as a hint to the muxer
Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-01-19 01:54:49 +01:00
Michael Bradshaw
3ac46a0a62 ffmpeg: Add -time_base option to hint the time base
Signed-off-by: Michael Bradshaw <mjbshaw@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-01-14 20:03:56 +01:00
Nicolas George
d9b311d44c ffmpeg: use buffersink accessors. 2017-01-12 14:06:16 +01:00
Michael Niedermayer
a830ab3f3b ffmpeg: remove stop_encoding variable and related code, it is dead / unused code
Fixes: CID1396243

Reviewed-by: compn <tempn@mi.rr.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-28 19:19:15 +01:00
Michael Niedermayer
11103a493d ffmpeg: Check avcodec_parameters_to_context() for failure
Fixes CID1396241

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-26 20:45:23 +01:00
Tobias Rapp
4d57ca51d7 ffmpeg: assert return value is initialized
Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-01 12:01:51 +01:00
Clément Bœsch
825f6fbfac ffmpeg: factor out sending frame to filters
Video doesn't exit ffmpeg on error anymore, and audio now prints an
error.
2016-11-18 20:23:58 +01:00
Clément Bœsch
b9c26aed4e ffmpeg: remove dead code out of the video filter loop
It makes no sense for this code to be inside the video filter loop, and
the frame sample aspect ratio is even set unconditionally a few lines
above.
2016-11-18 20:23:58 +01:00
Hendrik Leppkes
166f2c52ac Merge commit 'b55566db4c51d920a6496455bb30a608e5a50a41'
* commit 'b55566db4c51d920a6496455bb30a608e5a50a41':
  avconv: use avcodec_parameters_copy() with streamcopy

The fate-aac-autobsf-adtstoasc changes from writing an audio bitdepth
based on the sample format, which is now available.

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-11-14 14:56:52 +01:00
Hendrik Leppkes
198e8b8e77 Merge commit '50722b4f0cbc5940e9e6e21d113888436cc89ff5'
* commit '50722b4f0cbc5940e9e6e21d113888436cc89ff5':
  avconv: decouple configuring filtergraphs and setting output parameters

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-11-13 15:33:39 +01:00
Hendrik Leppkes
6b449a1290 Merge commit 'ba7397baef796ca3991fe1c921bc91054407c48b'
* commit 'ba7397baef796ca3991fe1c921bc91054407c48b':
  avconv: factor out initializing stream parameters for encoding

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-11-13 15:17:00 +01:00
Marton Balint
d318e06024 ffmpeg: add newline to avformat_write_header error message
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Marton Balint <cus@passwd.hu>
2016-11-13 03:10:08 +01:00
James Almer
55061bbc55 ffmpeg: don't overwrite av_bsf_receive_packet return value before checking it
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-11-05 00:04:27 -03:00
Carl Eugen Hoyos
5a4935c012 ffmpeg: Warn if thousands of frames are duplicated.
Fixes ticket #5193.
2016-11-04 11:40:00 +01:00
Michael Niedermayer
11f24e71ff ffmpeg: Fix bsf corrupting merged side data
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-11-04 00:42:58 +01:00
Hendrik Leppkes
b6422902d8 Merge commit '722ec3eb35bc152ce91d0a4502eca0df1c0086d0'
* commit '722ec3eb35bc152ce91d0a4502eca0df1c0086d0':
  avconv: decouple configuring filtergraphs and setting input parameters

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-11-03 14:53:58 +01:00
Andreas Cadhalpun
c8a6eb58d7 doc: fix spelling errors
Thanks to Mathieu Malaterre <malat@debian.org> for reporting the
Que/Queue typo. (https://bugs.debian.org/839542)

Reviewed-by: Lou Logan <lou@lrcd.com>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2016-10-21 23:58:47 +02:00
Clément Bœsch
ad2d2ebd4e ffmpeg: remove unused ist parameter in do_subtitle_out() 2016-10-16 19:22:19 +02:00
Michael Niedermayer
44453c09e4 ffmpeg: Use av_fifo_freep() to avoid stale pointers
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-10-14 17:05:25 +02:00
James Zern
7f7c494a33 ffmpeg_cleanup: fix crash with unrecognized codec
since:
3e5e5bd Merge commit '398f015f077c6a2406deffd9e37ff34b9c7bb3bc'

Signed-off-by: James Zern <jzern@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-10-14 17:02:33 +02:00
Hendrik Leppkes
3e5e5bdfef Merge commit '398f015f077c6a2406deffd9e37ff34b9c7bb3bc'
* commit '398f015f077c6a2406deffd9e37ff34b9c7bb3bc':
  avconv: buffer the packets written while the muxer is not initialized

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-10-08 11:38:47 +02:00
Hendrik Leppkes
ab7e83efed ffmpeg: explicitly write headers for files with no streams
Recent changes to ffmpeg.c tied output file init to stream init, which broke
stream-less files, specifically ffmetadata output.
2016-10-07 16:02:14 +02:00
Hendrik Leppkes
82c4d57553 Merge commit '1c169782cae6c5c430ff62e7d7272dc9d0e8d527'
* commit '1c169782cae6c5c430ff62e7d7272dc9d0e8d527':
  avconv: explicitly postpone writing the header until all streams are initialized

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-10-07 14:39:00 +02:00
Hendrik Leppkes
6f74e3cde6 Merge commit 'beb62dac629603eb074a44c44389c230b5caac7c'
* commit 'beb62dac629603eb074a44c44389c230b5caac7c':
  Use AVFrame.pts instead of deprecated pkt_pts.

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-10-07 13:16:36 +02:00
Hendrik Leppkes
04a3577263 ffmpeg: remove unused and errorneous AVFrame timestamp check
Decoders have previously not used AVFrame.pts, and with the upcoming
deprecation of pkt_pts (in favor of pts), this would lead to an errorneous
interpration of timestamps.
2016-10-07 12:21:18 +02:00
Rodger Combs
1f7d586052
ffmpeg: don't reconfigure terminal if we're not taking input from stdin 2016-10-06 18:31:06 -05:00
wm4
4f8262e373 ffmpeg: use new encode API 2016-10-01 17:23:02 +02:00
wm4
8f6f232228 ffmpeg: use new decode API
This is a bit messy, mainly due to timestamp handling.

decode_video() relied on the fact that it could set dts on a flush/drain
packet. This is not possible with the old API, and won't be. (I think
doing this was very questionable with the old API. Flush packets should
not contain any information; they just cause a FIFO to be emptied.) This
is replaced with checking the best_effort_timestamp for AV_NOPTS_VALUE,
and using the suggested DTS in the drain case.

The modified tests (fate-cavs and others) still fails due to dropping
the last frame. This happens because the timestamp of the last frame
goes backwards (ffprobe -show_frames shows the same thing). I suspect
that this "worked" due to the best effort timestamp logic picking the
DTS over the decreasing PTS. Since this logic is in libavcodec (where
it probably shouldn't be), this can't be easily fixed. The timestamps
of the cavs samples are weird anyway, so I chose not to fix it.

Another strange thing is the timestamp handling in the video path of
process_input_packet (after the decode_video() call). It looks like
the code to increase next_dts and next_pts should be run every time
a frame is decoded - but it's needed even if output is skipped.
2016-10-01 17:22:22 +02:00
wm4
b2fea2fdee ffmpeg: move subframe warning to libavcodec
With the new decode API, doing this in ffmpeg.c is impractical. There
was resistance against removing the warning, so put it into libavcodec.

Not bothering with reducing the warning to verbose log level for
subsequent wanrings. The warning should be rare, and only happen when
developing new codecs for the old API.

Includes a change suggested by Michael Niedermayer.
2016-10-01 17:22:02 +02:00
Anton Khirnov
bfbf86ef18 ffmpeg: pass the hwaccel frames context to the decoder 2016-09-29 15:57:32 +02:00
James Almer
3597d32e88 Merge commit '6ed0f70f97c882813199b3bafd724ceeb43659de'
* commit '6ed0f70f97c882813199b3bafd724ceeb43659de':
  avconv: factor out initializing stream parameters for streamcopy

Conflicts:
    ffmpeg.c

Merged-by: James Almer <jamrial@gmail.com>
2016-09-28 12:59:07 -03:00
James Almer
4a05d2eda7 ffmpeg: stop using AVStream.codec on stream copy
This commit is based on commit 35c8580 from Anton Khirnov <anton@khirnov.net>
which was skipped in b8945c4.

The avcodec_copy_context() call in the encode path is left in place for now
as AVStream.codec is apparently still required even after porting ffmpeg to
the new bsf API.

Tested-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-09-27 10:42:51 -03:00
James Almer
3ac76d7618 ffmpeg: fix memleak of encoder options AVDictionary on failure
Reviewed-by: Josh de Kock <josh@itanimul.li>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-09-25 16:17:41 -03:00
Michael Niedermayer
9083e044f1 ffmpeg: Fix bistream typos
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-25 19:06:51 +02:00
Clément Bœsch
5ef1959080 ffmpeg: switch to the new BSF API
This commit is initially largely based on commit 4426540 from Anton
Khirnov <anton@khirnov.net> and two following fixes (80fb19b and
fe7b21c) which were previously skipped respectively in 98e3153, c9ee36e,
and 7fe7cdc.

mpeg4-bsf-unpack-bframes FATE reference is updated because the bsf
filter now actually fixes the extradata (mpeg4_unpack_bframes_init()
changing one byte is now honored on the output extradata).

The FATE references for remove_extra change because the packet flags
were wrong and the keyframes weren't marked, causing the bsf relying on
these proprieties to not actually work as intended.

The following was fixed by James Almer:

The filter option arguments are now also parsed correctly.

A hack to propagate extradata changed by bitstream filters after the
first av_bsf_receive_packet() call is added to maintain the current
behavior. This was previously done by av_bitstream_filter_filter() and
is needed for the aac_adtstoasc bsf.

The exit_on_error was not being checked anymore, and led to an exit
error in the last frame of h264_mp4toannexb test. Restoring this
behaviour prevents erroring out. The test is still changed as a result
due to the badly filtered frame now not being written after the failure.

Signed-off-by: Clément Bœsch <u@pkh.me>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-09-24 14:25:53 -03:00