2017-07-19 831 views
1

我目前正在錄製的視頻在我的聯想筆記本電腦憑藉其內置在使用的FFmpeg的Windows 10.我的目標之一是使CPU使用率儘可能低的攝像頭,這就是爲什麼我要推的H264編碼到GPU。 現在,我的筆記本電腦變得有點棘手。因爲它使用兩個GPU。第一款GPU是Intel HD 5500圖形單元作爲CPU的一部分。這個最喜歡用於非要求苛刻的應用程序,如辦公室等,以節省能源。另一款是AMD R5 M330,將用於遊戲等圖形密集型應用。FFmpeg:在Windows上使用AMD GPU編碼x264?

目前,我使用下面的命令來編碼網絡攝像頭流英特爾HD GPU:

ffmpeg -f dshow -vcodec mjpeg -video_size 1280x720 -framerate 30 video="Lenovo EasyCamera":audio="Mikrofon (Realtek High Definition Audio)" -c:v h264_qsv -g 60 -q 28 -look_ahead 0 -preset:v faster -c:a aac -q:a 0.6 -r 30 output.mp4 

這並不工作,但迄今爲止似乎這款GPU沒有足夠的動力能夠以跟上更高比特率的幀速率或大量的i幀。視頻開始缺乏並跳過幀。如果我使用CPU編碼,一切都很順利。

現在,我的筆記本電腦得到了第二AMD GPU有很多更多的權力這將是一個很好的嘗試在一個編碼,但我無法找到有關如何在AMD硬件編碼在Windows 10的任何信息,所以,我的問題是:ffmpeg命令如何使用AMD硬件進行h264編碼?

+1

他們還沒有在Windows上實現AMD VCE。 https://trac.ffmpeg.org/wiki/HWAccelIntro – halfelf

+0

好吧好吧這就是貝蒂,但看起來像AMF支持它計劃在今年實施......看起來我需要耐心與一個... – ZeroTek

+1

這似乎現在的最新版本工作,嘗試'-c:v h264_amf' –

回答

1

當前的ffmpeg的版本現在支持各大廠商的GPU硬件編碼。下面是該h264_amf(H.264)和hevc_amf(H.265或HEVC)編碼器,你將與AMD獨立顯卡使用,從ffmpeg -h full採取的選項:

h264_amf AVOptions: 
    -usage    <int>  E..V.... Encoder Usage (from 0 to 3) (default transcoding) 
    transcoding     E..V.... Generic Transcoding 
    ultralowlatency    E..V.... 
    lowlatency     E..V.... 
    webcam      E..V.... Webcam 
    -profile   <int>  E..V.... Profile (from 66 to 257) (default main) 
    main       E..V.... 
    high       E..V.... 
    constrained_baseline    E..V.... 
    constrained_high    E..V.... 
    -level    <int>  E..V.... Profile Level (from 0 to 62) (default auto) 
    auto       E..V.... 
    1.0       E..V.... 
    1.1       E..V.... 
    1.2       E..V.... 
    1.3       E..V.... 
    2.0       E..V.... 
    2.1       E..V.... 
    2.2       E..V.... 
    3.0       E..V.... 
    3.1       E..V.... 
    3.2       E..V.... 
    4.0       E..V.... 
    4.1       E..V.... 
    4.2       E..V.... 
    5.0       E..V.... 
    5.1       E..V.... 
    5.2       E..V.... 
    6.0       E..V.... 
    6.1       E..V.... 
    6.2       E..V.... 
    -quality   <int>  E..V.... Quality Preference (from 0 to 2) (default speed) 
    speed      E..V.... Prefer Speed 
    balanced      E..V.... Balanced 
    quality      E..V.... Prefer Quality 
    -rc    <int>  E..V.... Rate Control Method (from -1 to 3) (default -1) 
    cqp       E..V.... Constant Quantization Parameter 
    cbr       E..V.... Constant Bitrate 
    vbr_peak      E..V.... Peak Contrained Variable Bitrate 
    vbr_latency     E..V.... Latency Constrained Variable Bitrate 
    -enforce_hrd  <boolean> E..V.... Enforce HRD (default false) 
    -filler_data  <boolean> E..V.... Filler Data Enable (default false) 
    -vbaq    <boolean> E..V.... Enable VBAQ (default false) 
    -frame_skipping <boolean> E..V.... Rate Control Based Frame Skip (default false) 
    -qp_i    <int>  E..V.... Quantization Parameter for I-Frame (from -1 to 51) (default -1) 
    -qp_p    <int>  E..V.... Quantization Parameter for P-Frame (from -1 to 51) (default -1) 
    -qp_b    <int>  E..V.... Quantization Parameter for B-Frame (from -1 to 51) (default -1) 
    -preanalysis  <boolean> E..V.... Pre-Analysis Mode (default false) 
    -max_au_size  <int>  E..V.... Maximum Access Unit Size for rate control (in bits) (from 0 to INT_MAX) (default 0) 
    -header_spacing <int>  E..V.... Header Insertion Spacing (from -1 to 1000) (default -1) 
    -bf_delta_qp  <int>  E..V.... B-Picture Delta QP (from -10 to 10) (default 4) 
    -bf_ref   <boolean> E..V.... Enable Reference to B-Frames (default true) 
    -bf_ref_delta_qp <int>  E..V.... Reference B-Picture Delta QP (from -10 to 10) (default 4) 
    -intra_refresh_mb <int>  E..V.... Intra Refresh MBs Number Per Slot in Macroblocks (from 0 to INT_MAX) (default 0) 
    -coder    <int>  E..V.... Coding Type (from 0 to 2) (default auto) 
    auto       E..V.... Automatic 
    cavlc      E..V.... Context Adaptive Variable-Length Coding 
    cabac      E..V.... Context Adaptive Binary Arithmetic Coding 
    -me_half_pel  <boolean> E..V.... Enable ME Half Pixel (default true) 
    -me_quarter_pel <boolean> E..V.... Enable ME Quarter Pixel (default true) 
    -aud    <boolean> E..V.... Inserts AU Delimiter NAL unit (default false) 
    -log_to_dbg  <boolean> E..V.... Enable AMF logging to debug output (default false) 
