plainTransport to RTMP using FFmpeg

Hi there!

I’ve setup a plainTransport connection between ffmpeg and the producer(s) and have been able to successfully save the stream to a .webm file locally using FFmpeg:

 get _commandArgs() {
    let commandArgs = [
      "-loglevel",
      "debug",
      "-protocol_whitelist",
      "pipe,udp,rtp",
      "-fflags",
      "+genpts",
      "-f",
      "sdp",
      "-i",
      "pipe:0",
    ];

    commandArgs = commandArgs.concat(this._videoArgs);

    commandArgs = commandArgs.concat([
      "-flags",
      "+global_header",
      `${RECORD_FILE_LOCATION_PATH}/${this._rtpParameters.fileName}.webm`,
    ]);

    console.log("commandArgs:%o", commandArgs);

    return commandArgs;
  }

  get _videoArgs() {
    return ["-map", "0:v:0", "-c:v", "copy"];
  }

I’m now wanting to stream it to an RTMP endpoint directly.
I’ve fiddled around with the args where we add flags like tune zerolatency, force convert format to flv and then stream but am running into weird errors.

Any help would be greatly appreciate it.

Thanks a ton :smiley:

Have also referenced this and am running into a very similar error: ffmpeg stop to rtmp at Youtube live

Judging by WebM container you use VP8 codec. You can’t just send that over RTMP (-c:v copy), you need to transcode it to H264 first or configure router to use H264 from the beginning.

1 Like

Hey, thanks for the reply @nazar-pc!

Been at it the past few hours and have been able to setup a few things where I’m transcoding my VP8 to H264 and then converting into FLV to be sent to an RTMP endpoint.

However, I’m seeing a “missed RTP packets, need to consume data” error which, on a lot of research, looks like a CPU inefficiency error.
Would greatly appreciate any leads about this

The error is:

ffmpeg::process::data [data:'Clipping frame in rate conversion by 0.037331\n']
ffmpeg::process::data [data:'[libx264 @ 0x5582b3e52180] frame=   8 QP=20.00 NAL=2 Slice:P Poc:16  I:407  P:2649 SKIP:544  size=28803 bytes\n' +
  'Clipping frame in rate conversion by 0.087074\n' +
  '[libx264 @ 0x5582b3e52180] frame=   9 QP=20.00 NAL=2 Slice:P Poc:18  I:183  P:2123 SKIP:1294 size=21348 bytes\n']
ffmpeg::process::data [data:'[libx264 @ 0x5582b3e52180] frame=  10 QP=20.00 NAL=2 Slice:P Poc:20  I:229  P:2240 SKIP:1131 size=23795 bytes\n']
ffmpeg::process::data [data:'[libx264 @ 0x5582b3e52180] frame=  11 QP=20.00 NAL=2 Slice:P Poc:22  I:278  P:2471 SKIP:851  size=25230 bytes\n']
ffmpeg::process::data [data:'[sdp @ 0x5582b3df44c0] max delay reached. need to consume packet\n' +
  '[sdp @ 0x5582b3df44c0] RTP: missed 669 packets\n' +
  '[sdp @ 0x5582b3df44c0] Received no start marker; dropping frame\n']
ffmpeg::process::data [data:'[sdp @ 0x5582b3df44c0] max delay reached. need to consume packet\n' +
  '[sdp @ 0x5582b3df44c0] RTP: missed 9 packets\n']

Also, my updated commad args are:

   [
      "-loglevel",
      "debug",
      "-thread_queue_size",
      "10240",
      "-protocol_whitelist",
      "file,pipe,udp,rtp",
      "-fflags",
      "+genpts",
      "-f",
      "sdp",
      "-i",
      "pipe:0",
      "-preset",
      "ultrafast",
      "-vcodec",
      "libx264",
      // "-tune",
      // "zerolatency",
      "-y",
      "-bufsize",
      "1000",
      "-f",
      "flv",
      "my-rtmp-url",
    ];