FFmpeg - 用帧率计算?

FFmpeg - Calculating with Framerate?

我必须准确地剪辑我的视频。该视频可能有 25fps 或 30fps(我不知道)。 ffmpeg 中是否有一个帧速率变量,以便我可以计算我必须剪切的帧?我只有几秒钟的视频。 像这样(例如 80 秒视频):

vf "fade=in:0:12,fade=out:(80*r):12"

-vf "fade=in:0:12,fade=out:2500:12"

ffmpeg 随

安装
ffprobe

显示给定媒体文件的统计信息...这是一个示例

ffprobe "The Fourth Phase of Water - Dr. Gerald Pollack at TEDxGuelphU-i-T7tCMUDXU.mp4"

... here is output of above command

ffprobe version N-86279-gac8dfcbd89 Copyright (c) 2007-2017 the FFmpeg developers
  built with gcc 6.3.0 (Ubuntu 6.3.0-12ubuntu2) 20170406
  configuration: 
  libavutil      55. 63.100 / 55. 63.100
  libavcodec     57. 96.101 / 57. 96.101
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 90.100 /  6. 90.100
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'The Fourth Phase of Water - Dr. Gerald Pollack at TEDxGuelphU-i-T7tCMUDXU.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2016-08-25T12:06:13.000000Z
  Duration: 00:24:14.34, start: 0.000000, bitrate: 923 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720, 794 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
    Metadata:
      creation_time   : 2016-08-25T12:06:13.000000Z
      handler_name    : ISO Media file produced by Google Inc.
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T12:06:13.000000Z
      handler_name    : ISO Media file produced by Google Inc.

所以现在您有了总时间和 fps,因此您可以计算总帧数或只使用时间来剪切视频

除了开始帧和帧持续时间之外,您还可以指定淡入淡出的开始时间和持续时间。

-vf "fade=in:st=0.0:d=0.5,fade=out:st=75.5:d=0.5"