IJKPlayer常用配置

/ 0评 / 4

创建IJKFFOptions,配置参数

    NSURL *url = [NSURL URLWithString:liveStreamString];
    [IJKFFMoviePlayerController checkIfFFmpegVersionMatch:YES];
    IJKFFOptions *options = [IJKFFOptions optionsByDefault];
    //设置最大fps
    [options setPlayerOptionIntValue:30  forKey:@"max-fps"];
    // 跳帧开关,如果cpu解码能力不足,可以设置成5,否则
    // 会引起音视频不同步,也可以通过设置它来跳帧达到倍速播放
    [options setPlayerOptionIntValue:5  forKey:@"framedrop"];

    [options setCodecOptionIntValue:IJK_AVDISCARD_DEFAULT forKey:@"skip_frame"];
    //解码参数,画面更清晰
    [options setCodecOptionIntValue:IJK_AVDISCARD_DEFAULT forKey:@"skip_loop_filter"];
    //播放前的探测时间
    [options setFormatOptionIntValue:50000 forKey:@"analyzeduration"];
    //播放前的探测Size,默认是1M, 改小一点会出画面更快
    [options setFormatOptionIntValue:1024 * 16 forKey:@"probesize"];
    //如果是rtsp协议,可以优先用tcp(默认是用udp)
//    [options setFormatOptionValue:@"tcp" forKey:@"rtsp_transport"];
    //开启硬解码 1是硬解 0是软解
    [options setPlayerOptionIntValue:0  forKey:@"videotoolbox"];
    // 帧速率(fps) (可以改,确认非标准桢率会导致音画不同步,所以只能设定为15或者29.97)
    [options setPlayerOptionIntValue:29.97 forKey:@"r"];
//    // -vol——设置音量大小,256为标准音量。(要设置成两倍音量时则输入512,依此类推
//    [options setPlayerOptionIntValue:512 forKey:@"vol"];
    //静音设置
    [options setPlayerOptionValue:@"1" forKey:@"an"];
    //帧数
    [options setPlayerOptionIntValue:5  forKey:@"min-frames"];
    
    // Param for living
    [options setPlayerOptionIntValue:3000 forKey:@"max_cached_duration"];   // 最大缓存大小是3秒,可以依据自己的需求修改
    [options setPlayerOptionIntValue:1 forKey:@"infbuf"];  // 无限读
    [options setPlayerOptionIntValue:0 forKey:@"packet-buffering"];  //  关闭播放器缓冲

初始化player的时候将option加入

    IJKFFMoviePlayerController *moviePlayer = [[IJKFFMoviePlayerController alloc] initWithContentURL:url withOptions:options];

评论已关闭。