Search code examples
videoffmpegelectronweb-mediarecorder

How to fix muxer does not support non seekable output error on ffmpeg?


I am getting this error when I try to stream my video to YouTube rtmps server and I don't know what it means or how to fix it. Can anyone help?

I first record my screen with Electron's MediaRecorder

then I insert metadata of to the blob (othervise Electron exports without specifying the end of the file)

I convert the webm to mp4 by executing ffmpeg -i ${tempVideoPath} -c copy ${tempMp4VideoPath}

Then I execute ffmpeg -re -i ${tempVideoPath} -c copy -f mp4 ${youtubertmpslink}

Finally I get this error:

ffmpeg version 5.1.1-essentials_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\yussu\Desktop\Yazilim\electronJS\online-egitim-ogretmen\src\temp\stream-1663141332257.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf59.27.100
  Duration: 00:00:04.98, start: 0.000000, bitrate: 4251 kb/s
  Stream #0:0[0x1](eng): Video: vp9 (Profile 0) (vp09 / 0x39307076), yuv420p(tv), 1920x1080, 4179 kb/s, SAR 1:1 DAR 16:9, 23.07 fps, 16k tbr, 16k tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](eng): Audio: opus (Opus / 0x7375704F), 48000 Hz, stereo, fltp, 99 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
[mp4 @ 000001bd5ee76440] muxer does not support non seekable output
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 -- 
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
    Last message repeated 1 times

    at ChildProcess.exithandler (child_process.js:308)
    at ChildProcess.emit (events.js:210)
    at maybeClose (internal/child_process.js:1021)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283)```

Solution

  • How I Fixed


    • Thanks to @kesh I got rid of webm to mp4 conversion all together, I instead placed -f flv at the end of the command that I use to stream the video.

    mp4 format requires file seek to do its job. So, ffmpeg complains if you instruct it to write mp4 data to a write-only medium (e.g., pipe and internet stream). You need to pick a different file format or change the way your program works if MP4 is a requirement. @kesh

    • Changed my streaming command to -re -i {{video}} -vcodec libx264 -acodec aac -preset ultrafast -tune zerolatency -f flv ${ingestionLink} this. I have my audio and video codec and also flv conversion in one command.

    I really don't have much knowledge about ffmpeg and these commands and changes are just combinations of bits and pieces I found.

    As far as I understand I just stream the webm video but I change the video and audio codec and also video format in a single command like this.