# how to control ffmpeg from modules?

**URL:** <https://community.wowza.com/t/how-to-control-ffmpeg-from-modules/41684>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [December 9, 2013, 11:17am UTC](https://community.wowza.com/t/how-to-control-ffmpeg-from-modules/41684 "2013-12-09T11:17:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Taras\_K](https://avatars.discourse-cdn.com/v4/letter/t/bb73d2/32.png) [@Taras\_K](https://community.wowza.com/u/Taras_K)\
**Post date:** [December 9, 2013, 11:17am UTC](https://community.wowza.com/t/how-to-control-ffmpeg-from-modules/41684/1 "2013-12-09T11:17:23Z")

</div>

Hi all:

I am writing an application which requires mux. Picture-in-picture style stuff. For now, I ingest some streams to the wowza server, and then manually execute a comand-line ffmpeg program to do the muxing, outputting another stream. This works, with acceptable latency and quality.

The question is, what is the best way to control ffmpeg from a module? Is anyone doing this at present?

One solution is just to make system commands from the Java module, but ffmpeg’s solution to any problems, like dropped streams, seems to be to simply crash. Is there some obvious way to get Java and ffmpeg to talk to each other and do appropriate things when streams go offline or change?

There’s some discussion of the Java Xuggler library, but this seems to have been dropped a couple years ago…

Thanks!

Taras.

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [December 9, 2013, 4:36pm UTC](https://community.wowza.com/t/how-to-control-ffmpeg-from-modules/41684/2 "2013-12-09T16:36:34Z")

</div>

Taras,

You can start and stop external processes in Java, but it sounds like you really want notifications. If you are pushing a rtmp stream from FFMpeg you can use [IMediaStreamActionNotify3](https://www.wowza.com/docs/how-to-use-imediastreamactionnotify3-interface-to-listen-for-rtmp-stream-events-includes-codec-info%28includes-codec-info%29). If you are pulling mpeg-ts (as shown in [these examples](https://www.wowza.com/docs/how-to-use-ffmpeg-with-wowza-media-server-mpeg-ts%28MPEG-TS%29)) then you use a combination of the IMediaStreamActionNotify (which will fire onPublish and onUnpublish for MediaCaster streams) and the [IMediaCasterNotify2](https://www.wowza.com/docs/imediacasternotify2-example)

If you are pulling from FFmpeg, which we recommend, you can also use the [ModuleMediaCasterStreamMonitorAdvanced](https://www.wowza.com/docs/how-to-enable-advanced-monitoring-and-resetting-of-mediacaster-streams) to monitor and reset streams automatically.

Richard

---

<div class="post-metadata">

**Author:** ![Taras\_K](https://avatars.discourse-cdn.com/v4/letter/t/bb73d2/32.png) [@Taras\_K](https://community.wowza.com/u/Taras_K)\
**Post date:** [December 31, 2013, 1:50pm UTC](https://community.wowza.com/t/how-to-control-ffmpeg-from-modules/41684/3 "2013-12-31T13:50:05Z")

</div>

It’s working great, thank you.
