aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_mux.c
Commit message (Collapse)AuthorAgeFilesLines
* fftools/ffmpeg_mux: move OutputStream.enc_ctx to EncoderAnton Khirnov2024-09-301-6/+2
| | | | | The encoding AVCodecContext is a part of the encoder, and so should live there.
* fftools/ffmpeg_enc: split Encoder into a private and public partAnton Khirnov2024-09-301-2/+2
| | | | | | | Similar to what was previously done for other components, e.g. decoders (see 3b84140a1bb5a5b3044915888a40a7b619921633). Start by moving {samples,frames}_encoded into the public struct.
* fftools/ffmpeg_enc: don't write frame rate/SAR to AVStream directlyAnton Khirnov2024-09-261-0/+3
| | | | | | | Have the muxer code read them out of the encoder context in of_stream_init() instead. This is a step towards decoupling encoders from muxers.
* fftools/ffmpeg_enc: do not set output stream codec parameters directlyAnton Khirnov2024-09-261-3/+10
| | | | | | | | | | Have the muxer code read them out of the encoder context in of_stream_init() instead. OutputStream.par_in no longer needs to be public, so can be moved to MuxStream. This is a step towards decoupling encoders from muxers.
* fftools/ffmpeg_enc: do not set AVStream timebase directlyAnton Khirnov2024-09-261-1/+8
| | | | | | | | Instead, pass the encoder context to of_stream_init() and have the muxer take the timebase from there. Note that the muxer can currently access the codec context directly, but that will change in future commits. This is a step towards decoupling encoders from muxers.
* fftools/ffmpeg_mux_init: make encoder_opts local to ost_add()Anton Khirnov2024-07-031-1/+0
| | | | It is no longer needed after this function returns.
* fftools/ffmpeg: rewrite checking whether codec AVOptions have been usedAnton Khirnov2024-07-031-0/+1
| | | | | | Share the code between encoding and decoding. Instead of checking every stream's options dictionary (which is also used for other purposes), track all used options in a dedicated dictionary.
* fftools/ffmpeg_mux: Remove unneeded initializationMichael Niedermayer2024-07-021-2/+1
| | | | | | | | | Not sure this change makes sense, the code is more robust with ret set Fixes: CID1559178 Unused value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* fftools/ffmpeg_filter: only store complex filtergraphs in global arrayAnton Khirnov2024-04-091-0/+1
| | | | | Store simple filtergraphs in the stream they feed. Keeping the two separate will be useful in following commits.
* fftools/ffmpeg_mux: drop OutputFile.formatAnton Khirnov2024-04-091-6/+9
| | | | | It is no longer used outside of the muxing code (where we can access the muxer directly).
* fftools/ffmpeg_filter: move most of -apad logic to the muxerAnton Khirnov2024-04-091-1/+0
| | | | | | The decision whether -apad actually does anything is made based on muxer properties, and so more properly belongs there. Filtering code only receives the result.
* fftools/ffmpeg_filter: pass sws/swr opts through OutputFilterOptionsAnton Khirnov2024-04-091-3/+0
| | | | | | Do not read them from OutputStream directly. Will allow decoupling filtering from encoding in future commits.
* fftools/ffmpeg_filter: pass vsync method through OutputFilterOptionsAnton Khirnov2024-04-091-1/+1
| | | | | | Do not read it from OutputStream directly. Will allow decoupling filtering from encoding in future commits.
* fftools/ffmpeg_enc: set AV_PKT_FLAG_TRUSTED on encoded packetsAnton Khirnov2024-03-131-0/+1
| | | | | | | | This allows using WRAPPED_AVFRAME encoders with loopback decoders in order to connect multiple filtergraphs together. Clear the flag in muxers, since lavf does not need it for anything and it would change the results of framecrc FATE tests.
* fftools/ffmpeg: remove unncessary casts for *_thread() return valuesAnton Khirnov2024-03-131-2/+2
| | | | | | These functions used to be passed directly to pthread_create(), which required them to return void*. This is no longer the case, so they can return a plain int.
* fftools/ffmpeg: remove options deprecated before 6.0Anton Khirnov2024-03-011-5/+0
|
* fftools/ffmpeg_mux: Fix use of uninitialized variableAndreas Rheinhardt2024-02-251-2/+2
| | | | | | | Broken in a2fc86378a18b2c2966ce3438df8f27f646438e5. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* fftools/ffmpeg: declare loop indices inside loopsAnton Khirnov2024-02-241-2/+1
|
* fftools/ffmpeg_mux_init: Fix attachment_filename use-after-freeAndreas Rheinhardt2024-02-181-0/+2
| | | | | | | | | | | | | | The filename is freed with the OptionsContext and therefore there will be a use-after-free when reporting the filename in print_stream_maps(). So create a copy of the string. This is a regression since 8aed3911fc454e79697e183660bf30d31334a64b. fate-lavf-mkv_attachment exhibits it (and reports a random nonsense filename here), but this does not make the test fail (not even with valgrind; only with ASAN, as it aborts on use-after-free). Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* fftools/ffmpeg_mux: fix terminating muxer on streamcopy with -tAnton Khirnov2024-02-051-2/+2
| | | | Reported-by: Andreas Rheinhardt
* fftools/ffmpeg: use correct unit prefix symbol for binary scaled byte values王昊然2024-02-031-2/+2
| | | | | | Fix bug #10501 Signed-off-by: WHR <msl0000023508@gmail.com>
* fftools/ffmpeg: use a mutex for enc_stats_write()Anton Khirnov2023-12-181-0/+4
| | | | | It may be called concurrently from different threads to write into the same file.
* fftools/ffmpeg_mux: deduplicate uniniting EncStatsAnton Khirnov2023-12-181-11/+10
|
* fftools/ffmpeg_mux: factor timestamps processing out of write_packet()Anton Khirnov2023-12-181-20/+30
|
* fftools/ffmpeg: deprecate -fps_mode/vsync dropAnton Khirnov2023-12-181-0/+2
| | | | | It depends on the ability of muxers to generate timestamps, which is itself deprecated.
* fftools/ffmpeg_mux: stop logging to AVFormatContextAnton Khirnov2023-12-181-7/+6
| | | | | | | Only the muxer itself is supposed to do that. Log to OutputStream instead. Drop now-redundant information from the logged string.
* fftools/ffmpeg: drop OutputFile.sq_encodeAnton Khirnov2023-12-141-1/+0
| | | | It is unused since d119ae2fd82a494d9430ff4d4fc262961a68c598
* fftools/ffmpeg_mux: move OutputStream.sq_idx_mux to private dataAnton Khirnov2023-12-141-6/+6
| | | | It should not be accessed outside of ffmpeg_mux*
* fftools/ffmpeg: replace OutputStream.file_index by a pointerAnton Khirnov2023-12-141-6/+5
| | | | Reduces the need to use the output_files global array.
* fftools/ffmpeg_mux: print latency information in -debug_ts muxing outputAnton Khirnov2023-12-141-10/+78
|
* fftools/ffmpeg: merge DemuxPktData into FrameDataAnton Khirnov2023-12-141-2/+2
| | | | | This way we can propagate arbitrary data from the demuxer all the way into the muxer, using a single struct.
* fftools/ffmpeg: convert to a threaded architectureAnton Khirnov2023-12-121-262/+62
| | | | | | | | | | Change the main loop and every component (demuxers, decoders, filters, encoders, muxers) to use the previously added transcode scheduler. Every instance of every such component was already running in a separate thread, but now they can actually run in parallel. Changes the results of ffmpeg-fix_sub_duration_heartbeat - tested by JEEB to be more correct and deterministic.
* fftools/ffmpeg: add thread-aware transcode scheduling infrastructureAnton Khirnov2023-12-121-7/+10
| | | | | | | | | | | | | | | See the comment block at the top of fftools/ffmpeg_sched.h for more details on what this scheduler is for. This commit adds the scheduling code itself, along with minimal integration with the rest of the program: * allocating and freeing the scheduler * passing it throughout the call stack in order to register the individual components (demuxers/decoders/filtergraphs/encoders/muxers) with the scheduler The scheduler is not actually used as of this commit, so it should not result in any change in behavior. That will change in future commits.
* fftools/ffmpeg_mux: move bitstream filtering to the muxer threadAnton Khirnov2023-12-121-45/+67
| | | | | This will be the appropriate place for it after the rest of transcoding is switched to a threaded architecture.
* fftools/ffmpeg_mux: add muxing thread private dataAnton Khirnov2023-12-121-9/+35
| | | | | To be used for data that never needs to be visible outside of the muxer thread. Start by moving the muxed AVPacket in there.
* fftools/ffmpeg: move a few inline function into a new headerAnton Khirnov2023-11-141-0/+1
| | | | | Will allow to use them in future commits without including the whole ffmpeg.h.
* fftools/ffmpeg_mux: replace monotonous with monotonicLeo Izen2023-09-011-1/+1
| | | | | | | The word "monotonous" means "spoken in a monotone" which is not what we mean here. We mean "monotonic" i.e. nondecreasing. Signed-off-by: Leo Izen <leo.izen@gmail.com>
* fftools/ffmpeg_mux: rename of_close() to of_free()Anton Khirnov2023-08-301-1/+1
| | | | | | This function is primarily a destructor for OutputFile, the underlying AVIOContext is normally closed earlier (right after writing the trailer).
* fftools/ffmpeg_mux: stop rescaling timestamps in of_streamcopy()Anton Khirnov2023-08-301-21/+23
| | | | | | | | | | | | | | | | This function converts packet timestamps from the input stream timebase to OutputStream.mux_timebase, which may or may not be equal to the actual output AVStream timebase (and even when it is, this may not always be the optimal choice due to bitstream filtering). Just keep the timestamps in input stream timebase, they will be rescaled as needed before bitstream filtering and/or sending the packet to the muxer. Move the av_rescale_delta() call for audio (needed to preserve accuracy with coarse demuxer timebases) to write_packet. Drop now-unused OutputStream.mux_timebase.
* fftools/ffmpeg_mux: use correct timebases for bitstream filteringAnton Khirnov2023-08-301-6/+6
| | | | | | | | | | Bitstream filtering input timebase is not always necessarily equal to OutputStream.mux_timebase. Also, set AVPacket.time_base correctly for packets output by bitstream filters Do not rescale at all in of_output_packet() when not doing bitstream filtering, as it's unnecessary - write_packet() will rescale to the actual muxer timebase.
* fftools/ffmpeg_mux: return errors from of_output_packet() instead of abortingAnton Khirnov2023-07-201-11/+9
|
* fftools/ffmpeg_mux: return errors from of_streamcopy() instead of abortingAnton Khirnov2023-07-151-8/+12
|
* fftools/ffmpeg_mux: forward EOF from the sync queueAnton Khirnov2023-07-131-2/+8
| | | | | | | EOF from sq_receive() means no packets will ever be output by the sync queue. Since the muxing sync queue is always used by all interleaved (i.e. non-attachment) streams, this means no further packets can make it to the muxer and we can terminate muxing now.
* fftools/ffmpeg_dec: move decoding to a separate threadAnton Khirnov2023-06-191-5/+0
| | | | | | | | | | This is only a preparatory step to a fully threaded architecture and does not yet make decoding truly parallel - the main thread will currently submit a packet and wait until it has been fully processed by the decoding thread before moving on. Decoder behavior as observed by the rest of the program should remain unchanged. That will change in future commits after encoders and filters are moved to threads and a thread-aware scheduler is added.
* fftools/ffmpeg_mux: make OutputStream.pkt privateAnton Khirnov2023-06-051-2/+2
| | | | It is no longer used outside of muxing code.
* fftools/ffmpeg_mux: simplify calling of_output_packet()Anton Khirnov2023-06-051-7/+7
| | | | | Use NULL packets to signal EOF instead of a separate variable. This is made possible by the previous commit.
* fftools/ffmpeg_mux: use a dedicated packet for BSF outputAnton Khirnov2023-06-051-2/+7
| | | | | | Currently of_output_packet() reuses the input packet, which requires its callers to submit blank packets even on EOF, which makes the code more complex.
* fftools/ffmpeg: convert timestamps inside the muxerAnton Khirnov2023-06-051-0/+6
| | | | | | Packets submitted to the muxer now have their timebase attached to them, so the muxer can do conversion to muxing timebase and avoid exposing it to callers.
* fftools/ffmpeg_mux: set stream duration after the timebase is certainly knownAnton Khirnov2023-06-051-0/+5
| | | | | Stop assuming the encoder knows the muxing timebase, which does not always have to hold (e.g. due to bitstream filters).
* fftools/ffmpeg_mux: flush bsfs immediately on exceeding recoding timeAnton Khirnov2023-05-311-6/+5
| | | | | | Current code marks the output stream as finished and waits for a flush packet, but that is both unnecessary and suspect, as in theory nothing should be sent to a finished stream - not even flush packets.