天天看點

用ffmpeg在指令行下,對檔案進行轉碼H264

上司安排了一批視訊,準備進行切圖。結果程式識别不了。

怎麼辦?轉碼。

用什麼轉?上司說用ffmpeg。

怎麼轉?不好意思,吾亦不知。

奈何?網上搜尋之。

  • 先安裝ffmpeg

  吾是有奔頭系統:

sudo apt-get install ffmpeg      
  • 用指令行進行轉碼

  其實這個first.data是什麼格式,吾亦不知。讓ffmpeg自己識别好了。

ffmpeg -i first.data -vcodec h264 -preset fast -b:v 2000k hello.h264      

 preset參數,畫質從差到好(編解碼工作量從低到高),分别是:ultrafast、superfast、veryfast、faster、fast、medium、slow、slower、veryslow、placebo(有的版本是不能用的,自己查支援哪些參數)

  • 有哪些codec
ffmpeg -decoders | grep h264
 
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
  configuration: --disable-asm --disable-x86asm --enable-cuda --enable-cuvid --enable-nvenc --enable-nonfree --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-cflags=-fPIC --extra-ldflags=-L/usr/local/cuda/lib64
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
 VFS..D h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
 V..... h264_v4l2m2m         V4L2 mem2mem H.264 decoder wrapper (codec h264)
 V..... h264_cuvid           Nvidia CUVID H264 decoder (codec h264)      

從圖中可以看到,codec h264 

繼續閱讀