Ios5 iFrameExtractor播放器没有声音

Ios5 iFrameExtractor播放器没有声音,ios5,ffmpeg,Ios5,Ffmpeg,我已经用ios5.1成功地构建了ffmpeg和iFrameExtractor,但是当我播放视频时,没有声音 // Register all formats and codecs avcodec_register_all(); av_register_all(); avformat_network_init(); if(avformat_open_input(&pFormatCtx, [@"http://somesite.com/test.mp4" cStringUsingEncodi

我已经用ios5.1成功地构建了ffmpeg和iFrameExtractor,但是当我播放视频时,没有声音

// Register all formats and codecs
avcodec_register_all();
av_register_all();
avformat_network_init();


if(avformat_open_input(&pFormatCtx, [@"http://somesite.com/test.mp4" cStringUsingEncoding:NSASCIIStringEncoding], NULL, NULL) != 0) {
    av_log(NULL, AV_LOG_ERROR, "Couldn't open file\n");
    goto initError;
}
日志是

[swscaler @ 0xdd3000] No accelerated colorspace conversion found from
 yuv420p to rgb24. 2012-10-22 20:42:47.344 iFrameExtractor[356:707]
 video duration: 5102.840000 2012-10-22 20:42:47.412
 iFrameExtractor[356:707] video size: 720 x 576 2012-10-22 20:42:47.454
 iFrameExtractor[356:707] Application windows are expected to have a
 root view
这是我为ffmpeg 0.11.1配置的文件:

#!/bin/tcsh -f

