[FFmpeg-devel] [PATCH]Fix G.726 in mkv

Carl Eugen Hoyos cehoyos at ag.or.at
Fri Jan 10 11:26:59 CET 2014


Hi!

The following command lines fail since dd5689a3
$ ffmpeg -i input -vn -acodec g726 -ar 8k out.mkv
$ ffmpeg -i out.mkv

Attached are two (independent) patches, one fixes decoding the samples created 
since the breakage, one allows to create files that older (broken) FFmpeg can 
read.

Please review, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index e05101f..9a7e366 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1909,6 +1909,7 @@ static int matroska_read_header(AVFormatContext *s)
             st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
             st->codec->sample_rate = track->audio.out_samplerate;
             st->codec->channels = track->audio.channels;
+            if (!st->codec->bits_per_coded_sample)
             st->codec->bits_per_coded_sample = track->audio.bitdepth;
             if (st->codec->codec_id != AV_CODEC_ID_AAC)
             st->need_parsing = AVSTREAM_PARSE_HEADERS;
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 82624b7..11174f1 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -620,7 +620,7 @@ static int mkv_write_tracks(AVFormatContext *s)
             continue;
         }
 
-        if (!bit_depth)
+        if (!bit_depth && codec->codec_id != AV_CODEC_ID_ADPCM_G726)
             bit_depth = av_get_bytes_per_sample(codec->sample_fmt) << 3;
         if (!bit_depth)
             bit_depth = codec->bits_per_coded_sample;


More information about the ffmpeg-devel mailing list