FFmpeg 实现视频合并,转码,拼接
生活随笔
收集整理的這篇文章主要介紹了
FFmpeg 实现视频合并,转码,拼接
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1.下載ffmpeg,地址:http://www.ffmpeg.org/download.html
2.配置 ffmpeg 環(huán)境,我的路勁如下圖,如果你的path有參數(shù)則在后面追加ffmpeg.exe 的路徑 (如果不行的話,使用用戶變量的 Path)? ??;d:\ffmpeg\bin?
3.代碼如下:
using System.Collections; using System.Collections.Generic; using UnityEngine;public class NewBehaviourScript : MonoBehaviour {static string FFmpegPath = @"D:\ffmpeg\bin\ffmpeg.exe";// Use this for initializationvoid Start () {//視頻轉(zhuǎn)碼//string para = string.Format("-i {0} -b 1024k -acodec copy -f mp4 {1}", videoUrl, targetUrl);// RunMyProcess(para);// 視頻拼接//string para = string.Format(" -f concat -safe 0 -i {0} -c copy {1}", @"F:\Videos\filelist.txt", @"F:\Videos\c.mp4");//RunMyProcess(para);// 同時(shí)顯示string para = "-i D:\\ffmpeg\\1.mp4 -i D:\\ffmpeg\\2.mp4 -i D:\\ffmpeg\\3.mp4 -i D:\\ffmpeg\\4.mp4 -filter_complex \"[0:v]pad=iw*2:ih*2[a];[a][1:v]overlay=w[b];[b][2:v]overlay=0:h[c];[c][3:v]overlay=w:h\" D:\\ffmpeg\\combineOut.mp4";RunMyProcess(para);}static void RunMyProcess(string Parameters){var p = new System.Diagnostics.Process();p.StartInfo.FileName = FFmpegPath;p.StartInfo.Arguments = Parameters;//是否使用操作系統(tǒng)shell啟動(dòng)p.StartInfo.UseShellExecute = true;//不顯示程序窗口p.StartInfo.CreateNoWindow = false;p.Start();Debug.Log("\n開始轉(zhuǎn)碼...\n");p.WaitForExit();p.Close();Debug.Log("\n轉(zhuǎn)碼完畢...\n");} }特別注意的是視頻拼接 F:\Videos\filelist.txt? 這個(gè)文件為下圖:
總結(jié)
以上是生活随笔為你收集整理的FFmpeg 实现视频合并,转码,拼接的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: STM32单片机语音识别MP3播放器音乐
- 下一篇: 怎么给PPT加密、选用隐大师U盘