rm -rf compiled/*

./configure \
--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--as='/usr/local/bin/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \
--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk \
--target-os=darwin \
--arch=arm \
--cpu=cortex-a8 \
--extra-cflags='-arch armv7' \
--extra-ldflags='-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk' \
--prefix=compiled/armv7 \
--enable-cross-compile \
--enable-nonfree \
--disable-armv5te \
--disable-swscale-alpha \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--enable-decoder=h264 \
--enable-decoder=svq3 \
--disable-asm \
--disable-bzlib \
--disable-gpl \
--disable-shared \
--enable-static \
--disable-mmx \
--disable-neon \
--disable-decoders \
--disable-muxers \
--disable-demuxers \
--disable-devices \
--disable-parsers \
--disable-encoders \
--enable-protocols \
--disable-filters \
--disable-bsfs \
--disable-postproc \
--disable-debug 

这里没有足够的信息

例如,您试图打开哪个url

日志中没有消息的位置。我知道使用version.11时,您会收到一些关于不包括网络初始化的警告,但这不会阻止它工作。 在以前的版本中,有些事情发生了变化,例如,您过去可以附加?tcp来指定ffmpeg正在使用tcp,但现在必须在字典中完成

如果可能,请同时提供系统日志和生成日志

下面是我们的一个应用程序的示例

avcodec_register_all();
        avdevice_register_all();
        av_register_all();
        avformat_network_init();


        const char *filename = [url UTF8String];
        NSLog(@"filename = %@" ,url);
       // err = av_open_input_file(&avfContext, filename, NULL, 0, NULL);
        AVDictionary *opts = 0;

        if (usesTcp) {
            av_dict_set(&opts, "rtsp_transport", "tcp", 0);
            }

         err = avformat_open_input(&avfContext, filename, NULL, &opts);
        av_dict_free(&opts);
        if (err) {
            NSLog(@"Error: Could not open stream: %d", err);

            return nil;
        }
        else {
            NSLog(@"Opened stream");
        }

这里没有足够的信息

例如,您试图打开哪个url

日志中没有消息的位置。我知道使用version.11时,您会收到一些关于不包括网络初始化的警告,但这不会阻止它工作。 在以前的版本中,有些事情发生了变化,例如,您过去可以附加?tcp来指定ffmpeg正在使用tcp,但现在必须在字典中完成

如果可能,请同时提供系统日志和生成日志

下面是我们的一个应用程序的示例

avcodec_register_all();
        avdevice_register_all();
        av_register_all();
        avformat_network_init();


        const char *filename = [url UTF8String];
        NSLog(@"filename = %@" ,url);
       // err = av_open_input_file(&avfContext, filename, NULL, 0, NULL);
        AVDictionary *opts = 0;

        if (usesTcp) {
            av_dict_set(&opts, "rtsp_transport", "tcp", 0);
            }

         err = avformat_open_input(&avfContext, filename, NULL, &opts);
        av_dict_free(&opts);
        if (err) {
            NSLog(@"Error: Could not open stream: %d", err);

            return nil;
        }
        else {
            NSLog(@"Opened stream");
        }

因此,假设您确实有一块代码,如下面所示,您如何处理音频,您必须使用一个音频api来处理它,如果您主要处理已知类型,那么音频队列可能是最简单的

在初始化过程中,首先从流中获取音频信息

// Retrieve stream information
    if(av_find_stream_info(pFormatCtx)<0)
        return ; // Couldn't find stream information

    // Find the first video stream
    videoStream=-1;
    for(int i=0; i<pFormatCtx->nb_streams; i++) {
        if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO)
        {
            videoStream=i;
                   }

        if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO)
        {
            audioStream=i;
            NSLog(@"found audio stream");
        }

    }


Then later in your processing loop do something like this.

 while(!frameFinished && av_read_frame(pFormatCtx, &packet)>=0) {
        // Is this a packet from the video stream?
        if(packet.stream_index==videoStream) {
            // Decode video frame
              //do something with the video.

        }
         if(packet.stream_index==audioStream) {
            // NSLog(@"audio stream");

             //do something with the audio packet, here we simply add it to a processing
             queue to be handled by another thread.

             [audioPacketQueueLock lock];
             audioPacketQueueSize += packet.size;
             [audioPacketQueue addObject:[NSMutableData dataWithBytes:&packet length:sizeof(packet)]];
             [audioPacketQueueLock unlock];
//检索流信息

如果(av_find_stream_info(pFormatCtx),那么假设您确实有一个代码块,如下面所示,您如何处理音频,您必须使用一个音频api来处理它,如果您主要处理已知类型,音频队列可能是最简单的

在初始化过程中,首先从流中获取音频信息

// Retrieve stream information
    if(av_find_stream_info(pFormatCtx)<0)
        return ; // Couldn't find stream information

    // Find the first video stream
    videoStream=-1;
    for(int i=0; i<pFormatCtx->nb_streams; i++) {
        if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO)
        {
            videoStream=i;
                   }

        if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO)
        {
            audioStream=i;
            NSLog(@"found audio stream");
        }

    }


Then later in your processing loop do something like this.

 while(!frameFinished && av_read_frame(pFormatCtx, &packet)>=0) {
        // Is this a packet from the video stream?
        if(packet.stream_index==videoStream) {
            // Decode video frame
              //do something with the video.

        }
         if(packet.stream_index==audioStream) {
            // NSLog(@"audio stream");

             //do something with the audio packet, here we simply add it to a processing
             queue to be handled by another thread.

             [audioPacketQueueLock lock];
             audioPacketQueueSize += packet.size;
             [audioPacketQueue addObject:[NSMutableData dataWithBytes:&packet length:sizeof(packet)]];
             [audioPacketQueueLock unlock];
//检索流信息

if(av_find_stream_info(pFormatCtx)Update!Tt现在可以工作,但对于任何类型的视频(.mp4.mov.ts)都没有声音再一次,你需要给我们更多的信息,也许你使用的一些代码的例子会是一个好的开始,例如,你在获得流之后对音频样本做了什么。没错,但作为一个练习,我刚刚把iframeextractor转换成使用我们的框架和解码器,总共花了大约15分钟,想看看这里吗您使用AVFoundation播放音频,但我的音频是mpeg格式,我也想通过ffmpeg播放音频:)您可以转换为原始PCM并使用音频单元播放,如果您想与我们签订合同,我们可以提供帮助。否则,请查看apple开发者网站上的音频单元示例。auroTouch2非常有用。更新!Tt现在可以工作,但对于任何类型的视频(.mp4.mov.ts)都没有声音再一次,你需要给我们更多的信息,也许你使用的一些代码的例子会是一个好的开始,例如,你在获得流之后对音频样本做了什么。没错,但作为一个练习,我刚刚把iframeextractor转换成使用我们的框架和解码器,总共花了大约15分钟,想看看这里吗您使用AVFoundation播放音频,但我的音频是mpeg格式,我也想通过ffmpeg播放音频:)您可以转换为原始PCM并使用音频单元播放,如果您想与我们签订合同,我们可以提供帮助。否则,请在apple开发者网站上查看音频单元示例。极光2非常有用。嘿,我现在正在尝试构建ffmpeg?为xcode构建FFMPEG的步骤是什么?我正在吃一些difficulty@Jimmy你可以在Github上搜索,这很容易。我现在正在尝试构建ffmpeg?为xcode构建FFMPEG的步骤是什么?我正在吃一些difficulty@Jimmy你可以在Github上搜索,这很简单