0

我正在使用 FFprobe 和 MP4Box 来检索视频流信息。我意识到返回的值存在显着差异。

以下命令用于 FFprobe:

$ ffprobe -v error -select_streams v:0 -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 1510579366733_9.ts
3.23334

但是,使用 MP4Box 检索同一文件的持续时间会返回不同的值。使用以下命令:

$ MP4Box -info 1510579366733_9.ts 2>&1 | grep Duration | awk '{print $2}'
2.826

我所有的 .ts 文件都有约 3 秒的视频片段,所以这应该只返回秒数(而不是分钟或小时);现在不关心这个。

这两个值中的哪一个更准确?

此外,我还意识到 usingMP4Box -info并不总是能检索 ts 文件的持续时间信息,而 FFprobe 迄今为止与我的所有 .ts 文件都工作得很好。

例子:

$ MP4Box -info 1510579366733_10.ts
Import probing results for 1510579366733_10.ts:
File has 2 tracks
    Track 257 type: Audio (MP4A) - Program 1
    Track 258 type: Video (H264) - Program 1


$ MP4Box -info 1510579366733_9.ts
Import probing results for 1510579366733_9.ts:
File has 2 tracks
Duration: 2.826 s
    Track 257 type: Audio (MP4A) - Program 1
    Track 258 type: Video (H264) - Program 1

仅供参考,ffprobe(完整)视频信息1510579366733_9.ts如下:

ffprobe version N-86980-g62b7553 Copyright (c) 2007-2017 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
  configuration: --prefix=/home/adminuser/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/adminuser/ffmpeg_build/include --extra-ldflags=-L/home/adminuser/ffmpeg_build/lib --bindir=/home/adminuser/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      55. 73.100 / 55. 73.100
  libavcodec     57.102.100 / 57.102.100
  libavformat    57. 76.100 / 57. 76.100
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 98.100 /  6. 98.100
  libswscale      4.  7.102 /  4.  7.102
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, mpegts, from '1510579366733_9.ts':
  Duration: 00:00:03.23, start: 0.000000, bitrate: 447 kb/s
  Program 1 
    Stream #0:0[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 137 kb/s
    Stream #0:1[0x102]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 426x240 [SAR 160:213 DAR 4:3], 30 fps, 30 tbr, 90k tbn, 60 tbc

1510579366733_10.ts

ffprobe version N-86980-g62b7553 Copyright (c) 2007-2017 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
  configuration: --prefix=/home/adminuser/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/adminuser/ffmpeg_build/include --extra-ldflags=-L/home/adminuser/ffmpeg_build/lib --bindir=/home/adminuser/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      55. 73.100 / 55. 73.100
  libavcodec     57.102.100 / 57.102.100
  libavformat    57. 76.100 / 57. 76.100
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 98.100 /  6. 98.100
  libswscale      4.  7.102 /  4.  7.102
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, mpegts, from '1510579366733_10.ts':
  Duration: 00:00:01.10, start: 0.000000, bitrate: 429 kb/s
  Program 1 
    Stream #0:0[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 131 kb/s
    Stream #0:1[0x102]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 426x240 [SAR 160:213 DAR 4:3], 30 fps, 30 tbr, 90k tbn, 60 tbc

针对Mulvya 的评论进行编辑:使用 ffprobestream=duration如下:-

$ ffprobe -v error -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 1510579366733_9.ts
3.178667
3.166667
3.178667
3.166667

$ ffprobe -v error -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 1510579366733_10.ts
1.066667
1.033333
1.066667
1.033333
4

0 回答 0