summaryrefslogtreecommitdiff
path: root/fftools
Commit message (Collapse)AuthorAge
* ffmpeg_opt: consider HW acceleration method when selecting decoderHaihao Xiang2022-08-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* ffmpeg_opt: select a decoder after getting values for per-stream hwdec optionsHaihao Xiang2022-08-03
| | | | | | | | | | | 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>
* fftools/ffmpeg_opt: Fix copyinkfAndreas Rheinhardt2022-08-02
| | | | | | | Broken in 9c2b800203a5a8f3d83f3b8f28e8c50d28186b39. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* fftools/ffmpeg_opt: reindentAnton Khirnov2022-07-28
|
* fftools/ffmpeg_opt: factor manually mapping streams out of open_output_file()Anton Khirnov2022-07-28
|
* fftools/ffmpeg_opt: reindentAnton Khirnov2022-07-28
|
* fftools/ffmpeg_opt: factor auto-mapping data streams out of open_output_file()Anton Khirnov2022-07-28
|
* fftools/ffmpeg_opt: reduce indentation in map_auto_subtitle()Anton Khirnov2022-07-28
| | | | | Fix indentation after the previous commit. Also use an early return to save one extra indentation level.
* fftools/ffmpeg_opt: factor auto-mapping subtitles out of open_output_file()Anton Khirnov2022-07-28
|
* fftools/ffmpeg_opt: reduce indentation in map_auto_audio()Anton Khirnov2022-07-28
| | | | | Fix indentation after the previous commit. Also use an early return to save one extra indentation level.
* fftools/ffmpeg_opt: factor auto-mapping audio out of open_output_file()Anton Khirnov2022-07-28
|
* fftools/ffmpeg_opt: reduce indentation in map_auto_video()Anton Khirnov2022-07-28
| | | | | Fix indentation after the previous commit. Also use an early return to save one extra indentation level.
* fftools/ffmpeg_opt: factor auto-mapping video out of open_output_file()Anton Khirnov2022-07-28
|
* fftools/ffmpeg: do not log to the decoder contextAnton Khirnov2022-07-28
| | | | | That should only be done from inside the decoder. Log to NULL instead, as is the current convention in ffmpeg.
* fftools/ffmpeg_mux: move some functions closer to their only callersAnton Khirnov2022-07-28
|
* fftools/ffmpeg_filter: drop a block commented out since 2012Anton Khirnov2022-07-28
| | | | | Since the option it relates to is deprecated, it is highly unlikely to become useful.
* fftools/ffmpeg: deprecate the -map_channel optionAnton Khirnov2022-07-28
| | | | | It is now entirely redundant with audio filters, and is in fact implemented by setting up a 'pan' filter instance.
* fftools/ffmpeg: move guess_input_channel_layout() to ffmpeg_opt.cAnton Khirnov2022-07-28
| | | | That is the only place where it is used. Also make it static.
* fftools/ffmpeg: drop unused hwaccel variablesAnton Khirnov2022-07-28
|
* fftools/ffmpeg_opt: drop a redundant assignmentAnton Khirnov2022-07-28
| | | | | The codec type will be set by avcodec_alloc_context3(), there is no reason to set it manually.
* fftools/ffmpeg: stop allocating an encoder context when not encodingAnton Khirnov2022-07-28
|
* fftools/ffmpeg: deprecate -psnrAnton Khirnov2022-07-28
| | | | It is entirely redundant with -flags +psnr.
* fftools/ffmpeg: do not use the encoder context for streamcopyAnton Khirnov2022-07-28
| | | | | | The streamcopy initialization code briefly needs an AVCodecContext to apply AVOptions to. Allocate a temporary codec context, do not use the encoding one.
* fftools/ffmpeg: drop OutputStream.ref_parAnton Khirnov2022-07-28
| | | | | It serves no purpose, codec parameters can be written directly to AVStream.codecpar with the same effect.
* fftools/ffmpeg: drop the -vol optionAnton Khirnov2022-07-28
| | | | It has been deprecated in favor of the volume filter since 2012.
* fftools/ffmpeg_filter: do not pass the entire AVCodecContext to ↵Anton Khirnov2022-07-28
| | | | | | | choose_pixel_fmt() It only uses strict_std_compliance, so pass just that value. Makes it more clear what fields are accessed.
* fftools/ffmpeg_filter: remove unused function argumentAnton Khirnov2022-07-28
|
* fftools/ffmpeg: remove an unnecessary avcodec_close() callAnton Khirnov2022-07-28
| | | | | No encoders can possibly be opened at this point. And even if some were, they would be closed in ffmpeg_cleanup().
* fftools/ffmpeg: stop accessing the encoder context unnecessarilyAnton Khirnov2022-07-28
| | | | | | The same information is available from AVStream.codecpar. This will allow to stop allocating an encoder unless encoding is actually performed.
* fftools/ffmpeg: replace AVFrame.pkt_duration with durationAnton Khirnov2022-07-24
| | | | Mistakenly reintroduced in 4740fea7ddf.
* fftools/ffmpeg: Zero subtitle packet paddingAndreas Rheinhardt2022-07-23
| | | | | | Fixes uninitialized reads in the sub-lrc-remux test. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* fftools/objpool: Don't use return with expression when returning voidAndreas Rheinhardt2022-07-23
| | | | | | | | | | | 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>
* fftools/ffmpeg: move each muxer to a separate threadAnton Khirnov2022-07-23
|
* fftools: add a multistream thread-safe queueAnton Khirnov2022-07-23
| | | | | It is similar to AVThreadMessageQueue, but supports multiple streams, each with its own EOF state.
* fftools/ffmpeg: depend on threadsAnton Khirnov2022-07-23
| | | | | ffmpeg will be switched to a fully threaded architecture, starting with muxers.
* fftools/ffmpeg: stop using av_stream_get_end_pts()Anton Khirnov2022-07-23
| | | | | | | | It retrieves the muxer's internal timestamp with under-defined semantics. Continuing to use this value would also require synchronization once the muxer is moved to a separate thread. Replace the value with last_mux_dts.
* fftools/ffmpeg_mux: do not call exit_program() in print_sdp()Anton Khirnov2022-07-23
| | | | | Return an error instead, as is already done in other places in this function.
* fftools/ffmpeg_mux: return errors from write_packet()Anton Khirnov2022-07-23
| | | | | Do not call exit_program(), as that would conflict with moving this code into a separate thread.
* fftools/ffmpeg_mux: return errors from submit_packet()Anton Khirnov2022-07-23
| | | | | Do not call exit_program(), as that would conflict with moving this code into a separate thread.
* fftools/ffmpeg_mux: return errors from of_submit_packet()Anton Khirnov2022-07-23
| | | | | Do not call exit_program(), as that would conflict with moving this code into a separate thread.
* fftools/ffmpeg: make the muxer AVFormatContext private to ffmpeg_mux.cAnton Khirnov2022-07-23
| | | | | Since the muxer will operate in a separate thread in the future, the muxer context should not be accessed from the outside.
* fftools/ffmpeg: only set OutputStream.frame_number for video encodingAnton Khirnov2022-07-23
| | | | | | | It is unused otherwise. Rename the field to vsync_frame_number to better reflect its current purpose.
* fftools/ffmpeg: stop using OutputStream.frame_number in print_report()Anton Khirnov2022-07-23
| | | | | | | | | | This field means different things when the video is encoded (number of frames emitted to the encoding sync queue/encoder by the video sync code) or copied (number of packets sent to the muxer sync queue). Print the value of packets_written instead, which means the same thing in both cases. It is also more accurate, since packets may be dropped by the sync queue or bitstream filters.
* fftools/ffmpeg: use the sync queues to handle -framesAnton Khirnov2022-07-23
| | | | | | | | | | | | | | | | Same issues apply to it as to -shortest. Changes the results of the following tests: - matroska-flac-extradata-update The test reencodes two input FLAC streams into three output FLAC streams. The last output stream is limited to 8 frames. The current code results in the first two output streams having 12 frames, after this commit all three streams have 8 frames and are the same length. This new result is better, since it is predictable. - mkv-1242 The test streamcopies one video and one audio stream, video is limited to 11 frames. The new result shortens the audio stream so that it is not longer than the video.
* fftools/ffmpeg_mux: reindentAnton Khirnov2022-07-23
|
* fftools/ffmpeg: rework -shortest implementationAnton Khirnov2022-07-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The -shortest option (which finishes the output file at the time the shortest stream ends) is currently implemented by faking the -t option when an output stream ends. This approach is fragile, since it depends on the frames/packets being processed in a specific order. E.g. there are currently some situations in which the output file length will depend unpredictably on unrelated factors like encoder delay. More importantly, the present work aiming at splitting various ffmpeg components into different threads will make this approach completely unworkable, since the frames/packets will arrive in effectively random order. This commit introduces a "sync queue", which is essentially a collection of FIFOs, one per stream. Frames/packets are submitted to these FIFOs and are then released for further processing (encoding or muxing) when it is ensured that the frame in question will not cause its stream to get ahead of the other streams (the logic is similar to libavformat's interleaving queue). These sync queues are then used for encoding and/or muxing when the -shortest option is specified. A new option – -shortest_buf_duration – controls the maximum number of queued packets, to avoid runaway memory usage. This commit changes the results of the following tests: - copy-shortest[12]: the last audio frame is now gone. This is correct, since it actually outlasts the last video frame. - shortest-sub: the video packets following the last subtitle packet are now gone. This is also correct.
* fftools: add an object poolAnton Khirnov2022-07-23
| | | | | Allows to avoid constantly allocating and freeing objects like AVFrame or AVPacket.
* fftools/ffmpeg: use pre-BSF DTS for choosing next outputAnton Khirnov2022-07-23
| | | | | | | | | | The following commits will add a new buffering stage after bitstream filters, which should not be taken into account for choosing next output. OutputStream.last_mux_dts is also used by the muxing code to make up missing DTS values - that field is now moved to the muxer-private MuxStream object.
* fftools/ffmpeg: use last filter output pts to choose next output streamAnton Khirnov2022-07-23
| | | | | This will be needed in following commits that will add new buffering stages after encoding and bitstream filtering.
* fftools/ffmpeg: do not send spurious EOF for streamcopy when loopingAnton Khirnov2022-07-23
|