Is there a way to let ffmpeg read from multiple buffers or multiple named pipes ?
Basically I want to output the first loop to different pipes instead of .jpg files, and run the video filter command using those pipes as input. Right now enormous disk IO is needed to create and read jpg tiles.
// heic -> tiles -> jpeg tiles
#pragma omp parallel for
for(uint i = 0; i < data.tiles.size(); ++i) {
char buff[100];
snprintf(buff, sizeof(buff), "./tmp/%03d.jpg", data.tiles[i].idx);
std::string cmdStr = "ffmpeg -i - -loglevel warning -frames:v 1 -vsync vfr -an -q:v 1 " + std::string(buff);
FILE * pipe_in;
if(pipe_in = popen(cmdStr.c_str(), "w")) {
fwrite((char*)&data.tiles[i].data[0], 1, data.tiles[i].data.size(), pipe_in);
fflush(pipe_in);
fclose(pipe_in);
}
}
... some processing
// jpeg tiles -> big jpeg
std::string inputStr = "./tmp/%03d.jpg";
std::string cmdStr = "ffmpeg -i " + inputStr +
" -loglevel warning -threads 4 -q:v 1 -vf \"tile=" + std::to_string(data.cols) + "x" + std::to_string(data.rows) +
",crop=" + std::to_string(data.width) + ":" + std::to_string(data.height) + ":0:0" +
transStr + "\" -y " + outputStr;
ret = std::system(cmdStr.c_str());