ffmpeg - c中的h264无损设置

标签 ffmpeg h.264 video-encoding lossless

我目前正在尝试在 c 中为 FFMPEG 应用无损 H264 设置。但是,我不确定需要什么设置才能确保无损编码,而且我在该领域发现的文档很少。

我当前的设置是:

    codecContex->coder_type = 1; 
    codecContex->flags|=CODEC_FLAG_LOOP_FILTER;
    codecContex->flags2|=CODEC_FLAG2_BPYRAMID-CODEC_FLAG2_WPRED-CODEC_FLAG2_8X8DCT;

    codecContex->profile=FF_PROFILE_H264_BASELINE;
    codecContex->scenechange_threshold = 40; 
    codecContex->gop_size=40;
    codecContex->max_b_frames=0;
    codecContex->max_qdiff=4;
    codecContex->me_method=10;
    codecContex->me_range=16;
    codecContex->me_cmp|= 1;
    codecContex->me_subpel_quality = 5; 
    codecContex->qmin=0; 
    codecContex->qmax=0;
    codecContex->qcompress=0.6f;
    codecContex->keyint_min=25;
    codecContex->trellis=0;
    codecContex->level=13;
    codecContex->refs = 16;
    codecContex->weighted_p_pred = 2;
    codecContex->b_frame_strategy= 1;
    codecContex->color_range = libffmpeg::AVCOL_RANGE_JPEG;
    codecContex->coder_type = FF_CODER_TYPE_AC;
    codecContex->crf = 0;

关于如何确保无损编码有什么想法吗? 提前致谢。

最佳答案

试试这个:

...
AVDictionary *param;
av_dict_set(&param, "qp", "0", 0);
/*
Change options to trade off compression efficiency against encoding speed. If you specify a preset, the changes it makes will be applied before all other parameters are applied.
You should generally set this option to the slowest you can bear.
Values available: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo.
*/
av_dict_set(&param, "preset", "medium", 0);
/*
Tune options to further optimize them for your input content. If you specify a tuning, the changes will be applied after --preset but before all other parameters.
If your source content matches one of the available tunings you can use this, otherwise leave unset.
Values available: film, animation, grain, stillimage, psnr, ssim, fastdecode, zerolatency.
*/
av_dict_set(&param, "tune", "film", 0);
int rt = avcodec_open2(codecContext, codec, &param);
...

为了无损,不要使用配置文件

关于ffmpeg - c中的h264无损设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22027302/

相关文章:

streaming - 使用 FFmpeg,如何解码 H264 数据包

video - 使用 FFmpeg 加速视频以获得正确的持续时间

ffmpeg - MP4 容器中的 H.264 编码流在 WMP12 Windows 7 中无法正常播放

android - 在 ffmpeg 中读取 JPEG

php在windows中执行exec时挂起

ffmpeg - 没有这样的文件或目录 discord.py

android - 如何使用 MediaCodec 将位图编码为视频?

ffmpeg - 如何使用 FFmpeg 连接两个 MP4 文件?

ios - 如何从 iOS 应用程序使用 RTSP 将视频流发送到 WOWZA 服务器?

ffmpeg - youtube-dl 有一个 3gp 文件,显然它不包含任何视频流。有没有办法播放视频?