zoukankan      html  css  js  c++  java
  • C# 调用FFmpeg 根据图片合成视频

    1.项目结构:

    2.代码:

      

    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace WebFFmpeg
    {
        public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
                string pathString = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
                Process p = new Process();
                p.StartInfo.FileName = pathString + "\FFmpeg\ffmpeg.exe";
                p.StartInfo.Arguments = @"-y -r 1 -i " +
                                        pathString + @"FFmpegpicimg%2d.jpg -i " +
                                        pathString + @"FFmpegmusic2.mp3 -s 800x800 -vcodec mpeg4" +
                                        pathString + @"FFmpegvedioout.mp4";
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardError = true;
                p.StartInfo.Crea teNoWindow = true;
                p.ErrorDataReceived += new DataReceivedEventHandler((s, message) => { Response.Write(message.Data); });//外部程序(这里是FFMPEG)输出流时候产生的事件,这里是把流的处理过程转移到下面的方法中,详细请查阅MSDN
                p.Start();//启动线程
                p.BeginErrorReadLine();//开始异步读取
                p.WaitForExit();//阻塞等待进程结束
                p.Close();//关闭进程
                p.Dispose();//释放资源
    
                Response.Write("<a href='FFmpeg/vedio/out.mp4'>下载</a>");
            }
        }
    }

    3.Demo 连接

      http://share.weiyun.com/581ce7da333c175841c90931fdfd1756

  • 相关阅读:
    烤盐屋——Beta冲刺日志(2/7)
    团队作业第六次--Beta阶段随笔集合
    OneDay!——冲刺日志集合
    Beta冲刺答辩
    OneDay!——随机组队“吐槽”
    OneDay!——Beta冲刺总结
    用户使用调查报告
    Beta冲刺日志--Day 7
    Beta冲刺日志--Day 6
    Beta冲刺日志--Day 5
  • 原文地址:https://www.cnblogs.com/mingxuantongxue/p/4029426.html
Copyright © 2011-2022 走看看