转换失败!管道中带有自定义 exe 的 FFMpeg
Conversion failed! FFMpeg with custom exe in a pipe
我需要使用带有 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 rawvideo pipe:
或与其他 ffmpeg 管道命令一起使用
ffmpeg -y -hide_banner -i %input% -vf format=gray -f rawvideo 管道: | ffmpeg -hide_banner -y -framerate 30 ...
它也很完美。
所以MY_CUSTOM_EXE中的问题,但是如果只有一行代码会是什么?
你必须让你的程序使用 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.
将修复此特定错误。
我需要使用带有 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 rawvideo pipe:
或与其他 ffmpeg 管道命令一起使用
ffmpeg -y -hide_banner -i %input% -vf format=gray -f rawvideo 管道: | ffmpeg -hide_banner -y -framerate 30 ...
它也很完美。
所以MY_CUSTOM_EXE中的问题,但是如果只有一行代码会是什么?
你必须让你的程序使用 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.
将修复此特定错误。