視頻轉(zhuǎn)碼
ffmpeg -rtsp_transport? tcp -i "rtsp://admin:a1234567@192.168.2.239:554/cam/realmonitor?channel=1&subtype=1" -vcodec libx264 -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 -f flv "rtmp://192.168.2.251:1935/rtmp-live/239"
ffmpeg -rtsp_transport? tcp -i "rtsp://admin:a1234567@192.168.2.240:554/cam/realmonitor?channel=1&subtype=1" -vcodec libx264 -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 -f flv "rtmp://192.168.2.251:1935/rtmp-live/240"
ffmpeg -rtsp_transport? tcp -i "rtsp://admin:a1234567@192.168.2.223:554/cam/realmonitor?channel=1&subtype=1" -vcodec libx264 -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 -f flv "rtmp://192.168.2.251:1935/rtmp-live/223"
---------------------------------------------------------------------------------------------------------------------------
frame: 編碼的幀數(shù)量
fps:每秒編碼的幀數(shù)
q:質(zhì)量因子
size/ Lsize:視頻和音頻編碼后的大小,即基本等于視頻和音頻 之和
time:輸出幀的顯示時(shí)間
bitrate:輸出視頻的幀率
dup:輸入幀重復(fù)(dupliate)的數(shù)量
drop:輸入幀丟棄(drop)的個(gè)數(shù)
speed:編碼速度
---------------------------------------------------------------------------------------------------------------------------
視頻錄制
ffmpeg -rtsp_transport? tcp -i "rtsp://admin:a1234567@192.168.2.240:554/cam/realmonitor?channel=1&subtype=1"–vcodec copy out.avi
---------------------------------------------------------------------------------------------------------------------------
視頻剪切
ffmpeg -rtsp_transport? tcp -ss 0:0 -t 0:10 -i "rtsp://admin:a1234567@192.168.2.240:554/cam/realmonitor?channel=1&subtype=1" output.mp4
---------------------------------------------------------------------------------------------------------------------------
RTMP
————————————————————————————————————————————————————————
ffmpeg -re -i keep.mp4? -acodec aac -ar 44100? -strict -2 -ac 1 -f flv rtmp://192.168.2.251:1935/hls/keep
ffmpeg -rtsp_transport tcp -i "rtsp://admin:a1234567@192.168.2.239:554/cam/realmonitor?channel=1&subtype=1"? -ar 44100 -ac 1 -f flv "rtmp://192.168.2.251:1935/hls/itc"
————————————————————————————————————————————————————————
HLS
————————————————————————————————————————————————————————
ffmpeg? -i "rtsp://admin:a1234567@192.168.2.128:554/cam/realmonitor?channel=1&subtype=1"? -vcodec copy -acodec copy? -vbsf h264_mp4toannexb? -f hls -hls_time 2 -hls_wrap 10 "D:\xampp\htdocs\hb.m3u8"
————————————————————————————————————————————————————————
FFMPEG 常見(jiàn)命令和參數(shù)說(shuō)明
——————————————————
-rtsp_transport? tcp 強(qiáng)制使用TCP采集rtsp
-i 輸入文件
-vcodec 視頻編解碼格式
-vprofile H.264有四種畫質(zhì)級(jí)別,分別是baseline, extended, main, high:
1、Baseline Profile:基本畫質(zhì)。支持I/P 幀,只支持無(wú)交錯(cuò)(Progressive)和CAVLC;
2、Extended profile:進(jìn)階畫質(zhì)。支持I/P/B/SP/SI 幀,只支持無(wú)交錯(cuò)(Progressive)和CAVLC;(用的少)
3、Main profile:主流畫質(zhì)。提供I/P/B 幀,支持無(wú)交錯(cuò)(Progressive)和交錯(cuò)(Interlaced), 也支持CAVLC 和CABAC 的支持;
4、High profile:高級(jí)畫質(zhì)。在main Profile 的基礎(chǔ)上增加了8x8內(nèi)部預(yù)測(cè)、自定義量化、 無(wú)損視頻編碼和更多的YUV 格式;
H.264 Baseline profile、Extended profile和Main profile都是針對(duì)8位樣本數(shù)據(jù)、4:2:0格式(YUV)的視頻序列。
在相同配置情況下,High profile(HP)可以比Main profile(MP)降低10%的碼率。 根據(jù)應(yīng)用領(lǐng)域的不同,Baseline profile多應(yīng)用于實(shí)時(shí)通信領(lǐng)域,Main profile多應(yīng)用于流媒體領(lǐng)域,High profile則多應(yīng)用于廣電和存儲(chǔ)領(lǐng)域。
-acodec 音頻編碼格式,未設(shè)定則和輸入相同
-f 設(shè)定輸出格式
-ar 設(shè)定采樣頻率
-ac 設(shè)定聲音的channel數(shù)
-an 不處理音頻
-t 時(shí)間
-f 輸出格式及路徑
-b 比特率,每秒的比特?cái)?shù)
-s size,分辨率
-r 幀率,每秒顯示多少幀圖片