FFmpeg 解码性能测试demo( iphone 6s plus 真机测试)

该博客通过真机测试对比了iPhone 6s Plus和iPhone 7在使用FFmpeg进行视频解码时的性能。在不同解码策略下(单线程、双线程软解、双线程硬件解码),记录了每秒解帧数,分析了CPU负荷情况。测试结果显示了设备性能差异及其对解码效率的影响。

Demo

头文件:

#include <sys/time.h>

获取当前时间方法

//当前时间戳 毫秒级别(一秒解多少帧)
long long getNowMs(){
    struct timeval tv;
    gettimeofday(&tv, NULL);
    long long sec = tv.tv_sec%360000; //秒 只取100小时内
    long long t = sec*1000+tv.tv_usec/1000;
    return t;
}

我的手机是 iphone 6s plus 真机测试解码一个 mp4格式102.4 MB的视频:

//打开一个视频文件
+ (void)ffmpegOpenFile:(NSString *)filePath{
    // 1 注册组件
//    av_register_all();

    // 2 初始化网络 如果需要的话
    avformat_network_init();

    // 初始化 解码器
//    avcodec_register_all();

    // 3 打开封装格式文件
    //封装格式上下文
    AVFormatContext *ic = avformat_alloc_context();

    //文件路径
    const char *url = [filePath UTF8String];

    /*
     • AVFormatContext **ps  传指针的地址
     • const char *url   文件路径(本地的或者网络的http rtsp 地址会被存在AVFormatContext 结构体的 fileName中)
     • AVInputFormat *fmt 指定输入的封装格式 一般情况传NULL即可,自行判断即可
     • AVDictionary **options 一般传NULL
     */
    int re = avformat_open_input(&ic, url, NULL, NULL);

    if (re != 0) {
        NSLog(@"打开文件失败");
        char *error_info = NULL;
        av_strerror(re, error_info, 1024);

        return;
    }

    NSLog(@"打开文件成功");
    //获取流信息 读取部分视频做探测
    re = avformat_find_stream_info(ic, 0);
    if (re != 0) {
        NSLog(@"avformat_find_stream_info failed!");
    }
    //总时长,流的信息
    NSLog(@"duration =%lld nb_streams = %d",ic->duration,ic->nb_streams);
    //打印相关信息
    int fps = 0;
    int videoStream = 0;
    int audioStream = 1;
    //(1)遍历
    for (int i = 0; i < ic->nb_streams; i++) {
        AVStream *as = ic->streams[i];
        if (as->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
           
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值