0

I am trying to retrieve the duration of a .webm video file that I recorded using the the video.js plugin (https://github.com/collab-project/videojs-record).

I am using ffmpeg to get the duration but it always return N/A:

ffprobe version 3.0.2-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2007-2016 the FFmpeg developers
  built with gcc 5.3.1 (Debian 5.3.1-16) 20160424
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --enable-libass --enable-gnutls --enable-libvidstab --enable-libsoxr --enable-frei0r --enable-libfribidi --disable-indev=sndio --disable-outdev=sndio --enable-librtmp --enable-libmfx --enable-libzimg --cc=gcc
  libavutil      55. 17.103 / 55. 17.103
  libavcodec     57. 24.102 / 57. 24.102
  libavformat    57. 25.100 / 57. 25.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 31.100 /  6. 31.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, matroska,webm, from '/home/demoss/public_html/source/bALRt9I697PVQh4zglou.webm':
  Metadata:
    encoder         : Chrome
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0(eng): Video: vp8, yuv420p, 640x480, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1(eng): Audio: opus, 48000 Hz, mono, fltp (default)
duration=N/A

I don't think the video is corrupted as it played in my VideoJS player without issues.

Any pointers as to why its not returning the duration would be greatly appreciated. I wouldn't mind using an alternative library as well

Thanks

maximus 69
  • 1,388
  • 4
  • 22
  • 35

2 Answers2

5

If ffprobe/ffmpeg does not show the format or stream durations then you can fully decode the file to find the duration:

ffmpeg -i input.webm -f null -
...
frame= 2087 fps=0.0 q=-0.0 Lsize=N/A time=00:01:23.48 bitrate=N/A speed= 123x

Refer to time= in the second-to-last line in the output. In this example the file duration is 00:01:23.48.

Depending on the duration and complexity of your input this may take some time.

Also see FFmpeg Wiki: FFprobe Tips - Duration.

llogan
  • 121,796
  • 28
  • 232
  • 243
0

I was able to convert the webm to mp4 using the following command:

ffmpeg -fflags +genpts -i myfile.webm -r 24 mynew.mp4

I am not quite sure of how it works internally, but I hope the experts could expand on this.

Hope this helps someone

maximus 69
  • 1,388
  • 4
  • 22
  • 35