国产探花免费观看_亚洲丰满少妇自慰呻吟_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;

            }

        }

    }

}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 柏乡县| 正阳县| 南投市| 滨州市| 射阳县| 阿坝县| 鄂伦春自治旗| 镇雄县| 武宁县| 隆昌县| 中江县| 渝中区| 深水埗区| 屯门区| 桂林市| 威海市| 临海市| 安泽县| 贵阳市| 吉林省| 武陟县| 铜山县| 德格县| 五家渠市| 会昌县| 观塘区| 花莲市| 临海市| 时尚| 民和| 阿图什市| 吐鲁番市| 甘谷县| 永宁县| 金川县| 东光县| 民丰县| 明星| 崇信县| 凤翔县| 镇坪县|