国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

視頻轉碼在實際項目中的應用

2019-11-14 14:07:53
字體:
來源:轉載
供稿:網友

視頻轉碼在實際項目中的應用

前言:因之前有遇到在項目中將.flv文件視頻轉換為.mp4,故作此記錄,以下是使用ffmpeg.exe作為轉碼工具。

1:接下來需要準備工具;http://ffmpeg.org/  下載相應版本的ffmpeg.exe(64+32)

2:實現代碼,以下只是其中一種實現方式:

using System;

using System.Collections.Generic;

using System.Diagnostics;

using System.Linq;

using System.Web;

 

namespace VideoConvert.Models

{

    public class FFmpegHelper

    {

        /// <summary>

        /// 32位

        /// </summary>

        

                //判斷系統版本:

                Is32Or64();

                p.StartInfo.Arguments = arg;

                p.StartInfo.FileName = path;

                p.StartInfo.RedirectStandardError = true;

                p.StartInfo.RedirectStandardInput = true;

                p.StartInfo.RedirectStandardOutput = true;

                //表示不顯示轉碼窗口

                p.StartInfo.CreateNoWindow = true;

                p.StartInfo.UseShellExecute = false;

                //設置進程終止時觸發事件;

                p.EnableRaisingEvents = true;

                p.Exited += new EventHandler(p_Exited);

                p.OutputDataReceived +=new DataReceivedEventHandler(p_OutputDataReceived);

                p.ErrorDataReceived +=new DataReceivedEventHandler(p_ErrorDataReceived);

                p.Start();

                //讀取輸出;

                p.BeginOutputReadLine();

                p.BeginErrorReadLine();

                //設置等待進程觸發p_Exited事件后在往下執行;

                p.WaitForExit();

            }

        }

 

        void p_ErrorDataReceived(object sender, DataReceivedEventArgs e)

        {

            //記錄輸出日志

        }

 

        void p_OutputDataReceived(object sender, DataReceivedEventArgs e)

        {

            //記錄輸出日志

        }

 

        void p_Exited(object sender, EventArgs e)

        {

            //進程退出觸發該事件,可以利用此執行其它操作或者是判斷

        }

 

        public void Is32Or64()

        {

            if (Environment.Is64BitOperatingSystem)

            {

                path = ffmpegPath64;

            }

            else {

                path = ffmpegPath32;

            }

        }

    }

}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 罗平县| 贵德县| 宁陵县| 深圳市| 右玉县| 鹿泉市| 新昌县| 巨鹿县| 永昌县| 长阳| 云梦县| 阿瓦提县| 宁明县| 沧源| 体育| 洛浦县| 台北市| 西吉县| 镇安县| 门源| 尉氏县| 泰兴市| 彭水| 丰城市| 镇坪县| 互助| 西乡县| 鄯善县| 中西区| 盖州市| 和林格尔县| 虞城县| 随州市| 三门县| 泊头市| 恭城| 涿鹿县| 兴城市| 江都市| 九龙坡区| 鹿邑县|