Wowza Community

Using FFmpeg with an RTMP Wowza stream on an app instance as the source

Hey guys!!

Hope all is well, just wanted to see if I can get any details on how to use an RTMP source from Wowza with FFmpeg is the stream is running on an instance of a particular application?

Lemme try to clarify…

On this forum post: https://www.wowza.com/docs/how-to-use-ffmpeg-with-wowza-media-server-mpeg-ts it says that the format of the RTMP URL portion is:

rtmp://[wowza-ip-address]/[application]/[streamName]

Now if I use an input source like the following (not a stream running on an app instance) everything works just dandy:

ffmpeg -re -i rtmp://localhost/live/stream

If however, I try to use a stream running on an application instance I get an error, see below:

ffmpeg -re -i [B]rtmp://localhost/live/instance/stream[/B] -i [B]rtmp://localhost/liveeventorigin/instance/stream[/B] -map 0:0 -map 1:1 -codec copy -f flv rtmp://localhost/liveorigin/video
ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
  built on Jul 18 2012 12:05:01 with llvm_gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
  configuration: --enable-shared --enable-libmp3lame --enable-encoder=libmp3lame
  libavutil      51. 54.100 / 51. 54.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.100 / 54.  6.100
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
[rtmp @ 0x7fbad3414c60] Server error: Failed to play [B]instance/stream[/B]; stream not found.
[B]rtmp://localhost/live/instance/stream[/B]: Operation not permitted

Any ideas where I might be going wrong? Thanks!

Hi,

I tried with the following command line and it works for me.

ffmpeg -re -i rtmp://192.168.1.126/live/Stream1 -i rtmp://192.168.1.126/live/Stream2 -map 0:0 -map 1:1 -acodec copy -vcodec copy -f flv rtmp://192.168.1.126/live/Stream3

ffmpeg version 0.7.4

Stream3 is published with video from Stream1 and audio from Stream2

The error you are getting is stream not found, suggesting that ffmpeg cannot handle appInstances. It is treating instance/stream as the stream name.

You could remap the appInstance that ffmpeg is connecting to by using IVHostNotify.onVHostClientConnect in a custom VHostListener. This method is called before the rtmp client is connected to the application so it can be remapped to a different application or appInstance. The problem is that rtmp streaming is a 2 part process and at this point, you will not have the stream name part of the url so wont know which appInstance is actually being requested. Once the connection is made, you would also have to remap the stream name to the correct name using IMediaStreamNameAliasProvider2.resolvePlayAlias(IApplicationInstance appInstance, String name, IClient client) in a custom module.

How to do server-side redirect of RTMP connections from one application to another

How to use the IMediaStreamNameAliasProvider2 interface

Roger

Thank you so much for your clear and detailed response, dude. I totally forgot about IMediaStreamNameAliasProvider… I’ll take a look at the options you’ve provided, thanks a bunch!