視頻轉碼
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:質量因子
size/ Lsize:視頻和音頻編碼后的大小谜疤,即基本等于視頻和音頻 之和
time:輸出幀的顯示時間
bitrate:輸出視頻的幀率
dup:輸入幀重復(dupliate)的數(shù)量
drop:輸入幀丟棄(drop)的個數(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 常見命令和參數(shù)說明
——————————————————
-rtsp_transport? tcp 強制使用TCP采集rtsp
-i 輸入文件
-vcodec 視頻編解碼格式
-vprofile H.264有四種畫質級別,分別是baseline, extended, main, high:
1塞弊、Baseline Profile:基本畫質。支持I/P 幀,只支持無交錯(Progressive)和CAVLC;
2堪滨、Extended profile:進階畫質藏杖。支持I/P/B/SP/SI 幀,只支持無交錯(Progressive)和CAVLC褥赊;(用的少)
3、Main profile:主流畫質莉恼。提供I/P/B 幀拌喉,支持無交錯(Progressive)和交錯(Interlaced), 也支持CAVLC 和CABAC 的支持俐银;
4尿背、High profile:高級畫質。在main Profile 的基礎上增加了8x8內部預測捶惜、自定義量化田藐、 無損視頻編碼和更多的YUV 格式;
H.264 Baseline profile吱七、Extended profile和Main profile都是針對8位樣本數(shù)據(jù)汽久、4:2:0格式(YUV)的視頻序列。
在相同配置情況下踊餐,High profile(HP)可以比Main profile(MP)降低10%的碼率景醇。 根據(jù)應用領域的不同,Baseline profile多應用于實時通信領域吝岭,Main profile多應用于流媒體領域三痰,High profile則多應用于廣電和存儲領域。
-acodec 音頻編碼格式苍碟,未設定則和輸入相同
-f 設定輸出格式
-ar 設定采樣頻率
-ac 設定聲音的channel數(shù)
-an 不處理音頻
-t 時間
-f 輸出格式及路徑
-b 比特率酒觅,每秒的比特數(shù)
-s size,分辨率
-r 幀率微峰,每秒顯示多少幀圖片