Commit Graph

469 Commits

Author SHA1 Message Date
Mark Thompson e3fb74f7f9 lavfi: Always propagate hw_frames_ctx through links
Also adds a new flag to mark filters which are aware of hwframes and
will perform this task themselves, and marks all appropriate filters
with this flag.

This is required to allow software-mapped hardware frames to work,
because we need to have the frames context available for any later
mapping operation in the filter graph.

The output from the filter graph should only propagate further to an
encoder if the hardware format actually matches the visible format
(mapped frames are valid here and have an hw_frames_ctx, but this
should not be given to the encoder as its hardware context).
2016-11-02 20:29:05 +00:00
James Almer 064f19f39e avconv: support parsing bitstream filter options
Example usage:

avconv -i INPUT -bsf filter[=opt1=val1:opt2=val2] OUTPUT

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-11-02 10:08:28 +01:00
Anton Khirnov 27085d1b47 avconv: only retry decoding on actual decoding errors
Errors during decoding are currently considered non-fatal and do not
terminate transcoding, so even if parts of the data are corrupted, the
rest may be decodable.

However, that should apply only to the actual decoding calls, not to the
failures elsewhere (e.g. configuring filters).
2016-10-02 11:41:45 +02:00
Anton Khirnov d10102d23c avconv: set the encoding framerate when the output is CFR 2016-10-02 11:41:45 +02:00
Luca Barbato f6d2fed811 avconv: Make sure that inputless filtergraphs are configured
Unbreak `avconv -filter_complex testsrc`.

Regression introduced in a3a0230a98
2016-08-12 11:41:58 +02:00
Diego Biurrun e46a6fb773 avconv: Check that muxing_queue exists before reading from it
This avoids a segfault on nonexisting codec names.
2016-07-27 10:59:48 +02:00
Anton Khirnov b0f36a0043 avconv: stop using setpts for input framerate forced with -r
The setpts filter does not signal to the rest of the filtergraph that
the stream is CFR. Just generate the timestamps manually instead.
2016-07-22 19:08:12 +02:00
Anton Khirnov b55566db4c avconv: use avcodec_parameters_copy() with streamcopy
This preserves all the information in the codec parameters.

The wavpack ref changes are caused by the fact that now the sample
format is set, so matroskaenc can use it to set the bit depth.

Bug-Id: 945, along with the previous commit
2016-07-02 09:30:40 +02:00
Anton Khirnov 94ebf55658 avconv: 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
2016-06-28 08:30:20 +02:00
Anton Khirnov d2e56cf753 avconv: 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.
2016-06-28 08:30:20 +02:00
Anton Khirnov 232399e3ee avconv: pass the hwaccel frames context to the decoder 2016-06-25 12:10:42 +02:00
Anton Khirnov a3a0230a98 avconv: 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.
2016-06-25 12:04:32 +02:00
Anton Khirnov 3e265ca58f avconv: 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.
2016-06-25 12:04:32 +02:00
Anton Khirnov 50722b4f0c avconv: decouple configuring filtergraphs and setting output parameters
Currently, a filtergraph will pull in the output constraints from its
corresponding decoder context, which breaks proper layering. Instead,
explicitly send the constaints on the output parameters to the
filtergraph.

This is similar to what is done for filtergraph inputs in
30ab4c51a180610d9f1720c75518d763515c0d9f
2016-06-25 12:04:32 +02:00
Anton Khirnov ba7397baef avconv: factor out initializing stream parameters for encoding
Setting the filter input parameters is moved to init_input_stream(),
so that it is done before the decoder is opened, potentially overwriting
the information from avformat_find_stream_info() with less accurate
data.

This commit temporarily disables QSV transcoding with hw frames. The
functionality will be re-added in the following commits.
2016-06-25 12:04:29 +02:00
Anton Khirnov 722ec3eb35 avconv: decouple configuring filtergraphs and setting input parameters
Currently, calling configure_filtergraph() will pull in the input
parameters from the corresponding decoder context. This has the
following disadvantages:
- the decoded frame is a more proper source for this information
- a filter accessing decoder data breaks proper layering

