I am using FFprobe and MP4Box for retrieving video streamlet information. I realised that there is a notable difference in the values returned.
The following command was used for FFprobe:
$ ffprobe -v error -select_streams v:0 -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 1510579366733_9.ts
3.23334
However, using MP4Box to retrieve the duration for the same file returns a different value. The following command is used:
$ MP4Box -info 1510579366733_9.ts 2>&1 | grep Duration | awk '{print $2}'
2.826
All my .ts files have are of ~3-second video segments so this should just return the number of seconds (instead of minutes or hours); not concerned about this right now.
Which of the two values is supposedly more accurate?
Additionally, I also realised using MP4Box -info
does not always retrieve the duration information of the ts file as well, whereas FFprobe has worked well with all my .ts files thus far.
Example:
$ 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
FYI the ffprobe (full) video information for 1510579366733_9.ts
is below:
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
and for 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
Edit in response to Mulvya's comment:
Using ffprobe with stream=duration
is as follows: -
$ 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