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

**URL:** https://community.wowza.com/t/using-ffmpeg-with-an-rtmp-wowza-stream-on-an-app-instance-as-the-source/36969
**Category:** Wowza Streaming Engine
**Created:** [August 16, 2013, 12:25pm UTC](https://community.wowza.com/t/using-ffmpeg-with-an-rtmp-wowza-stream-on-an-app-instance-as-the-source/36969 "2013-08-16T12:25:36Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ben\_Davenport](https://avatars.discourse-cdn.com/v4/letter/b/8edcca/32.png) [@Ben\_Davenport](https://community.wowza.com/u/Ben_Davenport)
#### Post date: [August 16, 2013, 12:25pm UTC](https://community.wowza.com/t/using-ffmpeg-with-an-rtmp-wowza-stream-on-an-app-instance-as-the-source/36969/1 "2013-08-16T12:25:36Z")

</div>

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](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:

```auto
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:

```auto
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:

```auto
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!

---

<div class="post-metadata">

### Author: ![Roger\_Littin1](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@Roger\_Littin1](https://community.wowza.com/u/Roger_Littin1)
#### Post date: [August 18, 2013, 12:28am UTC](https://community.wowza.com/t/using-ffmpeg-with-an-rtmp-wowza-stream-on-an-app-instance-as-the-source/36969/2 "2013-08-18T00:28:49Z")

</div>

Hi,

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

```auto
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](https://www.wowza.com/docs/how-to-do-server-side-redirect-of-rtmp-connections-from-one-application-to-another)

[How to use the IMediaStreamNameAliasProvider2 interface](https://www.wowza.com/docs/how-to-use-the-imediastreamnamealiasprovider2-interface)

Roger

---

<div class="post-metadata">

### Author: ![Ben\_Davenport](https://avatars.discourse-cdn.com/v4/letter/b/8edcca/32.png) [@Ben\_Davenport](https://community.wowza.com/u/Ben_Davenport)
#### Post date: [August 21, 2013, 10:15am UTC](https://community.wowza.com/t/using-ffmpeg-with-an-rtmp-wowza-stream-on-an-app-instance-as-the-source/36969/3 "2013-08-21T10:15:14Z")

</div>

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!
