summaryrefslogtreecommitdiff
path: root/fftools/sync_queue.c
Commit message (Collapse)AuthorAgeFilesLines
* fftools/sync_queue: update audio frame duration when re-chunkingAnton Khirnov2023-04-191-1/+5
|
* fftools/sync_queue: allow requesting a specific number of audio samplesAnton Khirnov2023-04-091-9/+175
| | | | This will be made useful in following commits.
* fftools/sync_queue: make sure audio duration matches sample countAnton Khirnov2023-04-091-1/+14
| | | | | | | | | For audio AVFrames, nb_samples is typically more trustworthy than duration. Since sync queues look at durations, make sure they match the sample count. The last audio frame in the fate-shortest test is now gone. This is more correct, since it outlasts the last video frame.
* fftools/sync_queue: support operation with no limiting streamsAnton Khirnov2023-04-091-1/+6
| | | | | ffmpeg CLI will not create such queues currently, but this will become useful in following commits.
* fftools/sync_queue: document overall designAnton Khirnov2023-04-091-0/+35
|
* fftools/sync_queue: use timebase from input frames/packetsAnton Khirnov2023-04-091-17/+22
| | | | | They are always properly set now. Avoid a separate timebase-setting call, which duplicates the knowledge of the timebase being used.
* fftools/ffmpeg: replace AVFrame.pkt_duration with durationAnton Khirnov2022-07-241-1/+1
| | | | Mistakenly reintroduced in 4740fea7ddf.
* fftools/ffmpeg: use the sync queues to handle -framesAnton Khirnov2022-07-231-5/+28
| | | | | | | | | | | | | | | | 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-231-0/+425
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.