for (pair<string, string> opt : opts) {
av_dict_set(&options, opt.first.c_str(), opt.second.c_str(), 0);
}
- if (avformat_write_header(avctx, &options) < 0) {
- fprintf(stderr, "avformat_write_header() failed\n");
- abort();
+ int err = avformat_write_header(avctx, &options);
+ if (err < 0) {
+ char errbuf[AV_ERROR_MAX_STRING_SIZE];
+ av_strerror(err, errbuf, sizeof(errbuf));
+ fprintf(stderr, "avformat_write_header() failed: %s\n", errbuf);
+ exit(EXIT_FAILURE);
}
for (MuxMetrics *metric : metrics) {
metric->metric_written_bytes += avctx->pb->pos;
}
}
int64_t old_pos = avctx->pb->pos;
- if (av_interleaved_write_frame(avctx, const_cast<AVPacket *>(&pkt)) < 0) {
- fprintf(stderr, "av_interleaved_write_frame() failed\n");
- abort();
+ int err = av_interleaved_write_frame(avctx, const_cast<AVPacket *>(&pkt));
+ if (err < 0) {
+ char errbuf[AV_ERROR_MAX_STRING_SIZE];
+ av_strerror(err, errbuf, sizeof(errbuf));
+ fprintf(stderr, "av_interleaved_write_frame() failed: %s\n", errbuf);
+ exit(EXIT_FAILURE);
}
avio_flush(avctx->pb);
for (MuxMetrics *metric : metrics) {