Fixing the length (duration) of a webm file takes too much time by ffmpeg

I have some webm files which lack duration/length.

For example when I open one of them (which is about 20 minutes) by vlc media player I see something like this:

enter image description here

This is very annoying because I cannot forward (skip few minutes and advance) through the video.

I was able to fix this problem by ffmpeg using the following command:

ffmpeg -i original_video.webm -c:a copy new_video.webm

But the problem is that this command takes too much time, I am looking for a fast solution using ffmpeg to fix the duration of my webm videos.

If I simply use

ffmpeg -i original_video.webm -c copy new_video.webm

I get the error:

ffmpeg version git-2020-08-31-4a11a6f Copyright (c) 2000-2020 the FFmpeg developers built with gcc 10.2.1 (GCC) 20200805 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --enable-librav1e --enable-libsvtav1 --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf libavutil 56. 58.100 / 56. 58.100 libavcodec 58.101.101 / 58.101.101 libavformat 58. 51.101 / 58. 51.101 libavdevice 58. 11.101 / 58. 11.101 libavfilter 7. 87.100 / 7. 87.100 libswscale 5. 8.100 / 5. 8.100 libswresample 3. 8.100 / 3. 8.100 libpostproc 55. 8.100 / 55. 8.100
Input #0, matroska,webm, from 'original_video.webm': Metadata: encoder : Chrome Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0(eng): Video: h264 (Constrained Baseline), yuv420p(progressive), 1280x858, SAR 1:1 DAR 640:429, 59.94 tbr, 1k tbn, 2k tbc (default) Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
[webm @ 000001c24f3a5c40] Only VP8 or VP9 or AV1 video and Vorbis or Opus
audio and WebVTT subtitles are supported for WebM.
Could not write header for output file #0 (incorrect codec parameters ?):
Invalid argument
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Last message repeated 1 times
3

1 Answer

WebM only supports VP9/VP8 video. Your input contains H.264 video and is not a compliant WebM file.

Either:

  • Re-encode the video to VP9:

     ffmpeg -i input.webm -c:a copy output.webm
  • Or output to Matroska or MP4 instead of WebM:

     ffmpeg -i input.webm -c copy output.mkv ffmpeg -i input.webm -c copy output.mp4
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like