使用開源軟件FFmpeg將各種格式視頻轉換成MP4視頻格式(最簡單方法)



前言

這是FFmpeg的官方介紹:
FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge. No matter if they were designed by some standards committee, the community or a corporation. It is also highly portable: FFmpeg compiles, runs, and passes our testing infrastructure FATE across Linux, Mac OS X, Microsoft Windows, the BSDs, Solaris, etc. under a wide variety of build environments, machine architectures, and configurations.
It contains libavcodec, libavutil, libavformat, libavfilter, libavdevice, libswscale and libswresample which can be used by applications. As well as ffmpeg, ffplay and ffprobe which can be used by end users for transcoding and playing.
The FFmpeg project tries to provide the best technically possible solution for developers of applications and end users alike. To achieve this we combine the best free software options available. We slightly favor our own code to keep the dependencies on other libs low and to maximize code sharing between parts of FFmpeg. Wherever the question of “best” cannot be answered we support both options so the end user can choose.
FFmpeg官方網站



簡單來說,FFmpeg開源免費,功能強大,視頻轉碼只是它部分功能。

此文章只介紹使用此工具進行各種視頻轉成mp4。轉成其他格式視頻方法差不多。

  • 我的電腦系統:windows10
  • FFmpeg版本:ffmpeg 4.3.1

下載FFmpeg客戶端

在FFmpeg官網下載界面內進行下載

FFmpeg下載界面:http://ffmpeg.org/download.html

將發現如下圖所示界面,根據你的電腦系統來下載,有linux,windows,mac


在這裏插入圖片描述
先將鼠標放到win圖標上面,將出現兩個鏈接,如上圖。兩個都可以下載。我以第一個鏈接爲例。
點開出現下圖界面。




在這裏插入圖片描述

找到 release(發行版本較穩定),這幾個鏈接都可以下載,我是從第一個鏈接下載


# 安裝FFmpeg 安裝很簡單,直接解壓就好了。下載好之後,解壓你的壓縮包。 這是我的安裝的文件夾目錄 ![一級目錄](https://img-blog.csdnimg.cn/20210130094439726.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0NyYXlvbnhpbjIwMDA=,size_16,color_FFFFFF,t_70#pic_center) ![在這裏插入圖片描述](https://img-blog.csdnimg.cn/20210130094522678.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0NyYXlvbnhpbjIwMDA=,size_16,color_FFFFFF,t_70#pic_center) 你會發現在bin文件夾裏有三個文件,ffmpeg.exe,ffplay.exe,ffprobe.exe。本文章內容只用到ffmpeg.exe

開始使用

打開PowerShell頁面

按住shift同時,右鍵文件夾空的地方,會出現如下菜單,點擊“在此處打開…”,進入powershell界面。
(也可以打開cmd,cd命令切到這個目錄下。後期如果經常轉換的話,可以設置一下系統變量,以後也方便)。

在這裏插入圖片描述

在這裏插入圖片描述

輸入ffmpeg ,驗證是否可以使用;

在這裏插入圖片描述
出現上圖界面,就可以使用了,如果報錯;
可以嘗試加這個代碼試試:

start ffmpeg

然後ffmpeg應該可以了。

開始轉換視頻

 ffmpeg -i E:\影音\影視\汪汪隊立大功第三季第一集.ts  D:\轉換後的文件名.mp4 

E:\影音\影視\汪汪隊立大功第三季第一集.ts 這是你要轉的視頻文件。

D:\轉換後的文件名.mp4 這是你的視頻文件,文件後綴名爲你想要轉的格式名字。
在這裏插入圖片描述
等一會就好了。


總結

其實FFmpeg加上參數可以使用更多的功能,上述只是最簡單的方法,還可以加參數例如
-f 指定格式
-r 指定幀率
-s分辨率
-b:v 指定碼率



詳細請看官方文檔:http://ffmpeg.org/ffmpeg.html


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章