Add functions for explicitly sending the input stream parameters to a
filtergraph input - currently from a frame and a decoder. The decoder
one will be dropped in future commits after some more restructuring.
2016-06-25 11:20:50 +02:00
Anton Khirnov 398f015f07 avconv: buffer the packets written while the muxer is not initialized 2016-06-25 11:15:54 +02:00
Anton Khirnov 1c169782ca avconv: explicitly postpone writing the header until all streams are initialized
This should have no practical effect for now, but will make a difference
in the following commits.
2016-06-25 11:12:53 +02:00
Anton Khirnov beb62dac62 Use AVFrame.pts instead of deprecated pkt_pts. 2016-06-21 19:54:42 +02:00
Anton Khirnov 6ed0f70f97 avconv: factor out initializing stream parameters for streamcopy 2016-06-21 12:39:02 +02:00
Anton Khirnov 5fa255b65c avconv: initialize output framerate earlier
This will be needed in the following commits.
2016-06-21 12:39:02 +02:00
Anton Khirnov 1e93c1e30f avconv: do not set encoder options when streamcopy is used 2016-06-21 12:39:02 +02:00
Anton Khirnov 90944ee3ab avconv: refactor selecting an encoder
Fail immediately if automatic encoder selection failed. Always set the
stream_copy/encoding_needed flags in one place.
2016-06-21 12:39:02 +02:00
Anton Khirnov 5e1840622c avconv: fix handling attachments in init_output_stream
The current code assumes that encoding_needed is simply an inverse of
stream_copy, which is not true for manually attached files (for which
neither of those is true).
2016-06-21 12:39:02 +02:00
Anton Khirnov 73c6ec6d65 avconv: create simple filtergraphs earlier
We already have all the necessary information in open_output_file().
This makes the information about the stream/filtergraph mappings
available earlier.
2016-06-21 12:39:02 +02:00
Anton Khirnov 49670e4218 avconv: add a function for determining whether a filtergraph is simple
This makes the code easier to read.
2016-06-21 12:39:02 +02:00
Vittorio Giovara 20a8c78ce0 avconv: Do not copy extradata if source buffer is empty
Fixes clang-usan runtime error "null pointer passed as argument 2,
which is declared to never be null" while streamcopying.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-06-06 11:56:21 -04:00
Diego Biurrun e2a3df1a46 avconv: Use more precise deprecation ifdefs
This fixes compilation with the libavcodec version bumped to 58.
2016-05-22 20:22:43 +02:00
Anton Khirnov 35c8580668 avconv: stop using AVStream.codec
It is now only used by the av_parser_change() call during streamcopy, so
allocate a special AVCodecContext instance for this case. This instance
should go away when the new parser API is finished.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-22 20:22:42 +02:00
Diego Biurrun 763d69bfb2 Add some more deprecation guards
Avoids unused function/label/variable warnings after the next version bump.
2016-05-11 12:22:49 +02:00
Vittorio Giovara 41ed7ab45f cosmetics: Fix spelling mistakes
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +02:00
Luca Barbato 1db8eb1549 avconv: Drop an unused variable 2016-04-01 05:30:22 +02:00
Anton Khirnov 69a638019f avconv: fix -frames for video
For video, frame_number tracks the number of frames sent to the encoder.
So it should be incremented when we submit a frame, not when we get a
packet back.
2016-03-30 09:13:09 +02:00
Mark Thompson 5d273d3efa avconv: VAAPI hwcontext initialisation and hwaccel helper
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-03-30 09:04:53 +02:00
wm4 35846d93e0 avconv: use new encode API
The flushing case is a bit strange; not simplifying it so the change is
less noisy.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-03-23 19:31:35 +01:00
wm4 84aea95e31 avconv: use new decode API
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-03-23 19:31:35 +01:00
Anton Khirnov 4426540f0c avconv: switch to the new BSF API 2016-03-20 08:15:01 +01:00
wm4 0b6e5d6b32 avconv: remove sub-frame warning
It's not practical to keep this with the new decode API.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-03-05 09:10:10 +01:00
Anton Khirnov 15e84ed3f1 avconv: convert to codecpar
The switch is not yet complete because the parsers and the bistream
filters do not have a new AVCodecParam-based API yet.
2016-02-23 17:01:58 +01:00
Anton Khirnov 5b9cdf8cba avconv: switch opening decoders and encoders
Open decoders first, next encoders. This makes sure that that
subtitle_header is always set properly, without relying on
avformat_find_stream_info() setting it.
2016-02-23 17:01:58 +01:00
Anton Khirnov c15f6098b1 avconv: pass the hw context from filters to the encoder 2016-02-14 22:33:26 +01:00
Luca Barbato 63f7f8d1db avconv: Drop an impossible check
EAGAIN is already managed in poll_filters().

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2016-01-04 16:58:32 +01:00
Luca Barbato 7ebf1b4ada avconv: Simplify poll_filters() return value check
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2016-01-04 16:58:32 +01:00
Anton Khirnov e63e3797a1 avconv: pass the global codec side data to the muxer 2015-12-06 10:23:21 +01:00
Anton Khirnov 3efd71b4d0 avconv: set packet duration for CFR video streams 2015-11-08 11:49:05 +01:00
Alexandra Hájková cd0e08813a avconv: support infinite loop for the loop option
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-10-26 19:28:24 +01:00
Luca Barbato ce70f28a17 avpacket: Replace av_free_packet with av_packet_unref
`av_packet_unref` matches the AVFrame ref-counted API and can be used as
a drop in replacement.

Deprecate `av_free_packet`.
2015-10-26 18:00:55 +01:00
Luca Barbato a5d4204309 avformat: Always return ref-counted AVPacket
And drop the av_dup_packet from the input_thread.
2015-10-26 18:00:55 +01:00
Anton Khirnov fb472e1a11 avconv: add support for Intel QSV-accelerated transcoding
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-10-16 20:01:37 +02:00
Luca Barbato 34ed5c2e4d avformat: Do not use AVFMT_RAWPICTURE
There are no formats supporting it anymore and it is deprecated.
Update the documentation accordingly.
2015-10-13 13:43:29 +02:00