ijkPlayer源码(iOS)学习第5天

今天代码有点看不动了,所以从网上找点学习资料,等学看完学习资料再继续研究

 

https://blog.youkuaiyun.com/qq819853294/article/details/8296622

 

https://www.jianshu.com/p/58a2777baf56

 

https://blog.youkuaiyun.com/yao_hou/article/details/80559161

 

通过网上学习,同步在自己电脑完成了ffmpeg的第一个demo。

步骤如下

1.给mac用HomeBrew安装 FFMpeg。

2.Xcode新建项目配置环境

3.Code

代码如下

#import <Foundation/Foundation.h>
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // insert code here...
        NSLog(@"Hello, World!");
        
        //ffmpeg程序的第一句,注册库
        av_register_all();
        printf("avcodec_configuration:\n%s",avcodec_configuration());
        
        AVFormatContext *afc = NULL;
        int nRet =avformat_open_input(&afc, "/Users/wangfei/Documents/wangfei/ffmpeg学习/FFTest/FFTest/Q利游戏终季01中文字幕.mp4", 0, 0);
        if (nRet < 0) {
            printf("can not find video!\n");
            
        } else {
            printf("open video success");
       
        
            int durTime = afc->duration / AV_TIME_BASE;
            printf("durTime is \n%d",durTime);
            
            unsigned streamCount = afc->nb_streams;
            
            
            for (int i = 0 ; i < streamCount; i++) {
                AVCodecContext *acc = afc->streams[i]->codec;
                if (acc->codec_type == AVMEDIA_TYPE_VIDEO) {
                    AVCodec *codec = avcodec_find_decoder(acc->codec_id);
                    if (!codec) {
                        
                    }
                    int ret = avcodec_open2(acc, codec, NULL);
                    
                    if (ret != 0) {
                        char buf[1024] = {0};
                        av_strerror(ret, buf, sizeof(buf));
                    }
                }
                
            }
        }
        
        if (afc) {
            avformat_close_input(&afc);
        }
    }
    return 0;
}

 

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值