[FFmpeg-devel] [PATCH] lavd/v4l2: extend error/debug feedback in case of invalid codec/pix_fmt

Stefano Sabatini stefasab at gmail.com
Tue Jan 15 11:45:00 CET 2013


---
 libavdevice/v4l2.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index b2e5fed..2dcceff 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -757,6 +757,10 @@ static uint32_t device_try_init(AVFormatContext *s1,
         for (i = 0; i<FF_ARRAY_ELEMS(fmt_conversion_table); i++) {
             if (s1->video_codec_id == AV_CODEC_ID_NONE ||
                 fmt_conversion_table[i].codec_id == s1->video_codec_id) {
+                av_log(s1, AV_LOG_DEBUG, "Trying to set codec:%s pix_fmt:%s\n",
+                       avcodec_get_name(fmt_conversion_table[i].codec_id),
+                       (char *)av_x_if_null(av_get_pix_fmt_name(fmt_conversion_table[i].ff_fmt), "none"));
+
                 desired_format = fmt_conversion_table[i].v4l2_fmt;
                 if (device_init(s1, width, height, desired_format) >= 0) {
                     break;
@@ -851,7 +855,9 @@ static int v4l2_read_header(AVFormatContext *s1)
 
     if (desired_format == 0) {
         av_log(s1, AV_LOG_ERROR, "Cannot find a proper format for "
-               "codec_id %d, pix_fmt %d.\n", s1->video_codec_id, pix_fmt);
+               "codec '%s' (id %d), pixel format '%s' (id %d)\n",
+               avcodec_get_name(s1->video_codec_id), s1->video_codec_id,
+               (char *)av_x_if_null(av_get_pix_fmt_name(pix_fmt), "none"), pix_fmt);
         v4l2_close(s->fd);
 
         res = AVERROR(EIO);
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list