From 288b03290c529c0eeeb32e65e9770eaedf15d876 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 21 Sep 2016 09:05:55 -0400 Subject: [PATCH 1/2] remark out some debugging --- src/zm_ffmpeg.cpp | 1 + src/zm_videostore.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index dd16cf7d3..02dca8ebb 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -357,6 +357,7 @@ static void zm_log_fps(double d, const char *postfix) { /* "user interface" functions */ void zm_dump_stream_format(AVFormatContext *ic, int i, int index, int is_output) { char buf[256]; + Debug(1, "Dumping stream index i(%d) index(%d)", i, index ); int flags = (is_output ? ic->oformat->flags : ic->iformat->flags); AVStream *st = ic->streams[i]; AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0); diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index 45cd1d280..d59a9b467 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -240,9 +240,9 @@ void VideoStore::dumpPacket( AVPacket *pkt ){ int VideoStore::writeVideoFramePacket(AVPacket *ipkt, AVStream *input_st){//, AVPacket *lastKeyframePkt){ - Debug(3, "before ost_tbcket %d", startTime ); - zm_dump_stream_format( oc, ipkt->stream_index, 0, 1 ); - Debug(3, "before ost_tbcket %d", startTime ); + //Debug(3, "before ost_tbcket %d", startTime ); + //zm_dump_stream_format( oc, ipkt->stream_index, 0, 1 ); + //Debug(3, "before ost_tbcket %d", startTime ); int64_t ost_tb_start_time = av_rescale_q(startTime, AV_TIME_BASE_Q, video_st->time_base); AVPacket opkt, safepkt; From 249d3cadc56cfaf74d68e28dfde7595884114b30 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 21 Sep 2016 12:17:09 -0400 Subject: [PATCH 2/2] fix for video on stream 1 --- src/zm_videostore.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index d59a9b467..d9a6507b7 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -272,7 +272,15 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt, AVStream *input_st){//, AV opkt.data = ipkt->data; opkt.size = ipkt->size; - opkt.stream_index = ipkt->stream_index; + + // Some camera have audio on stream 0 and video on stream 1. So when we remove the audio, video stream has to go on 0 + if ( ipkt->stream_index > 0 and ! audio_stream ) { + Debug(1,"Setting stream index to 0 instead of %d", ipkt->stream_index ); + opkt.stream_index = 0; + } else { + opkt.stream_index = ipkt->stream_index; + } + /*opkt.flags |= AV_PKT_FLAG_KEY;*/ if (video_st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (fmt->flags & AVFMT_RAWPICTURE)) {