转载出处 https://gxnotes.com/article/11115.html

安装ffmpeg

通过homebrew的方法安装最简单

brew install ffmpeg

查看文件

命令: ffmpeg -i fileName

➜  ffmpeg -i video1500533324880.mp4
ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video1500533324880.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2017-07-20T06:48:43.000000Z
    com.android.version: 6.0
  Duration: 00:00:02.46, start: 0.000000, bitrate: 2085 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480, 2151 kb/s, SAR 1:1 DAR 4:3, 30.05 fps, 30 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2017-07-20T06:48:43.000000Z
      handler_name    : VideoHandle
    Stream #0:1(eng): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s (default)
    Metadata:
      creation_time   : 2017-07-20T06:48:43.000000Z
      handler_name    : SoundHandle

删除所有音轨

ffmpeg -i input_file.mp4 -vcodec copy -an output_file.mp4

删除根据流号删除

识别流号码

$ ffmpeg -i in.mp4
   ...
   Stream #0:0: Video: ...
   Stream #0:1: Audio: ...
   Stream #0:2: Audio: ...

使用-map _file_:_stream_选择要处理和输出的流

$ ffmpeg -i in.mp4 -map 0:0 -map 0:2 -vcodec copy -acodec copy out.mp4

见:https://ffmpeg.org/ffmpeg.html#Advanced-options