日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

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

【實(shí)例簡介】

這個是一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)用外部程序的絕對路徑

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)外殼程序啟動線程(一定為FALSE,詳細(xì)的請看MSDN)

p.StartInfo.RedirectStandardError = true;//把外部程序錯誤輸出寫到StandardError流中(這個一定要注意,FFMPEG的所有輸出信息,都為錯誤輸出流,用StandardOutput是捕獲不到任何消息的...這是我耗費(fèi)了2個多月得出來的經(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();//啟動線程

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

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

}

catch (Exception e)

{

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

return "false";

}

finally

{

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

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

}

總結(jié)

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

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