Question

I'm trying to combine/merge two rtmp streams and then publish 'em to another stream

Ex.:

ffmpeg -i rtmp://ip:1935/live/micMyStream7 -i rtmp://ip:1935/live/MyStream7  -strict -2  -f flv rtmp://ip:1935/live/bcove7

The scenario is the following, I got a stream which comes from an user's microphone that is the first one (micMyStream7) and I also got a stream from another user but this one has audio and video(MyStream7).

As they are talking to each other when a user is speaking, the other one would only be listening to and vice versa.

My idea is to set up a third stream called (bcove) which would "merge" both of them so that I could have spectators who would only be listening to the entire conversation between them.

This is the log that ffmpeg printed although I couldn't recognize any message which helped me out.

paulo@paulo-desktop:~$ ffmpeg -re -i rtmp://ip:1935/live/micMyStream7 -i rtmp://ip:1935/live/MyStream7  -strict -2  -f flv rtmp://ip:1935/live/bcove7
ffmpeg version N-56029-g2ffead9 Copyright (c) 2000-2013 the FFmpeg developers
  built on Sep  4 2013 11:05:57 with gcc 4.7 (Ubuntu/Linaro 4.7.3-1ubuntu1)
  configuration: 
  libavutil      52. 43.100 / 52. 43.100
  libavcodec     55. 31.100 / 55. 31.100
  libavformat    55. 16.100 / 55. 16.100
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 83.102 /  3. 83.102
  libswscale      2.  5.100 /  2.  5.100
  libswresample   0. 17.103 /  0. 17.103
Input #0, flv, from 'rtmp://ip:1935/live/micMyStream7':
  Metadata:
    author          : 
    copyright       : 
    description     : 
    keywords        : 
    rating          : 
    title           : 
    presetname      : Medium Bandwidth (300 Kbps) - VP6
    creationdate    : Wed Sep  4 16:41:52 2013
                    : 
    videodevice     : Built-in iSight
    videokeyframe_frequency: 5
    audiodevice     : External microphone
    audiochannels   : 1
    audioinputvolume: 75
  Duration: N/A, start: 0.000000, bitrate: 253 kb/s
    Stream #0:0: Video: vp6f, yuv420p, 320x240, 204 kb/s, 44.83 tbr, 1k tbn, 1k tbc
    Stream #0:1: Audio: mp3, 22050 Hz, mono, s16p, 49 kb/s
Input #1, flv, from 'rtmp://ip:1935/live/MyStream7':
  Metadata:
    author          : 
    copyright       : 
    description     : 
    keywords        : 
    rating          : 
    title           : 
    presetname      : Custom
    creationdate    : Wed Sep  4 12:02:24 2013
                    : 
    videodevice     : FaceTime HD Camera (Built-in)
    videokeyframe_frequency: 5
    audiodevice     : Internal microphone
    audiochannels   : 1
    audioinputvolume: 75
  Duration: N/A, start: 0.000000, bitrate: 253 kb/s
    Stream #1:0: Video: vp6f, yuv420p, 320x240, 204 kb/s, 45.08 tbr, 1k tbn, 1k tbc
    Stream #1:1: Audio: mp3, 22050 Hz, mono, s16p, 49 kb/s
Output #0, flv, to 'rtmp://ip:1935/live/bcove7':
  Metadata:
    author          : 
    copyright       : 
    description     : 
    keywords        : 
    rating          : 
    title           : 
    presetname      : Medium Bandwidth (300 Kbps) - VP6
    creationdate    : Wed Sep  4 16:41:52 2013
                    : 
    videodevice     : Built-in iSight
    videokeyframe_frequency: 5
    audiodevice     : External microphone
    audiochannels   : 1
    audioinputvolume: 75
    encoder         : Lavf55.16.100
    Stream #0:0: Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p, 320x240, q=2-31, 200 kb/s, 1k tbn, 44.83 tbc
    Stream #0:1: Audio: adpcm_swf ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 88 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (vp6f -> flv)
  Stream #0:1 -> #0:1 (mp3 -> adpcm_swf)
Press [q] to stop, [?] for help
[mp3 @ 0x3625ec0] overread, skip -9 enddists: -3 -300:14.44 bitrate= 224.0kbits/s    
[mp3 @ 0x3625ec0] overread, skip -7 enddists: -3 -30:26.39 bitrate= 203.5kbits/s  

Thanks in advance

Was it helpful?

Solution

Copy video stream and mix two mono steams

Use amix or amerge audio filter.

For two RTMP inputs:

ffmpeg -i rtmp://ip:1935/live/micMyStream7 -i rtmp://ip:1935/live/MyStream7 -filter_complex "[0:a][1:a]amix[a]" -map 0:v -map "[a]" -c:v copy -f flv rtmp://ip:1935/live/bcove7

For RTMP input and an additional, looping audio file:

ffmpeg -i rtmp://ip:1935/live/micMyStream7 -re -stream_loop -1 -i input.mp3 -filter_complex "[0:a][1:a]amix[a]" -map 0:v -map "[a]" -c:v copy -c:a aac -f flv rtmp://ip:1935/live/bcove7
  • -c:v copy will stream copy the video instead of re-encoding it.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top