xufuji456 / FFmpegAndroid

FFmpeg实现视频裁剪、水印、转码、编解码、转Gif动图;FFmpeg本地推流、H264与RTMP实时推流直播;OpenGL滤镜特效,视频拍摄。音视频学习路线,音视频知识总结、流媒体协议
5.08k stars 1.27k forks source link

ffmpeg中的atadenoise调用实例 #165

Closed xsy123xsy closed 2 years ago

xsy123xsy commented 3 years ago

你好,请问是否有ffmpeg中的atadenoise降噪算法的调用实例

xsy123xsy commented 3 years ago

如何配置https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/filtering_video.c 中的const char *filter_descr,从而使用ffmpeg中的atadenoise进行视频降噪

xufuji456 commented 3 years ago

在项目里有实例:https://github.com/xufuji456/FFmpegAndroid/blob/master/app/src/main/cpp/video_filter.c image

xsy123xsy commented 3 years ago

谢谢,但是没有看到atadenoise的filter_descr

xufuji456 commented 3 years ago

atadenoise的filter_descr="atadenoise=2a",可以在java层添加。 参数列表如下: 0a Set threshold A for 1st plane. Default is 0.02. Valid range is 0 to 0.3.

0b Set threshold B for 1st plane. Default is 0.04. Valid range is 0 to 5.

1a Set threshold A for 2nd plane. Default is 0.02. Valid range is 0 to 0.3.

1b Set threshold B for 2nd plane. Default is 0.04. Valid range is 0 to 5.

2a Set threshold A for 3rd plane. Default is 0.02. Valid range is 0 to 0.3.

2b Set threshold B for 3rd plane. Default is 0.04. Valid range is 0 to 5.

Threshold A is designed to react on abrupt changes in the input signal and threshold B is designed to react on continuous changes in the input signal.

s Set number of frames filter will use for averaging. Default is 9. Must be odd number in range [5, 129].

p Set what planes of frame filter will use for averaging. Default is all.

a Set what variant of algorithm filter will use for averaging. Default is p parallel. Alternatively can be set to s serial.

xsy123xsy commented 3 years ago

谢谢,我在示例程序filtering_video.c中按照这种方式声明atadenoise滤镜: const char* filter_descr = "atadenoise=0a=0.2:1a=0.2:2a=0.2:0b=0.3:1b=0.3:2b=0.3"; 但是运行时open_input_file()这个函数返回一个负值,并且报错:cannot open input file 代码如下:

    int ret;
    AVPacket packet;
    AVFrame* frame;
    AVFrame* filt_frame;
    std::string test_file_path_s = rx_video_resource_file_path("0.mp4");
    char const* test_file_path = test_file_path_s.c_str();

    // if (argc != 2) {
    //     fprintf(stderr, "Usage: %s file\n", argv[0]);
    //     exit(1);
    // }

    frame = av_frame_alloc();
    filt_frame = av_frame_alloc();
    if (!frame || !filt_frame) {
        perror("Could not allocate frame");
        exit(1);
    }

    if ((ret = open_input_file(test_file_path)) < 0)
        goto end;
    if ((ret = init_filters(filter_descr)) < 0)
        goto end;