1. 程式人生 > >[win10] ffmpeg 學習筆記

[win10] ffmpeg 學習筆記

目錄

1.官方宣傳

2.下載與安裝

2.1 下載

2.2 安裝

3.用法

 3.1  ...\ffmpeg\bin 下三個exe的解釋

3.1.1 ffmpeg.exe

3.1.2 ffplay.exe

3.1.3 ffprobe.exe

3.2 ffmpeg 命令列

 


 

1.官方宣傳

        一個完整的跨平臺解決方案,用於錄製,轉換和流式傳輸音訊和視訊。FFmpeg是領先的多媒體框架,能夠解碼編碼 轉碼複用流式傳輸

過濾播放人類和機器建立的任何內容。它支援最晦澀難懂的古代格式,直至最前沿。無論它們是由某些標準委員會,社群還是公司設計的。它還具有高度可移植性:FFmpeg 在各種構建環境,機器架構和配置下,跨Linux,Mac OS X,Microsoft Windows,BSD,Solaris等編譯,執行和傳遞我們的測試基礎架構 FATE

2.下載與安裝

2.1 下載

官網:https://ffmpeg.zeranoe.com/builds/

  • FFmpeg分為3個版本:StaticSharedDev
  • 前兩個版本可以直接在命令列中使用。包含了三個exe:ffmpeg.exe
    ffplay.exeffprobe.exe
  • Static版本中的exe體積較大,那是因為相關的Dll都已經編譯進exe裡面去了。
  • Shared版本中exe的體積相對小很多,是因為它們執行的時候還需要到相關的dll中呼叫相應的功能
  • Dev版本用於開發,裡面包含了庫檔案xxx.lib以及標頭檔案xxx

本博主下載的是 ffmpeg-20181028-bdfd2e3-win64-static 

2.2 安裝

他沒有安裝程式,我們需要把包含exe的那個資料夾放入環境變數,重啟電腦即可。

3.用法

 

 3.1  ...\ffmpeg\bin 下三個exe的解釋

       藉由雷神的 https://blog.csdn.net/leixiaohua1020/article/details/15811977,我們可以瞭解ffmpeg.exe、ffplay.exe和ffprobe.exe 的用法

3.1.1 ffmpeg.exe


ffmpeg是用於轉碼的應用程式。

一個簡單的轉碼命令可以這樣寫:

將input.avi轉碼成output.ts,並設定視訊的位元速率為640kbps

ffmpeg -i input.avi -b:v 640k output.ts

具體的使用方法可以參考: ffmpeg引數中文詳細解釋
詳細的使用說明(英文):http://ffmpeg.org/ffmpeg.html

3.1.2 ffplay.exe


ffplay是用於播放的應用程式。

一個簡單的播放命令可以這樣寫:

播放test.avi

ffplay test.avi


具體的使用方法可以參考:ffplay的快捷鍵以及選項
詳細的使用說明(英文):http://ffmpeg.org/ffplay.html

3.1.3 ffprobe.exe
 

ffprobe是用於檢視檔案格式的應用程式。

這個就不多介紹了。

詳細的使用說明(英文):http://ffmpeg.org/ffprobe.html

 

 

3.2 ffmpeg 命令列

在cmd中 ffmpeg.exe -h 檢視ffmpeg說明,可以看到:

usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Getting help:
    -h      -- print basic options
    -h long -- print more options
    -h full -- print all options (including all format and codec specific options, very long)
    -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf
    See man ffmpeg for detailed description of the options.

Print help / information / capabilities:
-L                  show license
-h topic            show help
-? topic            show help
-help topic         show help
--help topic        show help
-version            show version
-buildconf          show build configuration
-formats            show available formats
-muxers             show available muxers
-demuxers           show available demuxers
-devices            show available devices
-codecs             show available codecs
-decoders           show available decoders
-encoders           show available encoders
-bsfs               show available bit stream filters
-protocols          show available protocols
-filters            show available filters
-pix_fmts           show available pixel formats
-layouts            show standard channel layouts
-sample_fmts        show available audio sample formats
-colors             show available color names
-sources device     list sources of the input device
-sinks device       list sinks of the output device
-hwaccels           show available HW acceleration methods

