* [FFmpeg-devel] [PATCH 4/6] fftools/ffmpeg: drop OutputStream.enc
2022-08-25 8:59 [FFmpeg-devel] [PATCH 1/6] fftools/ffmpeg: remove a stale extern declaration Anton Khirnov
2022-08-25 8:59 ` [FFmpeg-devel] [PATCH 2/6] fftools/ffmpeg_filter: remove an always-false check Anton Khirnov
2022-08-25 8:59 ` [FFmpeg-devel] [PATCH 3/6] fftools/ffmpeg_filter: remove an always-true check Anton Khirnov
@ 2022-08-25 8:59 ` Anton Khirnov
2022-08-25 8:59 ` [FFmpeg-devel] [PATCH 5/6] fftools/ffmpeg: drop OutputStream.fps_mode Anton Khirnov
2022-08-25 8:59 ` [FFmpeg-devel] [PATCH 6/6] fftools/ffmpeg: use a separate counter for encoded packet data size Anton Khirnov
4 siblings, 0 replies; 6+ messages in thread
From: Anton Khirnov @ 2022-08-25 8:59 UTC (permalink / raw)
To: ffmpeg-devel
It is either equal to OutputStream.enc_ctx->codec, or NULL when enc_ctx
is NULL. Replace the use of enc with enc_ctx->codec, or the equivalent
enc_ctx->codec_* fields where more convenient.
---
fftools/ffmpeg.c | 27 +++++++++++++-------------
fftools/ffmpeg.h | 1 -
fftools/ffmpeg_filter.c | 13 +++++++------
fftools/ffmpeg_hw.c | 6 +++---
fftools/ffmpeg_opt.c | 43 ++++++++++++++++++++++++-----------------
5 files changed, 49 insertions(+), 41 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index ef7177fc33..4a825aa6b5 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2362,7 +2362,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output,
OutputStream *ost = output_streams[i];
if (!check_output_constraints(ist, ost) || !ost->enc_ctx
- || ost->enc->type != AVMEDIA_TYPE_SUBTITLE)
+ || ost->enc_ctx->codec_type != AVMEDIA_TYPE_SUBTITLE)
continue;
do_subtitle_out(output_files[ost->file_index], ost, &subtitle);
@@ -2865,13 +2865,14 @@ static int init_output_stream_streamcopy(OutputStream *ost)
static void set_encoder_id(OutputFile *of, OutputStream *ost)
{
+ const char *cname = ost->enc_ctx->codec->name;
uint8_t *encoder_string;
int encoder_string_len;
if (av_dict_get(ost->st->metadata, "encoder", NULL, 0))
return;
- encoder_string_len = sizeof(LIBAVCODEC_IDENT) + strlen(ost->enc->name) + 2;
+ encoder_string_len = sizeof(LIBAVCODEC_IDENT) + strlen(cname) + 2;
encoder_string = av_mallocz(encoder_string_len);
if (!encoder_string)
exit_program(1);
@@ -2880,7 +2881,7 @@ static void set_encoder_id(OutputFile *of, OutputStream *ost)
av_strlcpy(encoder_string, LIBAVCODEC_IDENT " ", encoder_string_len);
else
av_strlcpy(encoder_string, "Lavc ", encoder_string_len);
- av_strlcat(encoder_string, ost->enc->name, encoder_string_len);
+ av_strlcat(encoder_string, cname, encoder_string_len);
av_dict_set(&ost->st->metadata, "encoder", encoder_string,
AV_DICT_DONT_STRDUP_VAL | AV_DICT_DONT_OVERWRITE);
}
@@ -3007,9 +3008,9 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
!ost->frame_rate.den))
ost->frame_rate = ost->max_frame_rate;
- if (ost->enc->supported_framerates && !ost->force_fps) {
- int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);
- ost->frame_rate = ost->enc->supported_framerates[idx];
+ if (enc_ctx->codec->supported_framerates && !ost->force_fps) {
+ int idx = av_find_nearest_q_idx(ost->frame_rate, enc_ctx->codec->supported_framerates);
+ ost->frame_rate = enc_ctx->codec->supported_framerates[idx];
}
// reduce frame rate for mpeg4 to be within the spec limits
if (enc_ctx->codec_id == AV_CODEC_ID_MPEG4) {
@@ -3150,7 +3151,7 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame,
int ret = 0;
if (ost->enc_ctx) {
- const AVCodec *codec = ost->enc;
+ const AVCodec *codec = ost->enc_ctx->codec;
AVCodecContext *dec = NULL;
InputStream *ist;
@@ -3179,7 +3180,7 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame,
return ret;
}
- if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && ost->enc->type == AVMEDIA_TYPE_SUBTITLE) {
+ if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && codec->type == AVMEDIA_TYPE_SUBTITLE) {
int input_props = 0, output_props = 0;
AVCodecDescriptor const *input_descriptor =
avcodec_descriptor_get(dec->codec_id);
@@ -3206,8 +3207,8 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame,
ost->file_index, ost->index);
return ret;
}
- if (ost->enc->type == AVMEDIA_TYPE_AUDIO &&
- !(ost->enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE))
+ if (codec->type == AVMEDIA_TYPE_AUDIO &&
+ !(codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE))
av_buffersink_set_frame_size(ost->filter->filter,
ost->enc_ctx->frame_size);
assert_avoptions(ost->encoder_opts);
@@ -3419,7 +3420,7 @@ static int transcode_init(void)
av_log(NULL, AV_LOG_INFO, " (graph %d)", ost->filter->graph->index);
av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", ost->file_index,
- ost->index, ost->enc ? ost->enc->name : "?");
+ ost->index, ost->enc_ctx->codec->name);
continue;
}
@@ -3430,7 +3431,7 @@ static int transcode_init(void)
ost->index);
if (ost->enc_ctx) {
const AVCodec *in_codec = input_streams[ost->source_index]->dec;
- const AVCodec *out_codec = ost->enc;
+ const AVCodec *out_codec = ost->enc_ctx->codec;
const char *decoder_name = "?";
const char *in_codec_name = "?";
const char *encoder_name = "?";
@@ -3826,7 +3827,7 @@ static int process_input(int file_index)
OutputStream *ost = output_streams[j];
if (ost->source_index == ifile->ist_index + i &&
- (!ost->enc_ctx || ost->enc->type == AVMEDIA_TYPE_SUBTITLE)) {
+ (!ost->enc_ctx || ost->enc_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
OutputFile *of = output_files[ost->file_index];
output_packet(of, ost->pkt, ost, 1);
}
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 50654bf8db..68f24bd1d3 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -509,7 +509,6 @@ typedef struct OutputStream {
AVBSFContext *bsf_ctx;
AVCodecContext *enc_ctx;
- const AVCodec *enc;
int64_t max_frames;
AVFrame *filtered_frame;
AVFrame *last_frame;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index e9479018e4..ac8d81c8aa 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -90,6 +90,7 @@ choose_pixel_fmt(const AVCodec *codec, enum AVPixelFormat target,
static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint)
{
OutputStream *ost = ofilter->ost;
+ AVCodecContext *enc = ost->enc_ctx;
const AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
if (strict_dict)
// used by choose_pixel_fmt() and below
@@ -103,14 +104,14 @@ static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint)
return av_get_pix_fmt_name(ost->enc_ctx->pix_fmt);
}
if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
- return av_get_pix_fmt_name(choose_pixel_fmt(ost->enc, ost->enc_ctx->pix_fmt,
+ return av_get_pix_fmt_name(choose_pixel_fmt(enc->codec, enc->pix_fmt,
ost->enc_ctx->strict_std_compliance));
- } else if (ost->enc->pix_fmts) {
+ } else if (enc->codec->pix_fmts) {
const enum AVPixelFormat *p;
- p = ost->enc->pix_fmts;
+ p = enc->codec->pix_fmts;
if (ost->enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
- p = get_compliance_normal_pix_fmts(ost->enc, p);
+ p = get_compliance_normal_pix_fmts(enc->codec, p);
}
for (; *p != AV_PIX_FMT_NONE; p++) {
@@ -1095,8 +1096,8 @@ int configure_filtergraph(FilterGraph *fg)
for (i = 0; i < fg->nb_outputs; i++) {
OutputStream *ost = fg->outputs[i]->ost;
- if (ost->enc->type == AVMEDIA_TYPE_AUDIO &&
- !(ost->enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE))
+ if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO &&
+ !(ost->enc_ctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE))
av_buffersink_set_frame_size(ost->filter->filter,
ost->enc_ctx->frame_size);
}
diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c
index 8acfeaf08f..88fa782470 100644
--- a/fftools/ffmpeg_hw.c
+++ b/fftools/ffmpeg_hw.c
@@ -461,7 +461,7 @@ int hw_device_setup_for_encode(OutputStream *ost)
}
for (i = 0;; i++) {
- config = avcodec_get_hw_config(ost->enc, i);
+ config = avcodec_get_hw_config(ost->enc_ctx->codec, i);
if (!config)
break;
@@ -472,7 +472,7 @@ int hw_device_setup_for_encode(OutputStream *ost)
av_log(ost->enc_ctx, AV_LOG_VERBOSE, "Using input "
"frames context (format %s) with %s encoder.\n",
av_get_pix_fmt_name(ost->enc_ctx->pix_fmt),
- ost->enc->name);
+ ost->enc_ctx->codec->name);
ost->enc_ctx->hw_frames_ctx = av_buffer_ref(frames_ref);
if (!ost->enc_ctx->hw_frames_ctx)
return AVERROR(ENOMEM);
@@ -487,7 +487,7 @@ int hw_device_setup_for_encode(OutputStream *ost)
if (dev) {
av_log(ost->enc_ctx, AV_LOG_VERBOSE, "Using device %s "
"(type %s) with %s encoder.\n", dev->name,
- av_hwdevice_get_type_name(dev->type), ost->enc->name);
+ av_hwdevice_get_type_name(dev->type), ost->enc_ctx->codec->name);
ost->enc_ctx->hw_device_ctx = av_buffer_ref(dev->device_ref);
if (!ost->enc_ctx->hw_device_ctx)
return AVERROR(ENOMEM);
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 1ba7950bc1..1659cf55ba 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1513,18 +1513,21 @@ static int get_preset_file_2(const char *preset_name, const char *codec_name, AV
return ret;
}
-static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost)
+static int choose_encoder(OptionsContext *o, AVFormatContext *s,
+ OutputStream *ost, const AVCodec **enc)
{
enum AVMediaType type = ost->st->codecpar->codec_type;
char *codec_name = NULL;
+ *enc = NULL;
+
if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO || type == AVMEDIA_TYPE_SUBTITLE) {
MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st);
if (!codec_name) {
ost->st->codecpar->codec_id = av_guess_codec(s->oformat, NULL, s->url,
NULL, ost->st->codecpar->codec_type);
- ost->enc = avcodec_find_encoder(ost->st->codecpar->codec_id);
- if (!ost->enc) {
+ *enc = avcodec_find_encoder(ost->st->codecpar->codec_id);
+ if (!*enc) {
av_log(NULL, AV_LOG_FATAL, "Automatic encoder selection failed for "
"output stream #%d:%d. Default encoder for format %s (codec %s) is "
"probably disabled. Please choose an encoder manually.\n",
@@ -1533,8 +1536,8 @@ static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *o
return AVERROR_ENCODER_NOT_FOUND;
}
} else if (strcmp(codec_name, "copy")) {
- ost->enc = find_codec_or_die(codec_name, ost->st->codecpar->codec_type, 1);
- ost->st->codecpar->codec_id = ost->enc->id;
+ *enc = find_codec_or_die(codec_name, ost->st->codecpar->codec_type, 1);
+ ost->st->codecpar->codec_id = (*enc)->id;
}
}
@@ -1560,6 +1563,7 @@ static int check_opt_bitexact(void *ctx, const AVDictionary *opts,
static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index)
{
OutputStream *ost;
+ const AVCodec *enc;
AVStream *st = avformat_new_stream(oc, NULL);
int idx = oc->nb_streams - 1, ret = 0;
const char *bsfs = NULL, *time_base = NULL;
@@ -1583,15 +1587,15 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
ost->forced_kf_ref_pts = AV_NOPTS_VALUE;
st->codecpar->codec_type = type;
- ret = choose_encoder(o, oc, ost);
+ ret = choose_encoder(o, oc, ost, &enc);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Error selecting an encoder for stream "
"%d:%d\n", ost->file_index, ost->index);
exit_program(1);
}
- if (ost->enc) {
- ost->enc_ctx = avcodec_alloc_context3(ost->enc);
+ if (enc) {
+ ost->enc_ctx = avcodec_alloc_context3(enc);
if (!ost->enc_ctx) {
av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding context.\n");
exit_program(1);
@@ -1606,16 +1610,18 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
if (!ost->pkt)
exit_program(1);
- if (ost->enc) {
+ if (ost->enc_ctx) {
+ AVCodecContext *enc = ost->enc_ctx;
AVIOContext *s = NULL;
char *buf = NULL, *arg = NULL, *preset = NULL;
- ost->encoder_opts = filter_codec_opts(o->g->codec_opts, ost->enc->id, oc, st, ost->enc);
+ ost->encoder_opts = filter_codec_opts(o->g->codec_opts, enc->codec_id,
+ oc, st, enc->codec);
MATCH_PER_STREAM_OPT(presets, str, preset, oc, st);
ost->autoscale = 1;
MATCH_PER_STREAM_OPT(autoscale, i, ost->autoscale, oc, st);
- if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) {
+ if (preset && (!(ret = get_preset_file_2(preset, enc->codec->name, &s)))) {
AVBPrint bprint;
av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED);
do {
@@ -1729,7 +1735,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
av_dict_copy(&ost->sws_dict, o->g->sws_dict, 0);
av_dict_copy(&ost->swr_opts, o->g->swr_opts, 0);
- if (ost->enc && av_get_exact_bits_per_sample(ost->enc->id) == 24)
+ if (ost->enc_ctx && av_get_exact_bits_per_sample(ost->enc_ctx->codec_id) == 24)
av_dict_set(&ost->swr_opts, "output_sample_bits", "24", 0);
ost->source_index = source_index;
@@ -1985,7 +1991,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in
ost->logfile_prefix ? ost->logfile_prefix :
DEFAULT_PASS_LOGFILENAME_PREFIX,
nb_output_streams - 1);
- if (!strcmp(ost->enc->name, "libx264")) {
+ if (!strcmp(ost->enc_ctx->codec->name, "libx264")) {
av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE);
} else {
if (video_enc->flags & AV_CODEC_FLAG_PASS2) {
@@ -3033,6 +3039,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
/* set the filter output constraints */
if (ost->filter) {
+ const AVCodec *c = ost->enc_ctx->codec;
OutputFilter *f = ost->filter;
switch (ost->enc_ctx->codec_type) {
case AVMEDIA_TYPE_VIDEO:
@@ -3042,24 +3049,24 @@ static int open_output_file(OptionsContext *o, const char *filename)
if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
f->format = ost->enc_ctx->pix_fmt;
} else {
- f->formats = ost->enc->pix_fmts;
+ f->formats = c->pix_fmts;
}
break;
case AVMEDIA_TYPE_AUDIO:
if (ost->enc_ctx->sample_fmt != AV_SAMPLE_FMT_NONE) {
f->format = ost->enc_ctx->sample_fmt;
} else {
- f->formats = ost->enc->sample_fmts;
+ f->formats = c->sample_fmts;
}
if (ost->enc_ctx->sample_rate) {
f->sample_rate = ost->enc_ctx->sample_rate;
} else {
- f->sample_rates = ost->enc->supported_samplerates;
+ f->sample_rates = c->supported_samplerates;
}
if (ost->enc_ctx->ch_layout.nb_channels) {
av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels);
- } else if (ost->enc->ch_layouts) {
- f->ch_layouts = ost->enc->ch_layouts;
+ } else if (c->ch_layouts) {
+ f->ch_layouts = c->ch_layouts;
}
break;
}
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 6+ messages in thread
* [FFmpeg-devel] [PATCH 6/6] fftools/ffmpeg: use a separate counter for encoded packet data size
2022-08-25 8:59 [FFmpeg-devel] [PATCH 1/6] fftools/ffmpeg: remove a stale extern declaration Anton Khirnov
` (3 preceding siblings ...)
2022-08-25 8:59 ` [FFmpeg-devel] [PATCH 5/6] fftools/ffmpeg: drop OutputStream.fps_mode Anton Khirnov
@ 2022-08-25 8:59 ` Anton Khirnov
4 siblings, 0 replies; 6+ messages in thread
From: Anton Khirnov @ 2022-08-25 8:59 UTC (permalink / raw)
To: ffmpeg-devel
update_video_stats() currently uses OutputStream.data_size to print the
total size of the encoded stream so far and the average bitrate.
However, that field is updated in the muxer thread, right before the
packet is sent to the muxer. Not only is this racy, but the numbers may
not match even if muxing was in the main thread due to bitstream
filters, filesize limiting, etc.
Introduce a new counter, data_size_enc, for total size of the packets
received from the encoder and use that in update_video_stats(). Rename
data_size to data_size_mux to indicate its semantics more clearly.
No synchronization is needed for data_size_mux, because it is only read
in the main thread in print_final_stats(), which runs after the muxer
threads are terminated.
---
fftools/ffmpeg.c | 22 +++++++++++++---------
fftools/ffmpeg.h | 6 ++++--
fftools/ffmpeg_mux.c | 2 +-
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 4a825aa6b5..0bc97811b3 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -901,9 +901,9 @@ static void update_video_stats(OutputStream *ost, const AVPacket *pkt, int write
ti1 = 0.01;
bitrate = (pkt->size * 8) / av_q2d(enc->time_base) / 1000.0;
- avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0;
+ avg_bitrate = (double)(ost->data_size_enc * 8) / ti1 / 1000.0;
fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
- (double)ost->data_size / 1024, ti1, bitrate, avg_bitrate);
+ (double)ost->data_size_enc / 1024, ti1, bitrate, avg_bitrate);
fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(ost->pict_type));
}
@@ -979,6 +979,8 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &enc->time_base));
}
+ ost->data_size_enc += pkt->size;
+
if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
update_video_stats(ost, pkt, !!vstats_filename);
@@ -1454,14 +1456,16 @@ static void print_final_stats(int64_t total_size)
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
AVCodecParameters *par = ost->st->codecpar;
+ const uint64_t s = ost->data_size_mux;
+
switch (par->codec_type) {
- case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break;
- case AVMEDIA_TYPE_AUDIO: audio_size += ost->data_size; break;
- case AVMEDIA_TYPE_SUBTITLE: subtitle_size += ost->data_size; break;
- default: other_size += ost->data_size; break;
+ case AVMEDIA_TYPE_VIDEO: video_size += s; break;
+ case AVMEDIA_TYPE_AUDIO: audio_size += s; break;
+ case AVMEDIA_TYPE_SUBTITLE: subtitle_size += s; break;
+ default: other_size += s; break;
}
extra_size += par->extradata_size;
- data_size += ost->data_size;
+ data_size += s;
if (ost->enc_ctx &&
(ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2))
!= AV_CODEC_FLAG_PASS1)
@@ -1529,7 +1533,7 @@ static void print_final_stats(int64_t total_size)
OutputStream *ost = output_streams[of->ost_index + j];
enum AVMediaType type = ost->st->codecpar->codec_type;
- total_size += ost->data_size;
+ total_size += ost->data_size_mux;
total_packets += atomic_load(&ost->packets_written);
av_log(NULL, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ",
@@ -1543,7 +1547,7 @@ static void print_final_stats(int64_t total_size)
}
av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets muxed (%"PRIu64" bytes); ",
- atomic_load(&ost->packets_written), ost->data_size);
+ atomic_load(&ost->packets_written), ost->data_size_mux);
av_log(NULL, AV_LOG_VERBOSE, "\n");
}
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 481b836d30..672f91dc13 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -579,8 +579,10 @@ typedef struct OutputStream {
int keep_pix_fmt;
/* stats */
- // combined size of all the packets written
- uint64_t data_size;
+ // combined size of all the packets sent to the muxer
+ uint64_t data_size_mux;
+ // combined size of all the packets received from the encoder
+ uint64_t data_size_enc;
// number of packets send to the muxer
atomic_uint_least64_t packets_written;
// number of frames/samples sent to the encoder
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index b424ef0021..b781e1f5a6 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -156,7 +156,7 @@ static int write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
}
ms->last_mux_dts = pkt->dts;
- ost->data_size += pkt->size;
+ ost->data_size_mux += pkt->size;
atomic_fetch_add(&ost->packets_written, 1);
pkt->stream_index = ost->index;
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 6+ messages in thread