如何使用ffprobe确定webm持续时间

Lop*_*hin 5 ffmpeg ffprobe

我的目标很简单,我有几个webm文件需要合并,但首先我需要确定它们的持续时间.

似乎webm文件作为流播放,因此无法分辨每个文件的长度.

我一直在使用ffprobe来完成这项工作,但返回的持续时间是N/A.我使用的命令是:

ffprobe -i input.file -show_format | grep duration
Run Code Online (Sandbox Code Playgroud)

谢谢.

ffprobe列表的完整输出如下:

 ffprobe version 2.6.2 Copyright (c) 2007-2015 the FFmpeg developers
  built with Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libtheora --enable-libvorbis --enable-libvpx --enable-vda
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, matroska,webm, from '231':
  Metadata:
    encoder         : GStreamer matroskamux version 1.5.91
    creation_time   : 2015-12-05 07:59:29
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0(eng): Video: vp8, yuv420p, 640x480, SAR 1:1 DAR 4:3, 14.99 fps, 14.99 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      title           : Video
    Stream #0:1(eng): Audio: vorbis, 48000 Hz, stereo, fltp (default)
    Metadata:
      title           : Audio
duration=N/A
Run Code Online (Sandbox Code Playgroud)

rnr*_*ies 10

我遇到了一些不包含持续时间和比特率的文件同样的问题,并找到了以下解决方案:

1-重新打包文件:(注意,这不会转码文件,只会复制它们)

ffmpeg -i source.webm -vcodec copy -acodec copy new_source.webm
Run Code Online (Sandbox Code Playgroud)

2-从新复制的文件中获取持续时间:

ffprobe new_source.webm | grep Duration
Run Code Online (Sandbox Code Playgroud)