Global options (affect whole program instead of just one file:
-loglevel loglevel  set logging level
-v loglevel         set logging level
-report             generate a report
-max_alloc bytes    set maximum size of a single allocated block
-y                  overwrite output files
-n                  never overwrite output files
-ignore_unknown     Ignore unknown stream types
-filter_threads     number of non-complex filter threads
-filter_complex_threads  number of threads for -filter_complex
-stats              print progress report during encoding
-max_error_rate maximum error rate  ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.
-bits_per_raw_sample number  set the number of bits per raw sample
-vol volume         change audio volume (256=normal)

Per-file main options:
-f fmt              force format
-c codec            codec name
-codec codec        codec name
-pre preset         preset name
-map_metadata outfile[,metadata]:infile[,metadata]  set metadata information of outfile from infile
-t duration         record or transcode "duration" seconds of audio/video
-to time_stop       record or transcode stop time
-fs limit_size      set the limit file size in bytes
-ss time_off        set the start time offset
-sseof time_off     set the start time offset relative to EOF
-seek_timestamp     enable/disable seeking by timestamp with -ss
-timestamp time     set the recording timestamp ('now' to set the current time)
-metadata string=string  add metadata
-program title=string:st=number...  add program with specified streams
-target type        specify target file type ("vcd", "svcd", "dvd", "dv" or "dv50" with optional prefixes "pal-", "ntsc-" or "film-")
-apad               audio pad
-frames number      set the number of frames to output
-filter filter_graph  set stream filtergraph
-filter_script filename  read stream filtergraph description from a file
-reinit_filter      reinit filtergraph on input parameter changes
-discard            discard
-disposition        disposition

Video options:
-vframes number     set the number of video frames to output
-r rate             set frame rate (Hz value, fraction or abbreviation)
-s size             set frame size (WxH or abbreviation)
-aspect aspect      set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
-bits_per_raw_sample number  set the number of bits per raw sample
-vn                 disable video
-vcodec codec       force video codec ('copy' to copy stream)
-timecode hh:mm:ss[:;.]ff  set initial TimeCode value.
-pass n             select the pass number (1 to 3)
-vf filter_graph    set video filters
-ab bitrate         audio bitrate (please use -b:a)
-b bitrate          video bitrate (please use -b:v)
-dn                 disable data

Audio options:
-aframes number     set the number of audio frames to output
-aq quality         set audio quality (codec-specific)
-ar rate            set audio sampling rate (in Hz)
-ac channels        set number of audio channels
-an                 disable audio
-acodec codec       force audio codec ('copy' to copy stream)
-vol volume         change audio volume (256=normal)
-af filter_graph    set audio filters

Subtitle options:
-s size             set frame size (WxH or abbreviation)
-sn                 disable subtitle
-scodec codec       force subtitle codec ('copy' to copy stream)
-stag fourcc/tag    force subtitle tag/fourcc
-fix_sub_duration   fix subtitles duration
-canvas_size size   set canvas size (WxH or abbreviation)
-spre preset        set the subtitle options to the indicated preset

 

4.思考:接下來我們該做什麼?

        博主從來沒有見過-h出來這麼多命令的exe,這簡直就是在勸退所有初學者......ok,我先摸索摸索路子,船到橋頭自然直嘛。記錄一下,我找到一箇中文版的教程https://www.longqi.cf/tools/2015/02/13/ffmpegcn/,看了一下,其實就是翻譯,不過沒亂碼~感謝感謝,還有一個新一點的http://wiki.11ten.net/Resources/ffmpeg-%E4%B8%AD%E6%96%87%E6%96%87%E6%A1%A3.html

接下來我們慢慢剖析這些命令列,沒事,博主頭鐵。

 

 

參考

1.https://www.jianshu.com/p/7ed3be01228b 

2.https://blog.csdn.net/leixiaohua1020/article/details/15811977