如何在C#中的ffmpeg中使用管道

安德鲁·辛普森

我有100个jpeg。

我使用ffmpeg编码为视频文件,然后将其写入硬盘。

有没有办法将其直接传递到字节/流?

我正在使用C#,并且正在使用进程类来初始化ffmpeg。

谢谢

Themadmax
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;

namespace PipeFfmpeg
{
    class Program
    {
        public static void Video(int bitrate, int fps, string outputfilename)
        {
            Process proc = new Process();

            proc.StartInfo.FileName = @"ffmpeg.exe";
            proc.StartInfo.Arguments = String.Format("-f image2pipe -i pipe:.bmp -maxrate {0}k -r {1} -an -y {2}",
                bitrate, fps, outputfilename);
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.RedirectStandardInput = true;
            proc.StartInfo.RedirectStandardOutput = true;

            proc.Start();

            for (int i = 0; i < 500; i++)
            {
                using (var ms = new MemoryStream())
                {
                    using (var img = Image.FromFile(@"lena.png"))
                    {
                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
                        ms.WriteTo(proc.StandardInput.BaseStream);
                    }
                }
            }            
        }

        static void Main(string[] args)
        {
            Video(5000, 10, "lena.mp4");
        }
    }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

当管道到ffmpeg时如何在python3中使用stdout.write?

来自分类Dev

如何在C#中使用SQL Server中的值

来自分类Dev

如何在C#中的Telegram bot中使用SendDocumentAsync?

来自分类Dev

c# - 如何在catch中使用try中的对象

来自分类Dev

如何在R中的函数中使用dplyr / magrittr的管道?

来自分类常见问题

如何在r中的条件匹配中使用管道?

来自分类Dev

在find中如何在-exec中使用管道

来自分类Dev

如何在UnitTest ++ 1.4中使用jenkins管道脚本

来自分类Dev

如何在C#中使用ThreadPool?

来自分类Dev

如何在C#中使用__doPostback

来自分类Dev

如何在C#中使用[DllImport(“”)]?

来自分类Dev

如何在C#中使用CompositeTransform?

来自分类Dev

如何在C#中使用CreateUserProfileEx

来自分类Dev

如何在C#中使用ThreadPool?

来自分类Dev

如何在C#中使用CompositeTransform?

来自分类Dev

如何在C#中使用属性

来自分类Dev

如何在C#中使用ScriptEngine

来自分类Dev

如何在c#中使用库

来自分类Dev

如何在 Objective-C 中使用 FFmpeg 在 macOS 中录制屏幕?

来自分类Dev

如何在发布管道中使用构建管道中的自定义变量

来自分类Dev

c# - 如何在c#中的非异步函数中使用await调用异步函数?

来自分类Dev

如何在管道中使用状态?

来自分类Dev

如何在Delphi中使用管道模式

来自分类Dev

如何在ggplot管道中使用子集?

来自分类Dev

如何在管道中使用状态?

来自分类Dev

如何在管道中使用猫

来自分类Dev

如何在管道中使用“ sed”

来自分类Dev

如何在变量引用中使用管道?

来自分类Dev

如何在管道中使用 ngModelChange