Skip to content

Display and control your Android device

Log FFmpeg errors as strings

Romain Vimontdc0da7287b69
diff --git a/app/src/audio_regulator.c b/app/src/audio_regulator.c
index 16fdd08b..556553c7 100644
--- a/app/src/audio_regulator.c
+++ b/app/src/audio_regulator.c
@@ -5,6 +5,7 @@
#include <stdlib.h>
#include <string.h>
#include <libavcodec/avcodec.h>
+#include <libavutil/error.h>
#include <libavutil/opt.h>
#include "util/log.h"
@@ -184,7 +185,7 @@ sc_audio_regulator_push(struct sc_audio_regulator *ar, const AVFrame *frame) {
int ret = swr_convert(swr_ctx, &swr_buf, dst_nb_samples,
(const uint8_t **) frame->data, frame->nb_samples);
if (ret < 0) {
- LOGE("Resampling failed: %d", ret);
+ LOGE("Resampling failed: %s", av_err2str(ret));
return false;
}
@@ -352,7 +353,7 @@ sc_audio_regulator_push(struct sc_audio_regulator *ar, const AVFrame *frame) {
int ret = swr_set_compensation(swr_ctx, diff, distance);
if (ret < 0) {
- LOGW("Resampling compensation failed: %d", ret);
+ LOGW("Resampling compensation failed: %s", av_err2str(ret));
// not fatal
} else {
ar->compensation_active = diff != 0;
diff --git a/app/src/decoder.c b/app/src/decoder.c
index 06b846a6..a72a1a7f 100644
--- a/app/src/decoder.c
+++ b/app/src/decoder.c
@@ -3,6 +3,7 @@
#include <errno.h>
#include <libavcodec/packet.h>
#include <libavutil/avutil.h>
+#include <libavutil/error.h>
#include "util/log.h"
@@ -80,8 +81,8 @@ sc_decoder_push(struct sc_decoder *decoder, const AVPacket *packet) {
int ret = avcodec_send_packet(decoder->ctx, packet);
if (ret < 0 && ret != AVERROR(EAGAIN)) {
- LOGE("Decoder '%s': could not send video packet: %d",
- decoder->name, ret);
+ LOGE("Decoder '%s': could not send video packet: %s",
+ decoder->name, av_err2str(ret));
return false;
}
@@ -92,8 +93,8 @@ sc_decoder_push(struct sc_decoder *decoder, const AVPacket *packet) {
}
if (ret) {
- LOGE("Decoder '%s', could not receive video frame: %d",
- decoder->name, ret);
+ LOGE("Decoder '%s', could not receive video frame: %s",
+ decoder->name, av_err2str(ret));
return false;
}
diff --git a/app/src/icon.c b/app/src/icon.c
index 0a84f5ba..880ea596 100644
--- a/app/src/icon.c
+++ b/app/src/icon.c
@@ -10,6 +10,7 @@
#include <libavutil/avutil.h>
#include <libavutil/pixdesc.h>
#include <libavutil/pixfmt.h>
+#include <libavutil/error.h>
#include <SDL3/SDL.h>
#include "config.h"
@@ -133,14 +134,14 @@ decode_image(const char *path) {
int ret;
if ((ret = avcodec_send_packet(codec_ctx, packet)) < 0) {
- LOGE("Could not send icon packet: %d", ret);
+ LOGE("Could not send icon packet: %s", av_err2str(ret));
av_packet_free(&packet);
av_frame_free(&frame);
goto free_codec_ctx;
}
if ((ret = avcodec_receive_frame(codec_ctx, frame)) != 0) {
- LOGE("Could not receive icon frame: %d", ret);
+ LOGE("Could not receive icon frame: %s", av_err2str(ret));
av_packet_free(&packet);
av_frame_free(&frame);
goto free_codec_ctx;
diff --git a/app/src/v4l2_sink.c b/app/src/v4l2_sink.c
index 8ba5414c..3dfd4dd6 100644
--- a/app/src/v4l2_sink.c
+++ b/app/src/v4l2_sink.c
@@ -5,6 +5,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
+#include <libavutil/error.h>
#include "util/log.h"
#include "util/str.h"
@@ -88,7 +89,7 @@ static bool
encode_and_write_frame(struct sc_v4l2_sink *vs, const AVFrame *frame) {
int ret = avcodec_send_frame(vs->encoder_ctx, frame);
if (ret < 0 && ret != AVERROR(EAGAIN)) {
- LOGE("Could not send v4l2 video frame: %d", ret);
+ LOGE("Could not send v4l2 video frame: %s", av_err2str(ret));
return false;
}
@@ -104,7 +105,7 @@ encode_and_write_frame(struct sc_v4l2_sink *vs, const AVFrame *frame) {
return false;
}
} else if (ret != AVERROR(EAGAIN)) {
- LOGE("Could not receive v4l2 video packet: %d", ret);
+ LOGE("Could not receive v4l2 video packet: %s", av_err2str(ret));
return false;
}