# Pulling an http stream to push via rtmp

**URL:** https://community.wowza.com/t/pulling-an-http-stream-to-push-via-rtmp/37288
**Category:** Wowza Developer Dojo
**Tags:** wowza-streaming-server-java-api
**Created:** [September 16, 2011, 10:18am UTC](https://community.wowza.com/t/pulling-an-http-stream-to-push-via-rtmp/37288 "2011-09-16T10:18:32Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Larry\_Blair](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@Larry\_Blair](https://community.wowza.com/u/Larry_Blair)
#### Post date: [September 16, 2011, 10:18am UTC](https://community.wowza.com/t/pulling-an-http-stream-to-push-via-rtmp/37288/1 "2011-09-16T10:18:32Z")

</div>

We’re trying to pull http streams from Limelight, repackage them as rtmp, and push them back to Limelight using the Push-Publish module. The code example I have has me creating an onPublish() method that pushes the stream. I’m assuming this means the http streams would have to pushed to the Wowza server in order to trigger the onPublish(). What I need to do is to pull the streams. How do I accomplish this?

---

<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: [September 16, 2011, 7:07pm UTC](https://community.wowza.com/t/pulling-an-http-stream-to-push-via-rtmp/37288/2 "2011-09-16T19:07:57Z")

</div>

Wowza does not support http ingress but you can use VLC in between:

[https://www.wowza.com/docs/how-to-use-vlc-as-a-live-stream-encoder-with-wowza-media-server-mpeg-ts](https://www.wowza.com/docs/how-to-use-vlc-as-a-live-stream-encoder-with-wowza-media-server-mpeg-ts)).

Look at the Transcode examples at the bottom. You can swap the RTSP input with the HTTP URL.

```auto
vlc -vvv [url]http://domain.com/streamname[/url] --sout "#transcode{venc=x264{keyint=60,profile=baseline,level=3.0,nocabac},vcodec=x264,vb=150,scale=0.5,acodec=mp4a,ab=96,channels=2,samplerate=48000}:rtp{dst=127.0.0.1,port=10000,mux=ts}"

```

Richard

---

<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: [September 16, 2011, 7:34pm UTC](https://community.wowza.com/t/pulling-an-http-stream-to-push-via-rtmp/37288/3 "2011-09-16T19:34:51Z")

</div>

Wowza can re-stream shoutcast/icecast from http, is an exception.

Richard

---

<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: [September 16, 2011, 8:29pm UTC](https://community.wowza.com/t/pulling-an-http-stream-to-push-via-rtmp/37288/4 "2011-09-16T20:29:22Z")

</div>

Follow this tutorial:

[https://www.wowza.com/docs/how-to-re-stream-audio-from-shoutcast-icecast](https://www.wowza.com/docs/how-to-re-stream-audio-from-shoutcast-icecast)

Richard

---

<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: [September 16, 2011, 9:08pm UTC](https://community.wowza.com/t/pulling-an-http-stream-to-push-via-rtmp/37288/5 "2011-09-16T21:08:25Z")

</div>

You should start the stream in StreamManager or /conf/StartUpStreams.xml with MediaCaster type “shoutcast” to kick off the push publisher.

Wowza MediaCaster system has built-in monitor that will keep trying to reconnect. There is this optional Advanced Monitor:

[https://www.wowza.com/docs/how-to-enable-advanced-monitoring-and-resetting-of-mediacaster-streams](https://www.wowza.com/docs/how-to-enable-advanced-monitoring-and-resetting-of-mediacaster-streams)

With push publish, when re-connect succeeds, that should push another stream. JW Player has live stream reconnector for this kind of case.

Richard

---

<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: [September 20, 2011, 6:51pm UTC](https://community.wowza.com/t/pulling-an-http-stream-to-push-via-rtmp/37288/6 "2011-09-20T18:51:13Z")

</div>

Do this:

```auto
PushPublisher.setRemoveDefaultAppInstance(true);

```

Richard

---

<div class="post-metadata">

### Author: ![Larry\_Blair](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@Larry\_Blair](https://community.wowza.com/u/Larry_Blair)
#### Post date: [September 16, 2011, 11:30am UTC](https://community.wowza.com/t/pulling-an-http-stream-to-push-via-rtmp/37288/7 "2011-09-16T11:30:09Z")

</div>

I’m confused. I was able to get Wowza to pull an http stream (the stream is a never-ending mp3) and return it as an rtmp stream, so Wowza can clearly pull a stream. What I need is to have Wowza push the result to Limelight, since Limelight can’t pull it. I figure the must be a way to tell Wowza to pull a stream and, using Push-Publish, push it to Limelight.

---

<div class="post-metadata">

### Author: ![Larry\_Blair](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@Larry\_Blair](https://community.wowza.com/u/Larry_Blair)
#### Post date: [September 16, 2011, 12:27pm UTC](https://community.wowza.com/t/pulling-an-http-stream-to-push-via-rtmp/37288/8 "2011-09-16T12:27:23Z")

</div>

I’m sorry. The streams we’re talking about are icecast. How do I get Wowza to pull the stream and push it as rtmp?

---

<div class="post-metadata">

### Author: ![Larry\_Blair](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@Larry\_Blair](https://community.wowza.com/u/Larry_Blair)
#### Post date: [September 16, 2011, 1:02pm UTC](https://community.wowza.com/t/pulling-an-http-stream-to-push-via-rtmp/37288/9 "2011-09-16T13:02:19Z")

</div>

> Follow this tutorial:
> 
> [Re-stream audio from SHOUTcast/Icecast](https://www.wowza.com/docs/how-to-re-stream-audio-from-shoutcast-icecast)
> 
> Richard

I think I get it. I need to create a file in the content directory, containing the url of the icecast stream, for each of the streams. When the system comes up, my onPublish() method will get called for each stream.

If one of the icecast stream goes down, how does it recover when it comes back up?

The documentation for the Push-Publish left out a step. How does the system get my module class? My guess has been that I package it in a jar and stick it in the lib directory.

I’m attaching the source for my onPublish() method. Does it look right?

public void onPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend)

{

try

{

IApplicationInstance appInstance = stream.getStreams().getAppInstance();

synchronized(publishers)

{

PushPublisherRTMP publisher = new PushPublisherRTMP();

// Source stream

publisher.setAppInstance(appInstance);

publisher.setSrcStreamName(streamName);

// Destination stream

publisher.setHostname(streamName + “.pri.XXX.fmspush.llnw.net”);

publisher.setPort(1935);

publisher.setDstApplicationName(“XXX”);

publisher.setDstStreamName(streamName);

publisher.setSendFCPublish(true);

publisher.setSendReleaseStream(true);

PushPublishRTMPAuthProviderLimelight limelightRTMPAuthProvider = new PushPublishRTMPAuthProviderLimelight();

limelightRTMPAuthProvider.init(publisher);

limelightRTMPAuthProvider.setUserName(“XXX”);

limelightRTMPAuthProvider.setPassword(“XXX”);

publisher.setRTMPAuthProvider(limelightRTMPAuthProvider);

publisher.connect();

}

}

catch(Exception e)

{

WMSLoggerFactory.getLogger(null).error("ModulePushPublishSimpleExample#StreamNotify.onPublish: "+e.toString());

}

}

---

<div class="post-metadata">

### Author: ![Larry\_Blair](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@Larry\_Blair](https://community.wowza.com/u/Larry_Blair)
#### Post date: [September 20, 2011, 10:45am UTC](https://community.wowza.com/t/pulling-an-http-stream-to-push-via-rtmp/37288/10 "2011-09-20T10:45:54Z")

</div>

I’ve been able to get this most working. I’m down to one problem. I can’t figure out how to get it not to insert _definst_ in the push URL. Here is the output from the server.

INFO stream publish [http://xxx.ic.llnwd.net/stream/xxx\_stream\_1](http://xxx.ic.llnwd.net/stream/xxx_stream_1) -

INFO server comment - ShoutCastReceiver.init: shoutcastMP3GroupCount:4

INFO server comment - VHost.startStartupStreams: Stream successfully started [live/_definst_]: flv:[http://xxx.ic.llnwd.net/stream/xxx\_stream\_1](http://xxx.ic.llnwd.net/stream/xxx_stream_1)

INFO server comment - Wowza Media Server is started!

INFO server comment - PushPublisher.sessionOpened[rtmp://fmspush.sjc.llnw.net:1935/xxx/_definst_/xxx\_stream\_1]:

INFO server comment - PushPublisher.resetConnection[rtmp://fmspush.sjc.llnw.net:1935/xxx/_definst_/xxx\_stream\_1]: com.wowza.wms.plugin.pushpublish.protocol.rtmp.PushPublisherRTMPSession@3a835d

INFO server comment - PushPublisher.sessionClosed[rtmp://fmspush.sjc.llnw.net:1935/xxx/_definst_/xxx\_stream\_1]

INFO server comment - PushPublisher.sessionOpened[rtmp://fmspush.sjc.llnw.net:1935/xxx/_definst_/xxx\_stream\_1]:

INFO server comment - ShoutCastReceiver.internalConnect: [http://xxx.ic.llnwd.net:80/stream/xxx\_stream\_1](http://xxx.ic.llnwd.net:80/stream/xxx_stream_1)

INFO server comment - ShoutCastDecoder.checkHeader[[http://xxx.ic.llnwd.net/stream/xxx\_stream\_1]:](http://xxx.ic.llnwd.net/stream/xxx_stream_1%5D:) HTTP OK

---

<div class="post-metadata">

### Author: ![Larry\_Blair](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@Larry\_Blair](https://community.wowza.com/u/Larry_Blair)
#### Post date: [September 20, 2011, 11:02am UTC](https://community.wowza.com/t/pulling-an-http-stream-to-push-via-rtmp/37288/11 "2011-09-20T11:02:12Z")

</div>

> Do this:
> 
> ```auto
> PushPublisher.setRemoveDefaultAppInstance(true);
> 
> ```
> 
> Richard

No change. Here’s my code:

public void onPublish(IMediaStream stream, String fullStreamName, boolean isRecord, boolean isAppend)

{

try

{

IApplicationInstance appInstance = stream.getStreams().getAppInstance();

synchronized(publishers)

{

int pos = fullStreamName.lastIndexOf(“/”);

String streamName = fullStreamName.substring(pos + 1);

PushPublisherRTMP publisher = new PushPublisherRTMP();

// Source stream

publisher.setAppInstance(appInstance);

publisher.setSrcStreamName(streamName);

// Destination stream

publisher.setHostname(“[fmspush.sjc.llnw.net](http://fmspush.sjc.llnw.net)”);

publisher.setPort(1935);

publisher.setDstApplicationName(“xxx”);

publisher.setDstStreamName(streamName);

publisher.setRemoveDefaultAppInstance(true);

publisher.setSendFCPublish(true);

publisher.setSendReleaseStream(true);

PushPublishRTMPAuthProviderLimelight limelightRTMPAuthProvider = new PushPublishRTMPAuthProviderLimelight();

limelightRTMPAuthProvider.init(publisher);

limelightRTMPAuthProvider.setUserName(“xxx”);

limelightRTMPAuthProvider.setPassword(“xxx”);

publisher.setRTMPAuthProvider(limelightRTMPAuthProvider);

publisher.connect();

}

}

catch(Exception e)

{

WMSLoggerFactory.getLogger(null).error("ModulePushPublishSimpleExample#StreamNotify.onPublish: "+e.toString());

}

}
