aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_mux.c
Commit message (Collapse)AuthorAgeFilesLines
...
* fftools/ffmpeg_filter: always pass graph description to fg_create()Anton Khirnov2023-05-311-1/+0
| | | | | | Currently NULL would be passed for simple filtergraphs, which would make the filter code extract the graph description from the output stream when needed. This is unnecessarily convoluted.
* fftools/ffmpeg: replace print_error() by more meaningful messagesAnton Khirnov2023-05-151-1/+3
|
* fftools/ffmpeg_filter: add filtergraph private dataAnton Khirnov2023-05-021-1/+0
| | | | | Start by moving OutputStream.filtered_frame to it, which really belongs to the filtergraph rather than the output stream.
* fftools/ffmpeg: reduce access to OutputStream.enc_ctxAnton Khirnov2023-05-021-1/+1
| | | | It will be made private to Encoder in the future.
* fftools/ffmpeg: remove unused function argumentsAnton Khirnov2023-04-241-2/+2
|
* fftools/ffmpeg_mux: fix reporting muxer EOF as errorZhao Zhili2023-04-231-3/+9
| | | | | | Fix #10327. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* fftools/ffmpeg: propagate frame durations to packets when encodingAnton Khirnov2023-04-191-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove now-obsolete code setting packet durations pre-muxing for CFR encoded video. Changes output in the following FATE tests: * numerous adpcm tests * ffmpeg-filter_complex_audio * lavf-asf * lavf-mkv * lavf-mkv_attachment * matroska-encoding-delay All of these change due to the fact that the output duration is now the actual input data duration and does not include padding added by the encoder. * apng-osample: less wrong packet durations are now passed to the muxer. They are not entirely correct, because the first frame duration should be 3 rather than 2. This is caused by the vsync code and should be addressed later, but this change is a step in the right direction. * tscc2-mov: last output frame has a duration of 11 rather than 1 - this corresponds to the duration actually returned by the demuxer. * film-cvid: video frame durations are now 2 rather than 1 - this corresponds to durations actually returned by the demuxer and matches the timestamps. * mpeg2-ticket6677: durations of some video frames are now 2 rather than 1 - this matches the timestamps.
* fftools/ffmpeg_mux: make copy_initial_nonkeyframes private to muxing codeAnton Khirnov2023-04-171-1/+1
| | | | It is no longer used outside of ffmpeg_mux*
* fftools/ffmpeg_mux: make copy_prior_start private to muxing codeAnton Khirnov2023-04-171-1/+1
| | | | It is no longer used outside of ffmpeg_mux*
* fftools/ffmpeg_mux: make streamcopy_started private to muxing codeAnton Khirnov2023-04-171-3/+3
| | | | It is no longer used outside of ffmpeg_mux*
* fftools/ffmpeg_mux: make ts_copy_start private to muxing codeAnton Khirnov2023-04-171-2/+2
| | | | It is no longer used outside of ffmpeg_mux*
* fftools/ffmpeg_mux: stop using filter_in_rescale_delta_last for streamcopyAnton Khirnov2023-04-171-3/+3
| | | | | | | | | | | | | That field was added to store timestamp conversion state for audio decoding code. Later it started being used by streamcopy as well, but that use is wrong because, for a given input stream, both decoding and an arbitrary number of streamcopies may be performed simultaneously. They would then all overwrite the same state variable. Store this state in MuxStream instead. This is the last use of InputStream in of_streamcopy(), so the ist parameter can now be removed.
* fftools/ffmpeg_mux: use output stream parameters in of_streamcopy()Anton Khirnov2023-04-171-3/+3
| | | | | They should always be the same as the input stream parameters, but this reduces the need to access InputStream in muxing code.
* fftools/ffmpeg: move do_streamcopy() to ffmpeg_muxAnton Khirnov2023-04-171-0/+76
| | | | | | do_streamcopy() is muxing code, so this is a more appropriate place for this. The last uses of InputStream in it will be removed in following commits.
* fftools/ffmpeg: add muxer-input codec parameters to OutputStreamAnton Khirnov2023-04-171-2/+4
| | | | | | | | | | | It stores codec parameters of the stream submitted to the muxer, which may be different from the codec parameters in AVStream due to bitstream filtering. This avoids the confusing back and forth synchronisation between the encoder, bitstream filters, and the muxer, now information flows only in one direction. It also reduces the need for non-muxing code to access AVStream.
* fftools/ffmpeg: store stream media type in OutputStreamAnton Khirnov2023-04-171-6/+5
| | | | | | | | | Reduces access to a deeply nested muxer property OutputStream.st->codecpar->codec_type for this fundamental and immutable stream property. Besides making the code shorter, this will allow making the AVStream (OutputStream.st) private to the muxer in the future.
* fftools/ffmpeg_mux: make data_size_mux private to ffmpeg_muxAnton Khirnov2023-04-131-2/+3
| | | | It is no longer used outside of this file.
* fftools/ffmpeg: rewrite printing the final output sizesAnton Khirnov2023-04-131-3/+33
| | | | | | | | | | Current code in print_final_stats(), printing the final summary such as video:8851kB audio:548kB subtitle:0kB other streams:0kB global headers:20kB muxing overhead: 0.559521% was written with a single output file in mind and makes very little sense otherwise. Print this information in mux_final_stats() instead, one line per output file. Use the correct filesize, if available.
* fftools/ffmpeg_mux: log final stats to muxer contextAnton Khirnov2023-04-131-8/+8
|
* fftools/ffmpeg_mux: reindentAnton Khirnov2023-04-131-28/+28
|
* fftools/ffmpeg: move printing verbose muxing stats to ffmpeg_muxAnton Khirnov2023-04-131-0/+37
| | | | This is a more appropriate place for this.
* fftools/ffmpeg: factorize checking whether any output was writtenAnton Khirnov2023-04-131-0/+43
| | | | | | | | | | | | | | This is currently done in two places: * at the end of print_final_stats(), which merely prints a warning if the total size of all written packets is zero * at the end of transcode() (under a misleading historical 'close each encoder' comment), which instead checks the packet count to implement -abort_on empty_output[_stream] Consolidate both of these blocks into a single function called from of_write_trailer(), which is a more appropriate place for this. Also, return an error code rather than exit immediately, which ensures all output files are properly closed.
* fftools/ffmpeg: eliminate the main_return_code globalAnton Khirnov2023-04-131-7/+5
| | | | | | | | Properly pass muxing return codes through the call stack instead. Slightly changes behavior in case of errors: * the output IO stream is closed even if writing the trailer returns an error, which should be more correct * all files get properly closed with -xerror, even if one of them fails
* fftools/ffmpeg: move OutputStream.sq_frame to EncoderAnton Khirnov2023-04-131-1/+0
| | | | | It is audio/video encoding-only and does not need to be visible outside of ffmpeg_enc.c
* fftools/ffmpeg: add encoder private dataAnton Khirnov2023-04-091-1/+2
| | | | | Start by moving OutputStream.last_frame to it. In the future it will hold other encoder-internal state.
* fftools/sync_queue: use timebase from input frames/packetsAnton Khirnov2023-04-091-3/+0
| | | | | They are always properly set now. Avoid a separate timebase-setting call, which duplicates the knowledge of the timebase being used.
* fftools/ffmpeg_mux: distinguish between sync queue and muxer EOFAnton Khirnov2023-02-101-5/+9
| | | | | | | Individual streams should be terminated in the former case, the whole muxing process in the latter. Reported-by: Gyan Doshi
* fftools/ffmpeg: add an option for writing pre-muxing statsAnton Khirnov2023-02-091-1/+9
| | | | | | Analogous to -enc_stats*, but happens right before muxing. Useful because bitstream filters and the sync queue can modify packets after encoding and before muxing. Also has access to the muxing timebase.
* fftools/ffmpeg: store output packet timebases in the packetAnton Khirnov2023-02-091-3/+4
| | | | Useful to keep track of what timebase the packet's timestamps are in.
* fftools/ffmpeg: add an AVClass to MuxStream/OutputStreamAnton Khirnov2023-01-291-7/+6
| | | | | Use it for logging. This makes log messages related to this output stream more consistent.
* fftools/ffmpeg: add an AVClass to Muxer/OutputFileAnton Khirnov2023-01-291-16/+10
| | | | | Use it for logging. This makes log messages related to this output file more consistent.
* fftools/ffmpeg: add options for writing encoding statsAnton Khirnov2023-01-291-0/+8
| | | | | | | Similar to -vstats, but more flexible: - works for audio as well as video - frame and/or packet information - user-specifiable format
* fftools/ffmpeg: avoid storing full forced keyframe specAnton Khirnov2022-11-281-1/+0
| | | | | It is not needed after the spec is parsed. Also avoids ugly string comparisons for each video frame.
* fftools/ffmpeg: parse forced keyframes in of_open()Anton Khirnov2022-11-281-8/+0
| | | | Allows to remove the ugly of_get_chapters() wrapper.
* fftools/ffmpeg: move force-keyframe-related vars to a separate structAnton Khirnov2022-11-281-3/+4
| | | | | | There are 8 of them and they are typically used together. Allows to pass just this struct to forced_kf_apply(), which makes it clear that the rest of the OutputStream is not accessed there.
* fftools/ffmpeg_mux_init: postpone matching -disposition to streamsAnton Khirnov2022-11-231-1/+0
| | | | | | | | | Do it in set_dispositions() rather than during stream creation. Since at this point all other stream information is known, this allows setting disposition based on metadata, which implements #10015. This also avoids an extra allocated string in OutputStream that was unused after of_open().
* fftools/ffmpeg: move OutputStream.max_frames to MuxStreamAnton Khirnov2022-11-171-5/+0
| | | | It no longer needs to be visible outside of the muxing code.
* fftools/ffmpeg: set thread namesAnton Khirnov2022-10-241-0/+9
|
* fftools/ffmpeg_mux: move muxing queue fields from OutputStream to MuxStreamAnton Khirnov2022-10-181-2/+2
| | | | | They are private to the muxer and do not need to be visible outside of it.
* fftools/ffmpeg_mux: move bsf_ctx from OutputStream to MuxStreamAnton Khirnov2022-10-181-7/+10
| | | | | It is private to the muxer and does not need to be visible outside of it.
* fftools/ffmpeg_mux: embed OutputStream in a MuxStreamAnton Khirnov2022-10-181-16/+17
| | | | | | | | This is now possible since OutputStream is a child of OutputFile and the code allocating it can access MuxStream. Avoids the overhead and extra complexity of allocating two objects instead of one. Similar to what was previously done for OutputFile/Muxer.
* fftools/ffmpeg: free output streams in of_close()Anton Khirnov2022-10-181-0/+51
| | | | | Output streams are now children of OutputFile, so it makes more sense to free them there.
* fftools/ffmpeg: remove the output_streams globalAnton Khirnov2022-10-181-5/+5
| | | | | | | Replace it with an array of streams in each OutputFile. This is a more accurate reflection of the actual relationship between OutputStream and OutputFile. This is easier to handle and will allow further simplifications in future commits.
* fftools/ffmpeg: move init_output_bsfs() to ffmpeg_muxAnton Khirnov2022-10-181-0/+38
| | | | | Bitstream filtering is done as a part of muxing, so this is the more proper place for this.
* fftools/ffmpeg_mux: move sq_mux from OutputFile to MuxerAnton Khirnov2022-10-181-4/+4
| | | | | It is internal to ffmpeg_mux* and does not need to be visible to other code.
* fftools/ffmpeg_mux: inline mux_free() into of_close()Anton Khirnov2022-10-181-18/+13
| | | | mux_free() is no longer called from anywhere else.
* fftools/ffmpeg_mux: inline of_muxer_init() into of_open()Anton Khirnov2022-10-181-51/+5
| | | | | A separate muxer init is no longer necessary, now that of_open() has access to Muxer.
* fftools/ffmpeg_mux: allocate sq_pkt in setup_sync_queues()Anton Khirnov2022-10-181-8/+0
| | | | This is now possible since setup_sync_queues() can interact with Muxer.
* fftools/ffmpeg_mux: embed OutputFile in a MuxerAnton Khirnov2022-10-181-65/+63
| | | | | | | | This is now possible since the code allocating OutputFile can see sizeof(Muxer). Avoids the overhead and extra complexity of allocating two objects instead of one. Similar to what is done e.g. for AVStream/FFStream in lavf.
* fftools/ffmpeg_mux: move Muxer and MuxStream to a new headerAnton Khirnov2022-10-181-35/+1
| | | | This will allow ffmpeg_mux_init.c to work with these structs.