ffmpeg输出管道命名为windows管道 [英] ffmpeg output pipeing to named windows pipe

查看:2418
本文介绍了ffmpeg输出管道命名为windows管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题与我之前的问题有关:将原始帧转换为webm直播流

我想将视频管道传输到ffmpeg并通过另一个管道读取,但是我无法管道输出 ffmpeg.exe 到Windows上的命名管道。

I want to pipe a video to ffmpeg and read it back through another pipe, but I cannot pipe the output of ffmpeg.exe to a named pipe on windows.

我在C#中的管道定义:

My definition of the pipes in C#:

NamedPipeServerStream p_to_ffmpeg;
NamedPipeServerStream p_from_ffmpeg;
p_to_ffmpeg = new NamedPipeServerStream("to_ffmpeg", PipeDirection.Out, 1, PipeTransmissionMode.Byte);
p_from_ffmpeg = new NamedPipeServerStream("from_ffmpeg", PipeDirection.In, 1, PipeTransmissionMode.Byte);

然后我开始 ffmpeg.exe 具有以下选项的单独进程: -f rawvideo -vcodec rawvideo -video_size 656x492 -r 10 -pix_fmt rgb24 -i \\.\pipe\to_ffmpeg -c:v libvpx -pass 1 -f webm \\.\pipe\from_ffmpeg

And then I start ffmpeg.exe in a separate process with the following options: -f rawvideo -vcodec rawvideo -video_size 656x492 -r 10 -pix_fmt rgb24 -i \\.\pipe\to_ffmpeg -c:v libvpx -pass 1 -f webm \\.\pipe\from_ffmpeg

ffmpeg.exe拒绝写入管道,出现以下错误: 文件'\\.\pipe\from_ffmpeg'已经存在。覆盖? [y / N]

ffmpeg.exe refuses to write to the pipe with the following error : File '\\.\pipe\from_ffmpeg' already exists. Overwrite ? [y/N]

当我用文件名替换输出管道时,它的作用就像charm: -f rawvideo -vcodec rawvideo -video_size 656x492 -r 10 -pix_fmt rgb24 -i \\.\pipe\to_ffmpeg -c:v libvpx -pass 1 -f webm output.webm

When I replace the "output pipe" with a file name, it works like charm: -f rawvideo -vcodec rawvideo -video_size 656x492 -r 10 -pix_fmt rgb24 -i \\.\pipe\to_ffmpeg -c:v libvpx -pass 1 -f webm output.webm

如何让ffmpeg在Windows中写入命名管道?

编辑:当我强制使用ffmpeg的 -y 选项写入管道时,我收到以下错误:无法为输出文件写入头文件# 0(错误的编解码器参数?):发生错误号-32

When I force to write to the pipe with ffmpeg's -y option, I get the following error: Could not write header for output file #0 (incorrect codec parameters ?): Error number -32 occurred

推荐答案

可以通过向ffmpeg命令添加 -y 选项并指定管道的缓冲区大小来解决。

It seems like the problem can be solved by adding the -y option to the ffmpeg command and specifying a buffer size for the pipe.

我的ffmpeg命令(见aergistal的评论为什么我也删除了 -pass 1 标志): -y -f rawvideo -vcodec rawvideo -video_size 656x492 -r 10 -pix_fmt rgb24 -i \ \\\pipe\to_ffmpeg -c:v libvpx -f webm \\.\pipe\from_ffmpeg

My ffmpeg command (see aergistal's comment why I also removed the -pass 1 flag): -y -f rawvideo -vcodec rawvideo -video_size 656x492 -r 10 -pix_fmt rgb24 -i \\.\pipe\to_ffmpeg -c:v libvpx -f webm \\.\pipe\from_ffmpeg

定义命名管道如下:

p_from_ffmpeg = new NamedPipeServerStream(pipename_from, 
    PipeDirection.In, 
    1, 
    PipeTransmissionMode.Byte, 
    System.IO.Pipes.PipeOptions.WriteThrough, 
    10000, 10000);

这篇关于ffmpeg输出管道命名为windows管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