[FFmpeg-devel] [PATCH]lavf/matroskaenc: Print an error if an unreadable rawvideo pix_fmt is written

Carl Eugen Hoyos cehoyos at ag.or.at
Tue Jan 10 18:05:47 EET 2017


Hi!

Attached patch copies mov and avi behaviour.

Please comment, Carl Eugen
-------------- next part --------------
From c716fb256cfcc59dfa6adc93ac0810db9c2c1722 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos at ag.or.at>
Date: Tue, 10 Jan 2017 17:04:34 +0100
Subject: [PATCH] lavf/matroskaenc: Print an error if rawvideo pix_fmt is
 invalid for vfw.

---
 libavformat/matroskaenc.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 78a621e..3f06faa 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -51,10 +51,12 @@
 #include "libavutil/samplefmt.h"
 #include "libavutil/sha.h"
 #include "libavutil/stereo3d.h"
+#include "libavutil/pixdesc.h"
 
 #include "libavcodec/xiph.h"
 #include "libavcodec/mpeg4audio.h"
 #include "libavcodec/internal.h"
+#include "libavcodec/raw.h"
 
 typedef struct ebml_master {
     int64_t         pos;                ///< absolute offset in the file where the master's elements start
@@ -1128,6 +1130,11 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
         }
         if (par->codec_id == AV_CODEC_ID_RAWVIDEO && !par->codec_tag) {
             if (mkv->allow_raw_vfw) {
+                enum AVPixelFormat pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
+                                                                 par->bits_per_coded_sample);
+                if (par->format != pix_fmt && par->format != AV_PIX_FMT_NONE)
+                    av_log(s, AV_LOG_ERROR, "%s rawvideo cannot be written to vfw mkv, output file will be unreadable\n",
+                          av_get_pix_fmt_name(par->format));
                 native_id = 0;
             } else {
                 av_log(s, AV_LOG_ERROR, "Raw RGB is not supported Natively in Matroska, you can use AVI or NUT or\n"
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list