hevc_amf AVOptions: 
    -usage    <int>  E..V.... Set the encoding usage (from 0 to 3) (default transcoding) 
    transcoding     E..V.... 
    ultralowlatency    E..V.... 
    lowlatency     E..V.... 
    webcam      E..V.... 
    -profile   <int>  E..V.... Set the profile (default main) (from 1 to 1) (default main) 
    main       E..V.... 
    -profile_tier  <int>  E..V.... Set the profile tier (default main) (from 0 to 1) (default main) 
    main       E..V.... 
    high       E..V.... 
    -level    <int>  E..V.... Set the encoding level (default auto) (from 0 to 186) (default auto) 
    auto       E..V.... 
    1.0       E..V.... 
    2.0       E..V.... 
    2.1       E..V.... 
    3.0       E..V.... 
    3.1       E..V.... 
    4.0       E..V.... 
    4.1       E..V.... 
    5.0       E..V.... 
    5.1       E..V.... 
    5.2       E..V.... 
    6.0       E..V.... 
    6.1       E..V.... 
    6.2       E..V.... 
    -quality   <int>  E..V.... Set the encoding quality (from 0 to 10) (default speed) 
    balanced      E..V.... 
    speed      E..V.... 
    quality      E..V.... 
    -rc    <int>  E..V.... Set the rate control mode (from -1 to 3) (default -1) 
    cqp       E..V.... Constant Quantization Parameter 
    cbr       E..V.... Constant Bitrate 
    vbr_peak      E..V.... Peak Contrained Variable Bitrate 
    vbr_latency     E..V.... Latency Constrained Variable Bitrate 
    -header_insertion_mode <int>  E..V.... Set header insertion mode (from 0 to 2) (default none) 
    none       E..V.... 
    gop       E..V.... 
    idr       E..V.... 
    -gops_per_idr  <int>  E..V.... GOPs per IDR 0-no IDR will be inserted (from 0 to INT_MAX) (default 60) 
    -preanalysis  <boolean> E..V.... Enable preanalysis (default false) 
    -vbaq    <boolean> E..V.... Enable VBAQ (default false) 
    -enforce_hrd  <boolean> E..V.... Enforce HRD (default false) 
    -filler_data  <boolean> E..V.... Filler Data Enable (default false) 
    -max_au_size  <int>  E..V.... Maximum Access Unit Size for rate control (in bits) (from 0 to INT_MAX) (default 0) 
    -min_qp_i   <int>  E..V.... min quantization parameter for I-frame (from -1 to 51) (default -1) 
    -max_qp_i   <int>  E..V.... max quantization parameter for I-frame (from -1 to 51) (default -1) 
    -min_qp_p   <int>  E..V.... min quantization parameter for P-frame (from -1 to 51) (default -1) 
    -max_qp_p   <int>  E..V.... max quantization parameter for P-frame (from -1 to 51) (default -1) 
    -qp_p    <int>  E..V.... quantization parameter for P-frame (from -1 to 51) (default -1) 
    -qp_i    <int>  E..V.... quantization parameter for I-frame (from -1 to 51) (default -1) 
    -skip_frame  <boolean> E..V.... Rate Control Based Frame Skip (default false) 
    -me_half_pel  <boolean> E..V.... Enable ME Half Pixel (default true) 
    -me_quarter_pel <boolean> E..V.... Enable ME Quarter Pixel (default true) 
    -aud    <boolean> E..V.... Inserts AU Delimiter NAL unit (default false) 
    -log_to_dbg  <boolean> E..V.... Enable AMF logging to debug output (default false) 

例如,ffmpeg -i input.mkv -c:v hevc_amf -rc cqp -qp_p 0 -qp_i 0 -c:a copy output.mkv將是無損的。請注意,雖然速度更快,但文件大小會比使用libx264或libx265時的文件大小大得多 - 而這正是硬件編碼器目前的狀況。您可能需要使用硬件編碼器來記錄速度,然後使用libx264或libx265等軟件編碼器來減小文件大小。