diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-11-24 19:08:15 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-12-14 08:11:05 +0100 |
commit | 9d7000b1bea097d715166e93475c71a0fb237f05 (patch) | |
tree | 8c5fc7d07e595ed4e8813e7cc67d7c23b1e081f6 /fftools/ffmpeg_enc.c | |
parent | c9f38210fc498ada2605a1faac8aceb3d76e69c6 (diff) | |
download | ffmpeg-9d7000b1bea097d715166e93475c71a0fb237f05.tar.gz |
fftools/ffmpeg: attach wallclock timing information to packets and frames
Will become useful in following commits.
Diffstat (limited to 'fftools/ffmpeg_enc.c')
-rw-r--r-- | fftools/ffmpeg_enc.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 320df2dee7..43e8b077eb 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -34,6 +34,7 @@ #include "libavutil/log.h" #include "libavutil/pixdesc.h" #include "libavutil/rational.h" +#include "libavutil/time.h" #include "libavutil/timestamp.h" #include "libavcodec/avcodec.h" @@ -615,6 +616,14 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame, int ret; if (frame) { + FrameData *fd = frame_data(frame); + + fd = frame_data(frame); + if (!fd) + return AVERROR(ENOMEM); + + fd->wallclock[LATENCY_PROBE_ENC_PRE] = av_gettime_relative(); + if (ost->enc_stats_pre.io) enc_stats_write(ost, &ost->enc_stats_pre, frame, NULL, ost->frames_encoded); @@ -644,6 +653,8 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame, } while (1) { + FrameData *fd; + av_packet_unref(pkt); ret = avcodec_receive_packet(enc, pkt); @@ -665,6 +676,11 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame, return ret; } + fd = packet_data(pkt); + if (!fd) + return AVERROR(ENOMEM); + fd->wallclock[LATENCY_PROBE_ENC_POST] = av_gettime_relative(); + if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { ret = update_video_stats(ost, pkt, !!vstats_filename); if (ret < 0) |