summaryrefslogtreecommitdiff
path: root/fftools/ffmpeg.c
Commit message (Collapse)AuthorAge
* fftools/ffmpeg: always read input in a threadAnton Khirnov2022-08-08
| | | | This will be required by the following architecture changes.
* fftools/ffmpeg: drop a superfluous stack variableAnton Khirnov2022-08-08
|
* fftools/ffmpeg: remove OutputStream.sync_istAnton Khirnov2022-08-08
| | | | It is not actually used for anything.
* fftools/ffmpeg: remove OutputStream.encoding_neededAnton Khirnov2022-08-08
| | | | It is unnecessary, as it is always exactly equivalent to !!ost->enc_ctx
* fftools/ffmpeg: remove OutputStream.stream_copyAnton Khirnov2022-08-08
| | | | | | | | | | | | | | | 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.
* fftools/ffmpeg: stop accessing the decoder context unnecessarilyAnton Khirnov2022-08-08
| | | | | | The same information is available from AVStream.codecpar. This will allow to stop allocating a decoder unless decoding is actually performed.
* 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: 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: stop allocating an encoder context when not encodingAnton Khirnov2022-07-28
|
* 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: 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/ffmpeg: move each muxer to a separate threadAnton Khirnov2022-07-23
|
* 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: 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: 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/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
|
* fftools/ffmpeg: use refcounted packets for encoded subtitlesAnton Khirnov2022-07-23
|
* fftools/ffmpeg: move freeing 2pass input stats to a better placeAnton Khirnov2022-07-23
| | | | | | | | The current placement of this free is historical - it used to be followed by avcodec_close(), since removed. The proper place for freeing the stats is currently right before the encoder context itself is freed.
* fftools/ffmpeg_mux: split of_write_packet()Anton Khirnov2022-07-23
| | | | | | | | | | | | | | | | It is currently called from two places: - output_packet() in ffmpeg.c, which submits the newly available output packet to the muxer - from of_check_init() in ffmpeg_mux.c after the header has been written, to flush the muxing queue Some packets will thus be processed by this function twice, so it requires an extra parameter to indicate the place it is called from and avoid modifying some state twice. This is fragile and hard to follow, so split this function into two. Also rename of_write_packet() to of_submit_packet() to better reflect its new purpose.
* fftools/ffmpeg: move the mux queue into muxer private dataAnton Khirnov2022-07-23
| | | | | | | | | The muxing queue currently lives in OutputStream, which is a very large struct storing the state for both encoding and muxing. The muxing queue is only used by the code in ffmpeg_mux, so it makes sense to restrict it to that file. This makes the first step towards reducing the scope of OutputStream.
* fftools/ffmpeg: do not log to the muxer contextAnton Khirnov2022-07-23
| | | | All other logging goes to NULL context.
* fftools/ffmpeg: access output file chapters through a wrapperAnton Khirnov2022-07-23
| | | | | Avoid accessing the muxer context directly, as this will become forbidden in future commits.
* fftools/ffmpeg: refactor the code checking for bitexact outputAnton Khirnov2022-07-23
| | | | | | | | Figure out earlier whether the output stream/file should be bitexact and store this information in a flag in OutputFile/OutputStream. Stop accessing the muxer in set_encoder_id(), which will become forbidden in future commits.
* fftools/ffmpeg: move closing the file into of_write_trailer()Anton Khirnov2022-07-23
| | | | | | The current code postpones closing the files until after printing the final report, which accesses the output file size. Deal with this by storing the final file size before closing the file.
* fftools/ffmpeg: write the header for stream-less outputs when initializing ↵Anton Khirnov2022-07-23
| | | | | | the muxer There is no reason to delay this.
* fftools/ffmpeg: set want_sdp when initializing the muxerAnton Khirnov2022-07-23
| | | | Allows making the variable local to ffmpeg_mux.
* fftools/ffmpeg: refactor limiting output file size with -fsAnton Khirnov2022-07-23
| | | | | | Move the file size checking code to ffmpeg_mux. Use the recently introduced of_filesize(), making this code consistent with the size shown by print_report().
* fftools/ffmpeg: add a helper function to access output file sizeAnton Khirnov2022-07-23
| | | | Stop accessing muxer internals from outside of ffmpeg_mux.
* ffmpeg: use AVFrame.duration instead of AVFrame.pkt_durationAnton Khirnov2022-07-19
|
* fftools/ffmpeg: make debug_ts print raw filter outputTimo Rothenpieler2022-07-18
|
* fftools/ffmpeg: change frame counters to 64 bitMarton Balint2022-06-27
| | | | | | | | | | | Frame counters can overflow relatively easily (INT_MAX number of frames is slightly more than 1 year for 60 fps content), so make sure we are always using 64 bit values for them. A live stream can easily run for more than a year and the framedup logic breaks on an overflow. Signed-off-by: Marton Balint <cus@passwd.hu>
* ffmpeg: add option fps_modeGyan Doshi2022-06-11
| | | | | | | fps_mode sets video sync per output stream. Overrides vsync for matching streams. vsync is deprecated.
* ffmpeg: drop undocumented -d optionStefano Sabatini2022-06-09
| | | | | | | | | | | | Option was added in commit 39aafa5ee90e10382e but was never documented. Also does not seem there are current use cases for it, tests for which it was introduced are still working therefore we drop it altogether. Indirectly fix trac issue: http://trac.ffmpeg.org/ticket/1698 Signed-off-by: Marton Balint <cus@passwd.hu>
* fftools/ffmpeg: move processing AV_PKT_DATA_QUALITY_STATS to do_video_stats()Anton Khirnov2022-05-24
| | | | | | | | | | This is a more appropriate place for this code, since the values we read from AV_PKT_DATA_QUALITY_STATS side data are primarily written into video stats. This ensures that the values written into stats actually apply to the right packet. Rename the function to update_video_stats() to better reflect its new purpose.
* fftools/ffmpeg: merge variable declaration and initializationAnton Khirnov2022-05-24
|
* fftools/ffmpeg: stop using av_stream_get_end_pts() in do_video_stats()Anton Khirnov2022-05-24
| | | | | | It retrieves libavformat's internal dts value (contrary to the function's name), which is not only incorrect in general, but also unnecessary because we can access the packet directly.