日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

ffplay flv mp4 转_FLV与MP4格式视频转换

發(fā)布時(shí)間:2023/12/20 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ffplay flv mp4 转_FLV与MP4格式视频转换 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

【實(shí)例簡(jiǎn)介】

這個(gè)是一windows服務(wù)程序,可以通過配置指定的視頻文件夾轉(zhuǎn)換flv的視頻為MP4格式。

此服務(wù)調(diào)用ffmpeg.exe應(yīng)用程序進(jìn)行視頻轉(zhuǎn)換

【實(shí)例截圖】

【核心代碼】

string ffmpeg = Transfrom.ffmpegtool;

string ? path ? = ? System.IO.Directory.GetCurrentDirectory();//Environment.CurrentDirectory

if (string.IsNullOrEmpty(ffmpeg))

{

ffmpeg = path ffmpeg;

}

else

{

//ffmpeg = ffmpeg "\\ffmpeg\\ffmpeg.exe";

}

FileLog.Error("文件路徑:" ffmpeg);

//判斷轉(zhuǎn)換工具,轉(zhuǎn)換文件是否存在

if ((!System.IO.File.Exists(ffmpeg)) || (!System.IO.File.Exists(fileName)))

{

//Log.Info("ffmpeg.exe或轉(zhuǎn)換文件不存在!");

return "false";

}

//獲得(.flv)文件

string flv_file = System.IO.Path.ChangeExtension(playFile, extenName);

Process p = new Process();//建立外部調(diào)用線程

try

{

//執(zhí)行文件轉(zhuǎn)換

p.StartInfo.FileName = ffmpeg;//要調(diào)用外部程序的絕對(duì)路徑

p.StartInfo.Arguments = @"-y -i " fileName " -acodec libfaac -ab 64k -vcodec libx264 -threads 0 -coder 1 -flags loop -cmp chroma -partitions parti8x8 parti4x4 partp8x8 partb8x8 -me_method umh -subq 8 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -directpred 3 -trellis 1 -flags2 bpyramid mixed_refs wpred dct8x8 fastpskip -wpredp 2 -rc_lookahead 50 -refs 6 -bf 5 -b_strategy 2 -crf 22 " "" " -s 640x" 360 " " flv_file;

// " -i " fileName " -ab 56 -ar 22050 -b 500 -r 15 -s " widthSize "x" heightSize " " flv_file; //" -i " fileName " -ar 22050 ?" flv_file;//參數(shù)(這里就是FFMPEG的參數(shù)了)

p.StartInfo.UseShellExecute = false;//不使用操作系統(tǒng)外殼程序啟動(dòng)線程(一定為FALSE,詳細(xì)的請(qǐng)看MSDN)

p.StartInfo.RedirectStandardError = true;//把外部程序錯(cuò)誤輸出寫到StandardError流中(這個(gè)一定要注意,FFMPEG的所有輸出信息,都為錯(cuò)誤輸出流,用StandardOutput是捕獲不到任何消息的...這是我耗費(fèi)了2個(gè)多月得出來的經(jīng)驗(yàn)...mencoder就是用standardOutput來捕獲的)

//p.StartInfo.CreateNoWindow = false;//不創(chuàng)建進(jìn)程窗口

p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

p.StartInfo.RedirectStandardInput = true;

p.StartInfo.RedirectStandardOutput = true;

p.StartInfo.RedirectStandardError = true;

p.StartInfo.CreateNoWindow = true;

p.Start();//啟動(dòng)線程

//p.WaitForExit();//等待完成

p.StandardError.ReadToEnd();//開始同步讀取

}

catch (Exception e)

{

//Log.Info("視頻轉(zhuǎn)碼出錯(cuò) Error={0}", e.ToString());

return "false";

}

finally

{

p.Close();//關(guān)閉進(jìn)程

p.Dispose();//釋放資源

}

總結(jié)

以上是生活随笔為你收集整理的ffplay flv mp4 转_FLV与MP4格式视频转换的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。