Mercurial > mm7
diff Media/MediaPlayer.cpp @ 2504:6b8c2f8c7fad
for audio in House video
author | Ritor1 |
---|---|
date | Fri, 19 Sep 2014 10:49:17 +0600 |
parents | a77c34acdbc9 |
children | 491f0babd563 |
line wrap: on
line diff
--- a/Media/MediaPlayer.cpp Fri Sep 19 09:41:00 2014 +0600 +++ b/Media/MediaPlayer.cpp Fri Sep 19 10:49:17 2014 +0600 @@ -254,8 +254,8 @@ static bool av_open_audio_stream(AVFormatContext *format_ctx, AVAudioStream *out_stream) { - if (!av_open_stream(format_ctx, AVMEDIA_TYPE_AUDIO, out_stream)) - return Error("Audio stream not found"), false; + if (av_open_stream(format_ctx, AVMEDIA_TYPE_AUDIO, out_stream)) + //return Error("Audio stream not found"), false; // we support only 2-channel audio for now //if (out_stream->dec_ctx->channels != 2) @@ -263,10 +263,10 @@ // out_stream->Release(); // return Error("Unsupported number of channels: %u", out_stream->dec_ctx->channels), false; //} - + { out_stream->bytes_per_sample = av_num_bytes_per_sample(out_stream->dec_ctx->sample_fmt); out_stream->bytes_per_second = out_stream->dec_ctx->channels * out_stream->dec_ctx->sample_rate * out_stream->bytes_per_sample; - + } return true; } @@ -803,11 +803,12 @@ // Dump information about file onto standard error av_dump_format(format_ctx, 0, filenamea, 0); - if (!av_open_audio_stream(format_ctx, &audio)) + /*if (!av_open_audio_stream(format_ctx, &audio)) { Error("Cannot open audio stream: %s", filenamea); return Release(), false; - } + }*/ + av_open_audio_stream(format_ctx, &audio); if (!av_open_video_stream(format_ctx, &video)) { @@ -833,7 +834,8 @@ // Allocate video frame decoding_frame = avcodec_alloc_frame(); - audio_data_in_device = provider->CreateStreamingTrack16(audio.dec_ctx->channels, audio.dec_ctx->sample_rate, 2); + if (audio.stream_idx >= 0) + audio_data_in_device = provider->CreateStreamingTrack16(audio.dec_ctx->channels, audio.dec_ctx->sample_rate, 2); return true; } fprintf(stderr, "ffmpeg: Unable to find stream info\n");