[FFmpeg-devel] [PATCH]Support mulaw audio in Hikvision CCTV files
Carl Eugen Hoyos
cehoyos at ag.or.at
Tue Mar 26 11:16:16 CET 2013
HI!
Attached patch fixes vlc ticket #8344 for me.
Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index f36f0db..8cb4a98 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -110,6 +110,7 @@ typedef struct MpegDemuxContext {
unsigned char psm_es_type[256];
int sofdec;
int dvd;
+ int imkh_cctv;
#if CONFIG_VOBSUB_DEMUXER
AVFormatContext *sub_ctx;
FFDemuxSubtitlesQueue q;
@@ -123,6 +124,9 @@ static int mpegps_read_header(AVFormatContext *s)
int v, i = 0;
int64_t last_pos = avio_tell(s->pb);
+ if (AV_RL32(s->pb->buffer) == MKTAG('I', 'M', 'K', 'H'))
+ m->imkh_cctv = 1;
+
m->header_state = 0xff;
s->ctx_flags |= AVFMTCTX_NOHEADER;
@@ -506,6 +510,9 @@ static int mpegps_read_packet(AVFormatContext *s,
} else if(es_type == STREAM_TYPE_AUDIO_AC3){
codec_id = AV_CODEC_ID_AC3;
type = AVMEDIA_TYPE_AUDIO;
+ } else if(m->imkh_cctv && es_type == 0x91){
+ codec_id = AV_CODEC_ID_PCM_MULAW;
+ type = AVMEDIA_TYPE_AUDIO;
} else if (startcode >= 0x1e0 && startcode <= 0x1ef) {
static const unsigned char avs_seqh[4] = { 0, 0, 1, 0xb0 };
unsigned char buf[8];
@@ -564,6 +571,11 @@ static int mpegps_read_packet(AVFormatContext *s,
st->id = startcode;
st->codec->codec_type = type;
st->codec->codec_id = codec_id;
+ if (st->codec->codec_id == AV_CODEC_ID_PCM_MULAW) {
+ st->codec->channels = 1;
+ st->codec->channel_layout = AV_CH_LAYOUT_MONO;
+ st->codec->sample_rate = 8000;
+ }
st->request_probe = request_probe;
if (codec_id != AV_CODEC_ID_PCM_S16BE)
st->need_parsing = AVSTREAM_PARSE_FULL;
More information about the ffmpeg-devel
mailing list