日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

ffmpeg教程

發(fā)布時間:2025/4/16 55 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ffmpeg教程 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

一、命名格式

ffmpeg input(s) [codec options] output(s)

輸入(input)

參數(shù) -i Input.file/stream_url 輸入可以為一個文件,也可以是一個視頻流地址。
“-re” 選項標識以實時方式讀取文件;這允許使用文件作為 "live” 數(shù)據(jù)源。

編碼器(Codecs)

A huge array of options is available here, however we’ll only cover two things: Copying codecs and changing codecs to H264 for video and AAC for audio. H264/AAC 是最常用的編碼器are the most common codecs at the moment there’s a good chance you already have these in your files, otherwise re-encoding them to H264/AAC with the default settings of ffmpeg will almost certainly give you what you want. If not feel free to check out the ffmpeg documentation here.
使用-c:v設(shè)置視頻編碼;
使用-c:a設(shè)置音頻編碼;
使用-c設(shè)置音頻和視頻編碼。

Copying codecs (options)

The copying of codecs couldn’t be easier with ffmpeg. You only need to use -c copy to copy both the video and audio codecs. Copying the codecs allows you to ingest a media file/stream and record it or change it to a different format. You can also only copy a specific codec like this: -c:v copy for video and -c:a copy for audio. The neat thing about using the copy option is that it will not re-encode your media data, making this an extremely fast operation.

Encoding to H264/AAC (options)

Ffmpeg允許改變video and audio track separately. You can copy a video track while only editing the audio track if you wish. Copying is always done with the copy codec. An encode to H264/AAC is done by using the option -c:a aac -strict -2 -c:v h264. Older versions of ffmpeg might require the equivalent old syntax -acodec aac -strict -2 -vcodec h264 instead.

輸出(output)

The output of ffmpeg can either be a file or a push over a stream url. To record it to a file use outputfile.ext; almost any media type can be chosen by simply using the right extension. To push over a stream use -f FORMAT STREAM_URL. The most commonly used format for live streaming will be RTMP, but RTMP streams internally use the FLV format. That means you’ll have to use -f flv rtmp://SERVERIP:PORT/live/STREAMNAME for this. Other stream types may auto-select their format based on the URL, similar to how this works for files.

案例

(1)攝像頭信息采集和錄制推流

攝像頭名稱要通過這個命令拿到,然后替換掉下面的“Integrated Camera”這個名稱即可推流或者錄制成文件

ffmpeg -list_devices true -f dshow -i dummy
ffmpeg -f dshow -i video=“Integrated Camera” -vcodec libx264 -acodec copy -preset:v ultrafast -tune:v zerolatency -f flv rtmp://eguid.cc:1935/rtmp/eguid

(2)桌面屏幕錄制

1、屏幕錄制并保存成文件

ffmpeg -f gdigrab -i desktop eguid.mp4

2、屏幕錄制并推流

ffmpeg -f gdigrab -i desktop -vcodec libx264 -preset:v ultrafast
-tune:v zerolatency -f flv rtmp://eguid.cc:1935/rtmp/destop

(3)視頻文件推流

ffmpeg -re -i eguid.flv -vcodec copy -acodec copy -f flv -y
rtmp://eguid.cc:1935/rtmp/eguid

四、轉(zhuǎn)流(rtsp轉(zhuǎn)rtmp為例)

ffmpeg -i rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov
-rtsp_transport tcp -vcodec h264 -acodec aac -f flv rtmp://eguid.cc:1935/rtmp/eguid

五、拉流

ffmpeg -i rtmp://eguid.cc:1935/rtmp/eguid -vcodec h264 -f flv -acodec
aac -ac 2 eguid.flv

(6)音頻推流

ffmpeg -f mp3 -i sender.mp3 -acodec libmp3lame -ab 128k -ac 2 -ar
44100 -re -f rtp rtp://10.14.35.23:1234

流媒體服務(wù)

livego

Nginx RMTP模塊

RED5

客戶端

VLC media player

總結(jié)

以上是生活随笔為你收集整理的ffmpeg教程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

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