[FFmpeg-devel] [PATCH 43/49] fftools/ffmpeg_mux: return errors from update_video_stats()
Anton Khirnov
anton at khirnov.net
Mon Apr 4 14:30:31 EEST 2022
---
fftools/ffmpeg_mux.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 2cdbd5feef..087009e0eb 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -63,7 +63,7 @@ struct Muxer {
static int want_sdp = 1;
-static void update_video_stats(OutputStream *ost, const AVPacket *pkt, int write_vstats)
+static int update_video_stats(OutputStream *ost, const AVPacket *pkt, int write_vstats)
{
const uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS,
NULL);
@@ -82,14 +82,14 @@ static void update_video_stats(OutputStream *ost, const AVPacket *pkt, int write
}
if (!write_vstats)
- return;
+ return 0;
/* this is executed just the first time update_video_stats is called */
if (!vstats_file) {
vstats_file = fopen(vstats_filename, "w");
if (!vstats_file) {
perror("fopen");
- exit_program(1);
+ return AVERROR(errno);
}
}
@@ -116,6 +116,8 @@ static void update_video_stats(OutputStream *ost, const AVPacket *pkt, int write
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);
fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(ost->pict_type));
+
+ return 0;
}
static void close_all_output_streams(OutputStream *ost, OSTFinished this_stream, OSTFinished others)
@@ -227,8 +229,11 @@ static int write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
ost->data_size += pkt->size;
ost->packets_written++;
- if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed)
- update_video_stats(ost, pkt, !!vstats_filename);
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed) {
+ ret = update_video_stats(ost, pkt, !!vstats_filename);
+ if (ret < 0)
+ return ret;
+ }
pkt->stream_index = ost->index;
--
2.34.1
More information about the ffmpeg-devel
mailing list