Mercurial > mm7
comparison 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 |
comparison
equal
deleted
inserted
replaced
2503:502246699451 | 2504:6b8c2f8c7fad |
---|---|
252 return false; | 252 return false; |
253 } | 253 } |
254 | 254 |
255 static bool av_open_audio_stream(AVFormatContext *format_ctx, AVAudioStream *out_stream) | 255 static bool av_open_audio_stream(AVFormatContext *format_ctx, AVAudioStream *out_stream) |
256 { | 256 { |
257 if (!av_open_stream(format_ctx, AVMEDIA_TYPE_AUDIO, out_stream)) | 257 if (av_open_stream(format_ctx, AVMEDIA_TYPE_AUDIO, out_stream)) |
258 return Error("Audio stream not found"), false; | 258 //return Error("Audio stream not found"), false; |
259 | 259 |
260 // we support only 2-channel audio for now | 260 // we support only 2-channel audio for now |
261 //if (out_stream->dec_ctx->channels != 2) | 261 //if (out_stream->dec_ctx->channels != 2) |
262 //{ | 262 //{ |
263 // out_stream->Release(); | 263 // out_stream->Release(); |
264 // return Error("Unsupported number of channels: %u", out_stream->dec_ctx->channels), false; | 264 // return Error("Unsupported number of channels: %u", out_stream->dec_ctx->channels), false; |
265 //} | 265 //} |
266 | 266 { |
267 out_stream->bytes_per_sample = av_num_bytes_per_sample(out_stream->dec_ctx->sample_fmt); | 267 out_stream->bytes_per_sample = av_num_bytes_per_sample(out_stream->dec_ctx->sample_fmt); |
268 out_stream->bytes_per_second = out_stream->dec_ctx->channels * out_stream->dec_ctx->sample_rate * out_stream->bytes_per_sample; | 268 out_stream->bytes_per_second = out_stream->dec_ctx->channels * out_stream->dec_ctx->sample_rate * out_stream->bytes_per_sample; |
269 | 269 } |
270 return true; | 270 return true; |
271 } | 271 } |
272 | 272 |
273 static bool av_open_video_stream(AVFormatContext *format_ctx, AVVideoStream *out_stream) | 273 static bool av_open_video_stream(AVFormatContext *format_ctx, AVVideoStream *out_stream) |
274 { | 274 { |
801 if (avformat_find_stream_info(format_ctx, nullptr) >= 0) | 801 if (avformat_find_stream_info(format_ctx, nullptr) >= 0) |
802 { | 802 { |
803 // Dump information about file onto standard error | 803 // Dump information about file onto standard error |
804 av_dump_format(format_ctx, 0, filenamea, 0); | 804 av_dump_format(format_ctx, 0, filenamea, 0); |
805 | 805 |
806 if (!av_open_audio_stream(format_ctx, &audio)) | 806 /*if (!av_open_audio_stream(format_ctx, &audio)) |
807 { | 807 { |
808 Error("Cannot open audio stream: %s", filenamea); | 808 Error("Cannot open audio stream: %s", filenamea); |
809 return Release(), false; | 809 return Release(), false; |
810 } | 810 }*/ |
811 av_open_audio_stream(format_ctx, &audio); | |
811 | 812 |
812 if (!av_open_video_stream(format_ctx, &video)) | 813 if (!av_open_video_stream(format_ctx, &video)) |
813 { | 814 { |
814 Error("Cannot open video stream: %s", filenamea); | 815 Error("Cannot open video stream: %s", filenamea); |
815 return Release(), false; | 816 return Release(), false; |
831 av_init_packet(decoding_packet); | 832 av_init_packet(decoding_packet); |
832 | 833 |
833 // Allocate video frame | 834 // Allocate video frame |
834 decoding_frame = avcodec_alloc_frame(); | 835 decoding_frame = avcodec_alloc_frame(); |
835 | 836 |
836 audio_data_in_device = provider->CreateStreamingTrack16(audio.dec_ctx->channels, audio.dec_ctx->sample_rate, 2); | 837 if (audio.stream_idx >= 0) |
838 audio_data_in_device = provider->CreateStreamingTrack16(audio.dec_ctx->channels, audio.dec_ctx->sample_rate, 2); | |
837 return true; | 839 return true; |
838 } | 840 } |
839 fprintf(stderr, "ffmpeg: Unable to find stream info\n"); | 841 fprintf(stderr, "ffmpeg: Unable to find stream info\n"); |
840 return Release(), false; | 842 return Release(), false; |
841 } | 843 } |