1

I'd like to set up FFmpeg to receive an RTMP stream. Eventually I will be transcoding the Audio and Video, using the mpegts format type, and making the output a UDP multicast.

But for now, this is what I've been working from:

.\ffmpeg.exe -listen 1 -i rtmp://0.0.0.0:9090/stream -c copy -f flv C:\temp\output.flv

This almost works. It creates the file and it has an audio track, but no video track.

Output from ffmpeg shows that the video comes a couple thousand bytes after the audio and video, so it seems that ffmpeg ignores it:

[rtmp @ 000002ad65cca540] Erroneous C2 Message epoch does not match up with C1 epoch
[rtmp @ 000002ad65cca540] Erroneous C2 Message random does not match up
[rtmp @ 000002ad65cca540] App field don't match up:  <-> muskiefootball
Input #0, flv, from 'rtmp://0.0.0.0:9095/test':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Wildlife Sample Video - https://archive.org/details/WildlifeSampleVideo
    encoder         : Lavf58.29.100
  Duration: 00:00:00.00, start: 5.677000, bitrate: N/A
    Stream #0:0: Data: none
    Stream #0:1: Subtitle: text
    Stream #0:2: Audio: aac (LC), 44100 Hz, stereo, fltp, 130 kb/s
File 'C:\temp\testingoutput5.flv' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:2 -> #0:0 (aac (native) -> mp2 (native))
Press [q] to stop, [?] for help
Output #0, mpegts, to 'C:\temp\testingoutput5.flv':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Wildlife Sample Video - https://archive.org/details/WildlifeSampleVideo
    encoder         : Lavf58.29.100
    Stream #0:0: Audio: mp2, 44100 Hz, stereo, s16, 192 kb/s
    Metadata:
      encoder         : Lavc58.54.100 mp2
[flv @ 000002ad65cc9400] New video stream 0:3 at pos:26340 and DTS:7.163s
size=    1411kB time=00:00:54.29 bitrate= 212.9kbits/s speed=1.05x

So the video isn't included in the output.

What options do I have to allow ffmpeg to include the video in the output when it comes in after the start of the stream? The only limitation is that I have to listen for an RTMP connection, and since it comes from an outside service I can't modify anything about how they send the data.

2
  • ... -analyzeduration 20M -probesize 20M -i rtmp://0.0.0.0:9090/stream ...
    – Gyan
    Commented Sep 3, 2019 at 15:45
  • Unfortunately those options don't appear to do anything when I am listening for a remote stream to be pushed to me. They only appear to work when I'm pulling or reading from a file. Commented Sep 3, 2019 at 18:17

1 Answer 1

0

I was unable to find a way to get ffmpeg to do this natively. Instead I used nginx as a proxy in front of ffmpeg.

First, I built nginx with the nginx-rtmp-module:

https://github.com/arut/nginx-rtmp-module/wiki/Getting-started-with-nginx-rtmp

Then I used to following nginx config to listen for RTMP streams, buffer and interleave the child streams, and then push that to ffmpeg. The following config worked for me but is not refined:

rtmp {
    server {
        listen 9095;
        ping 30s;
        notify_method get;
        buflen 5s;

        application live {
            live on;
            interleave on;
            exec_push ffmpeg -i rtmp://127.0.0.1:9095/live/mykey -c copy -f flv /tmp/test.flv
        }
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .