summaryrefslogtreecommitdiff
path: root/fftools/ffmpeg.c
Commit message (Collapse)AuthorAgeFilesLines
* fftools/ffmpeg: rename transcode_init()Anton Khirnov2023-05-151-14/+4
| | | | | | | It does no initialization anymore, except for setting transcode_init_done - the bulk of the function is printing the input/output maps. It also cannot fail anymore, so remove the useless return value.
* fftools/ffmpeg: stop accessing input format from decoding codeAnton Khirnov2023-05-151-3/+2
| | | | | | Export the corresponding flag in InputFile instead. This will allow making the demuxer AVFormatContext private in future commits, similarly to what was previously done for muxers.
* fftools/ffmpeg: log corrupt-frame errors to the appropriate contextAnton Khirnov2023-05-151-2/+2
|
* fftools/ffmpeg: replace print_error() by more meaningful messagesAnton Khirnov2023-05-151-3/+2
|
* fftools/ffmpeg: move discarding unused programs to ffmpeg_demuxAnton Khirnov2023-05-151-16/+0
| | | | This is a more appropriate place for this code.
* fftools/ffmpeg: simplify tracking -readrate start timeAnton Khirnov2023-05-151-8/+0
| | | | | | There is no point in having a per-stream wallclock start time, since they are all computed at the same instant. Keep a per-file start time instead, initialized when the demuxer thread starts.
* fftools/ffmpeg: drop unused decode_video() parameterAnton Khirnov2023-05-151-4/+2
|
* fftools/ffmpeg: move post-demux packet processing to ffmpeg_demuxAnton Khirnov2023-05-151-188/+0
| | | | | | | | | | | | That is a more appropriate place for this code and will allow hiding more of InputStream. The value of repeat_pict extracted from libavformat internal parser no longer needs to be trasmitted outside of the demuxing thread. Move readrate handling to the demuxer thread. This has to be done in the same commit, since it reads InputStream.dts,nb_packets, which are now set in the demuxer thread.
* fftools/ffmpeg: attach InputStream.dts to demuxed packets when neededAnton Khirnov2023-05-151-2/+20
| | | | | | This way computing it and using it for streamcopy does not need to happen in sync. Will be useful in following commits, where updating InputStream.dts will be moved to the demuxing thread.
* fftools/ffmpeg: stop using decoder properties in ist_dts_update()Anton Khirnov2023-05-151-3/+3
| | | | | | This code runs post-demuxing and is not synchronized with the decoder output (which may be delayed with respect to its input by arbitrary and unknowable amounts), so accessing any decoder properties is incorrect.
* fftools/ffmpeg: reindent after previous commitAnton Khirnov2023-05-151-29/+29
|
* fftools/ffmpeg: consolidate InputStream.[next_]dts updatesAnton Khirnov2023-05-151-50/+55
| | | | | | Move them to a separate function called right after timestamp discontinuity processing. This is now possible, since these values have no interaction with decoding anymore.
* fftools/ffmpeg: stop using deprecated ticks_per_frameAnton Khirnov2023-05-151-6/+7
|
* fftools/ffmpeg: fix computing video frame duration from repeat_pictAnton Khirnov2023-05-151-4/+4
| | | | | This field contains the number of _field_ durations by which the standard frame duration should be extended.
* fftools/ffmpeg: discard packets for unused streams in demuxing threadAnton Khirnov2023-05-081-4/+0
| | | | Avoids the pointless overhead of transferring them to the main thread.
* fftools/ffmpeg: move unconfigured graph handling to ffmpeg_filterAnton Khirnov2023-05-081-24/+1
| | | | This code more properly belongs there.
* fftools/ffmpeg_filter: take fallback parameters from decoder, not demuxerAnton Khirnov2023-05-081-18/+0
| | | | | | | | | | When an input stream terminates and no frames were successfully decoded, filtering code will currently configure the filtergraph using demuxer stream parameters. Use decoder parameters instead, which should be more reliable. Also, initialize them immediately when an input stream is bound to a filtergraph input, so that these parameters are always available (if at all) and filtering code does not need to reach into the decoder at some arbitrary later point.
* fftools/ffmpeg: eliminate need_output()Anton Khirnov2023-05-081-28/+10
| | | | Replace it by simply calling choose_output() earlier.
* fftools/ffmpeg: merge choose_output() and got_eagain()Anton Khirnov2023-05-081-22/+19
| | | | | | | These two functions are a part of a single logical action - determining which, if any, output stream needs to be processed next. Keeping them separate is a historical artifact that obscures what is actually being done.
* fftools/ffmpeg: reduce -re to -readrate 1Anton Khirnov2023-05-071-1/+1
| | | | | They are exactly equivalent, so there is no point in maintaining a separate flag for -re.
* fftools: use the new AVFrame keyframe flagJames Almer2023-05-041-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* fftools: use the new AVFrame interlace flagsJames Almer2023-05-041-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* fftools/ffmpeg: always use the same path for setting InputStream.[next_]dtsAnton Khirnov2023-05-021-29/+5
| | | | | | | | | | | | | | | | | | | | | Currently those are set in different ways depending on whether the stream is decoded or not, using some values from the decoder if it is. This is wrong, because there may be arbitrary amount of delay between input packets and output frames (depending e.g. on the thread count when frame threading is used). Always use the path that was previously used only for streamcopy. This should not cause any issues, because these values are now used only for streamcopy and discontinuity handling. This change will allow to decouple discontinuity processing from decoding and move it to ffmpeg_demux. It also makes the code simpler. Changes output in fate-cover-art-aiff-id3v2-remux and fate-cover-art-mp3-id3v2-remux, where attached pictures are now written in the correct order. This happens because InputStream.dts is no longer reset to AV_NOPTS_VALUE after decoding, so streamcopy actually sees valid dts values.
* fftools/ffmpeg: constify packets passed to decode*()Anton Khirnov2023-05-021-4/+4
| | | | They are not modified by these functions.
* fftools/ffmpeg: drop InputStream.[next_]ptsAnton Khirnov2023-05-021-19/+1
| | | | They are no longer used for anything.
* fftools/ffmpeg_filter: stop using InputStream.pts for filter EOF tsAnton Khirnov2023-05-021-1/+3
| | | | Use InputStream.last_frame_pts/duration instead, which is more accurate.
* fftools/ffmpeg: stop using InputStream.pts for generating video timestampsAnton Khirnov2023-05-021-5/+2
| | | | | | | This was added in 380db569287ba99d903b7629f209b9adc7fd2723 as a temporary crutch that is not needed anymore. The only case where this code can be triggered is the very first frame, for which InputStream.pts is always equal to 0.
* fftools/ffmpeg: rework audio-decode timestamp handlingAnton Khirnov2023-05-021-17/+81
| | | | | | | | | | | | | | | | | | | | | Stop using InputStream.dts for generating missing timestamps for decoded frames, because it contains pre-decoding timestamps and there may be arbitrary amount of delay between input packets and output frames (e.g. dependent on the thread count when frame threading is used). It is also in AV_TIME_BASE (i.e. microseconds), which may introduce unnecessary rounding issues. New code maintains a timebase that is the inverse of the LCM of all the samplerates seen so far, and thus can accurately represent every audio sample. This timebase is used to generate missing timestamps after decoding. Changes the result of the following FATE tests * pcm_dvd-16-5.1-96000 * lavf-smjpeg * adpcm-ima-smjpeg In all of these the timestamps now better correspond to actual frame durations.
* fftools/ffmpeg: set AVFrame.time_base for decoded framesAnton Khirnov2023-05-021-10/+12
| | | | Makes it easier to keep track of the timebase the frames are in.
* fftools/ffmpeg: stop using packet pts for decoded audio frame ptsAnton Khirnov2023-05-021-3/+0
| | | | | | | | | | If input packets have timestamps, they will be propagated to output frames by the decoder, so at best this block does not do anything. There can also be an arbitrary amount of delay between packets sent to the decoder and decoded frames (e.g. due to decoder's intrinsic delay or frame threading), so deriving any timestamps from packet properties is wrong.
* fftools/ffmpeg_filter: use correct timebase for filter EOF timestampAnton Khirnov2023-05-021-4/+1
| | | | It does not need to be equal to demuxer timebase.
* fftools/ffmpeg: drop undocumented runtime debug-settingAnton Khirnov2023-05-021-35/+0
| | | | | This feature is of highly questionable usefulness and - as the comment in the code says - is not actually supported by the API.
* fftools/ffmpeg: reduce access to OutputStream.enc_ctxAnton Khirnov2023-05-021-4/+3
| | | | It will be made private to Encoder in the future.
* fftools/ffmpeg: move freeing a filtergraph into a separate functionAnton Khirnov2023-04-241-39/+3
|
* fftools/ffmpeg: move filtering functions to ffmpeg_filterAnton Khirnov2023-04-241-215/+1
|
* fftools/ffmpeg: replace stream timebase with packet one where appropriateAnton Khirnov2023-04-241-18/+18
|
* fftools/ffmpeg: stop setting InputStream.pts for streamcopyAnton Khirnov2023-04-241-1/+0
| | | | | It is not used in that case anymore. Forgotten in d56652fdc8e1315309516be320a7250854550fa5.
* fftools/ffmpeg: stop using InputStream.pts in ts_discontinuity_detect()Anton Khirnov2023-04-241-1/+1
| | | | | | | ts_discontinuity_detect() is applied right after demuxing, while InputStream.pts is a post-decoding timestamp, which may be delayed with respect to demuxing by an arbitrary amount (e.g. depending on the thread count when frame threading is used).
* fftools/ffmpeg: stop printing PSNR information in status reportAnton Khirnov2023-04-241-30/+0
| | | | | | | | | | | | | | When an encoder exports sum-of-squared-differences information in encoded packets, print_report() will print PSNR information in the status line. However, * the code computing PSNR assumes 8bit 420 video and prints incorrect values otherwise; there are no issues on trac about this * only a few encoders (namely aom, vpx, mpegvideo, snow) export this information; other often-used encoders such as libx26[45] do not export this, even though they could This suggests that this feature is not useful and it is better to remove it rather than spend effort on fixing it.
* fftools/ffmpeg_mux: stop using filter_in_rescale_delta_last for streamcopyAnton Khirnov2023-04-171-1/+1
| | | | | | | | | | | | | 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: move do_streamcopy() to ffmpeg_muxAnton Khirnov2023-04-171-80/+1
| | | | | | 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: store stream media type in OutputStreamAnton Khirnov2023-04-171-2/+2
| | | | | | | | | 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: initialize no-filter streams earlierAnton Khirnov2023-04-171-34/+0
| | | | | There is no reason to postpone it until transcode_init() anymore, it can be done right at the end of of_open().
* fftools/ffmpeg: open decoders right after we know they are neededAnton Khirnov2023-04-171-5/+0
| | | | Will allow initializing subtitle encoding earlier.
* fftools/ffmpeg: move opening decoders to a new fileAnton Khirnov2023-04-171-110/+1
| | | | All decoding code will be moved to this file in the future.
* fftools/ffmpeg: drop unnecessary indirectionAnton Khirnov2023-04-171-15/+11
| | | | | | | | init_input_stream() can print log messages directly, there is no need to ship them to the caller. Also, log errors to the InputStream and avoid duplicate information in the message.
* fftools/ffmpeg: move a check to a more appropriate placeAnton Khirnov2023-04-171-20/+1
| | | | reap_filters() no longer needs to access the encoding context.
* fftools/ffmpeg: move a misplaced assignmentAnton Khirnov2023-04-171-3/+0
| | | | | | Changing AVCodecContext.sample_aspect_ratio after the encoder was opened is by itself questionable, but if anywhere it belongs in encoding rather than filtering code.
* fftools/ffmpeg: move init_output_stream_streamcopy() to ffmpeg_mux_initAnton Khirnov2023-04-171-136/+0
| | | | | Everything in it can be done immediately when creating the output stream, there is no reason to postpone it.
* ffmpeg: make timestamp discontinuity logging a warningNongji Chen2023-04-141-1/+1
| | | | | | | | In most cases this should only occur once or so per stream in an input, and in case the logic ends up in an eternal loop, it should be visible to the end user instead of being completely invisible. Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>