我需要使用带有FFmpeg管道查询的批处理文件。我有一组图像(img0.bmp, img1.bmp, img2.bmp),我需要FFmpeg遍历它们并将原始数据传递给我的自定义.exe。
因此,查询如下所示
ffmpeg -y -hide_banner -i img%01d.bmp -vf format=gray -f rawvideo pipe: | MY_CUSTOM_EXE自定义exe的代码非常简单,如下所示
int main()
{
return 0;
}这个故事的诀窍是,如果我传递给FFmpeg exe一个像这样的... -i img0.bmp ...图像,它就可以工作,但是如果有一个设置的... -i img%01d.bmp ...,那么我在第一次交互后就会得到这样的错误:
Input #0, image2, from 'img%01d.bmp':
Duration: 00:00:00.12, start: 0.000000, bitrate: N/A
Stream #0:0: Video: bmp, pal8, 4096x3000, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (bmp (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, rawvideo, to 'pipe:':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 4096x3000, q=2-31, 2457600 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc58.54.100 rawvideo
av_interleaved_write_frame(): Invalid argument
Error writing trailer of pipe:: Invalid argument
frame= 1 fps=0.0 q=-0.0 Lsize= 12000kB time=00:00:00.04 bitrate=2457600.0kbits/s speed=0.999x
video:12000kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
Conversion failed!
Press any key to continue . . .另外,如果我像这样使用这个查询
ffmpeg -y -hide_banner -i img%01d.bmp -vf format=gray -f原始视频管道:
或使用其他ffmpeg管道命令
ffmpeg -y -hide_banner -i %input% -vf format=gray -f原始视频管道:| ffmpeg -hide_banner -y -framerate 30...
它也能完美地工作。
那么MY_CUSTOM_EXE中的问题,但如果它只有一行代码,会是什么呢?
发布于 2021-06-17 23:08:54
你必须让你的程序使用来自ffmpeg的输出,否则你会得到你所描述的错误。
我测试了一下我的预感,结果是:
av_interleaved_write_frame(): Broken pipe
Error writing trailer of pipe:: Broken pipe所以一个简单的
#include<iostream>
int main(){
char c;
while(std::cin >> c){} // consume everything the pipe offers
} // return 0 implied.将修复此特定错误。
https://stackoverflow.com/questions/68021677
复制相似问题