[C++] 182 FLTK : 動画の一部を複数ぼかす FFmpeg

[M1 Mac, Big Sur 11.6.8, clang 13.0.0, FLTK 1.3.8, NO IDE]

前回作成したコードを導入し、動画の一部を複数ぼかすことができるようにしました。

動画では3ヶ所にモザイクをかけています。

string filterCmdMake(string input,string output,string filters)
{   
    vector<string> crops;
    vector<string> overs;
    string comp;

    vector<string> list_filter = spt2.splits(filters,",");
    int num = list_filter.size();
    
    for (int i=0;i < num;i++){
        string crop = "[0:v]crop=" + list_filter[i] + ",boxblur=4[b" + to_string(i) + "]";
        crops.push_back(crop);
    }

    for (string ele:crops){
        cout << ele << endl;
    }

    for (int i=0;i < num;i++){
        vector<string> values = spt2.splits(list_filter[i],":");
        if (i==0){
            string over = "[0:v][b0]overlay=" + values[2] + ":" + values[3] + "[ovr0]";
            overs.push_back(over);
        } else {
            string over = "[ovr" + to_string(i-1) + "][b" + to_string(i) + "]overlay=" + values[2] + ":" + values[3] + "[ovr" + to_string(i) + "]";
            overs.push_back(over);
        }
    }

    for (string ele:overs){
        cout << ele << endl;
    }

    crops.insert(crops.end(), overs.begin(), overs.end());

    int num2 = crops.size();
    for (int i = 0;i < num2;i++){
        if (i != num2 - 1){
            comp += crops[i] + ";\\" + "\n";
        } else {
            comp += crops[i];
        }
    }

    cout << "comp: " << comp << endl;

    string cmd =  "/opt/homebrew/Cellar/ffmpeg/5.1/bin/ffmpeg -i " + input + " -filter_complex \\\n\"" + comp + "\"\\\n -map \"[ovr" + to_string(num-1) + "]\" " + output;
    cout << "cmd: " << cmd << endl;

    return cmd;
}