ffmpeg 视频编码从不以 -ss 和 -t 标志开头

ffmpeg 视频编码从不以 -ss 和 -t 标志开头

我正在尝试使用两个命令将视频分成两部分:

ffmpeg -i "a.mkv" -c:v libx264 -preset slow -crf 8 -c:a libfdk_aac -vbr 5 -ss 00:03:30 -t 00:01:30 "h.264/a1.mp4"
ffmpeg -i "a.mkv" -c:v libx264 -preset slow -crf 8 -c:a libfdk_aac -vbr 5 -ss 00:10:30 -t 00:01:30 "h.264/a2.mp4"

当我运行其中任何一个时,ffmpeg 都会启动但不会开始编码。输出始终为 fps=0。以下是输出:

ffmpeg version N-73755-g1c5b712 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      54. 28.100 / 54. 28.100
  libavcodec     56. 49.101 / 56. 49.101
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 23.100 /  5. 23.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Guessed Channel Layout for  Input Stream #0.1 : stereo
Input #0, matroska,webm, from 'a.mkv':
  Metadata:
    ISRC            : Video:x264vfw - H.264/MPEG-4 AVC codec Audio0:Speakers (Realtek High Definition Audio) Audio1:Microphone (Realtek High Definition Audio)
    ENCODER         : Lavf56.40.101
  Duration: 00:16:01.34, start: 0.000000, bitrate: 236851 kb/s
    Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 1k tbn, 120 tbc (default)
    Metadata:
      ENCODER         : Lavc56.49.101 libx264
    Stream #0:1: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s (default)
[libx264 @ 0x36ce0e0] using SAR=1/1
[libx264 @ 0x36ce0e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX LZCNT
[libx264 @ 0x36ce0e0] profile High, level 5.0
[libx264 @ 0x36ce0e0] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=8.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[libfdk_aac @ 0x36a6f00] Note, the VBR setting is unsupported and only works with some parameter combinations
Output #0, mp4, to 'h.264/a1.mp4':
  Metadata:
    ISRC            : Video:x264vfw - H.264/MPEG-4 AVC codec Audio0:Speakers (Realtek High Definition Audio) Audio1:Microphone (Realtek High Definition Audio)
    encoder         : Lavf56.40.101
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 60 fps, 15360 tbn, 60 tbc (default)
    Metadata:
      encoder         : Lavc56.49.101 libx264
    Stream #0:1: Audio: aac (libfdk_aac) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, s16 (default)
    Metadata:
      encoder         : Lavc56.49.101 libfdk_aac
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (pcm_s16le (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
frame=    0 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A

但是,如果我删除 -ss 和 -t 标志,视频编码就会开始。但我的目的是将视频分成两部分,因此这并不能解决问题。

答案1

您目前指定 的方式是将其-ss 00:03:30作为输出参数。这样做会导致 FFmpeg 从文件开头解码文件,然后转储帧直到达到。这比指定作为输入参数花费的时间-ss 00:03:30要长得多。-ss 00:03:30

相反,尝试这个命令:

ffmpeg -ss 00:03:30 -i "a.mkv" -c:v libx264 -preset slow -crf 8 -c:a libfdk_aac -t 00:01:30 "h.264/a1.mp4"

相关内容