首页 > 其他 > 详细

用ffmpeg和audioTrack实现音频输出

时间:2014-02-24 07:40:46      阅读:399      评论:0      收藏:0      [点我收藏+]

 

使用ffmpeg 解码, Android的audioTrack播放音频,只是自己的笔记而已

bubuko.com,布布扣
av_register_all();

avformat_open_input()

avformat_find_stream_info()

codecCtx=formatCtx->streams[audioStream]->codec;

pCodec=avcodec_find_decoder(codecCtx->codec_id);

avcodec_open2(codecCtx, pCodec, &optionsDict)

}
bubuko.com,布布扣

 

bubuko.com,布布扣
while(av_read_frame(formatCtx, &packet)>=0 && !stop) {
        // Is this a packet from the video stream?
        if(packet.stream_index==audioStream) {
            // Decode video frame
            avcodec_decode_audio4(codecCtx, decodedFrame, &frameFinished,
               &packet);
            // Did we get a video frame?
            if(frameFinished) {
                data_size = 
                    av_samples_get_buffer_size
                    (
                     NULL, 
                     codecCtx->channels,
                     decodedFrame->nb_samples,
                     codecCtx->sample_fmt,
                     1
                    );
                memcpy(&out_buf, decodedFrame->data[0], decodedFrame->linesize[0]);
            }
        }
bubuko.com,布布扣

用ffmpeg和audioTrack实现音频输出

原文:http://www.cnblogs.com/tanjinc/p/3562034.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!