# ffmpeg out to udp is not working

**URL:** https://community.wowza.com/t/ffmpeg-out-to-udp-is-not-working/34985
**Category:** Wowza Streaming Engine
**Created:** [December 27, 2010, 4:51pm UTC](https://community.wowza.com/t/ffmpeg-out-to-udp-is-not-working/34985 "2010-12-27T16:51:22Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Chandra\_Shekar](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@Chandra\_Shekar](https://community.wowza.com/u/Chandra_Shekar)
#### Post date: [December 27, 2010, 4:51pm UTC](https://community.wowza.com/t/ffmpeg-out-to-udp-is-not-working/34985/1 "2010-12-27T16:51:22Z")

</div>

Hi,

Greetings.

I know , this is not the right forumn to ask this question, but my concern is , take input a stream, transocde it using ffmpeg, stream on localhost, then wowza will pickit up, using wowzadir/content/.stream file, then clients will connect to wowza to playusing rtmp/http.

My ffmpeg code is

```auto
 ffmpeg -i "http://streamurl" -vcodec libx264 -vpre default -vpre baseline -g 60 -vb 150000 -strict experimental -acodec aac -ab 96000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -f mpegts udp://localhost:41110?pkt_size=1316

```

Above is not righting to local host:41110, tried netstat to see no of ports open, and 41110 wasn’t there.

Replaced localhost with 127.0.0.1 and system ip but no luck.

Where,

```auto
 ffmpeg -i "http://streamurl" -vcodec libx264 -vpre default -vpre baseline -g 60 -vb 150000 -strict experimental -acodec aac -ab 96000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -f mpegts sample.mpg

```

worked fine, and the file sample.mpg saved locally.

I want ffmpeg to stream to localhost with perticular port number, then wowza pics this up, makes this http, clients will connect to wowza.

I have reffered this link [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) to get the work done.

Any help is appriciated.

Thanks.

---

<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 27, 2010, 9:30pm UTC](https://community.wowza.com/t/ffmpeg-out-to-udp-is-not-working/34985/2 "2010-12-27T21:30:59Z")

</div>

Are you starting the stream in StreamManager?

Try following the guide exactly to get one of the examples to work, use same port and source, etc. instead of improvising, then substitute your source.

To play the stream, create a .stream file named ffmpeg.stream in the content folder:

```auto
/content/ffmpeg.stream

```

Make the contents of that file the udp stream:

```auto
udp://127.0.0.1:10000?pkt_size=1316

```

Create an application named “live” with StreamType “live”, then use StreamManager to start the stream name “ffmpeg.stream” on the live application with MediaCaster type “rtp”. Then you can play in Wowza example player:

Server: rtmp://[wowza-addrss]:1935/live

Stream: ffmpeg.stream

When you have that working, substitute the input with your http url

Richard

---

<div class="post-metadata">

### Author: ![Charlie\_Good](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/charlie_good/32/383_2.png) [@Charlie\_Good](https://community.wowza.com/u/Charlie_Good)
#### Post date: [January 4, 2011, 5:02am UTC](https://community.wowza.com/t/ffmpeg-out-to-udp-is-not-working/34985/3 "2011-01-04T05:02:34Z")

</div>

For some reason Wowza is loosing the stream. That is why it is resetting.

Charlie

---

<div class="post-metadata">

### Author: ![Andrew\_Kennedy](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@Andrew\_Kennedy](https://community.wowza.com/u/Andrew_Kennedy)
#### Post date: [December 28, 2010, 1:58am UTC](https://community.wowza.com/t/ffmpeg-out-to-udp-is-not-working/34985/4 "2010-12-28T01:58:15Z")

</div>

> Hi,
> 
> Thank you for the reply. What i observed is , ffmpeg is not writing to
> 
> ```auto
> udp://127.0.0.1:10000?pkt_size=1316
> 
> ```
> 
> . Used netstat, tcpdump to check that ffmpeg is writing to that port, no luck, it wasn’t. It means, that port is not getting used at all, in this scenario, how can wowza pics from teh port which does not exist.
> 
> Thanks

drop the ?pkt\_size=1316

so it becomes

```auto
 ffmpeg -i "http://streamurl" -vcodec libx264 -vpre default -vpre baseline -g 60 -vb 150000 -strict experimental -acodec aac -ab 96000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -f mpegts udp://127.0.0.1:41110

```

if you are using localhost the packetsize is not needed. Also do check you do not have a firewall blocking UDP as I have tried this and it does work.

I think with netstat you will not see any connections as this is producing packets going to 127.0.0.1:41110 rather than binding to a port.

Shamrock

---

<div class="post-metadata">

### Author: ![Andrew\_Kennedy](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@Andrew\_Kennedy](https://community.wowza.com/u/Andrew_Kennedy)
#### Post date: [January 3, 2011, 1:26am UTC](https://community.wowza.com/t/ffmpeg-out-to-udp-is-not-working/34985/5 "2011-01-03T01:26:57Z")

</div>

Possibly three problems

the encoder does not have enough CPU . H264 is quite intensive

the ffmpeg instance is not configured to use the correct number of threads

the input stream is corrupt

Shamrock

---

<div class="post-metadata">

### Author: ![Andrew\_Kennedy](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@Andrew\_Kennedy](https://community.wowza.com/u/Andrew_Kennedy)
#### Post date: [January 5, 2011, 1:36am UTC](https://community.wowza.com/t/ffmpeg-out-to-udp-is-not-working/34985/6 "2011-01-05T01:36:59Z")

</div>

From what information you have provided the Video Players (mplayer, vlc) etc play the stream before it is transcoded ?

It appears from the logs from the Wowza server that the transcoder is not able to keep up, such Wowza is reporting incomplete packets.

When running the ffmpeg command try adding -threads 4 as this should then use more of the available cores.

You will need to play around with ffmpeg some more as it can use a significant amount of CPU if not tuned to the specific need.

Shamrock

---

<div class="post-metadata">

### Author: ![Chandra\_Shekar](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@Chandra\_Shekar](https://community.wowza.com/u/Chandra_Shekar)
#### Post date: [December 28, 2010, 11:16am UTC](https://community.wowza.com/t/ffmpeg-out-to-udp-is-not-working/34985/7 "2010-12-28T11:16:19Z")

</div>

Hi,

Thank you for the reply. What i observed is , ffmpeg is not writing to

```auto
udp://127.0.0.1:10000?pkt_size=1316

```

. Used netstat, tcpdump to check that ffmpeg is writing to that port, no luck, it wasn’t. It means, that port is not getting used at all, in this scenario, how can wowza pics from teh port which does not exist.

Thanks

---

<div class="post-metadata">

### Author: ![Chandra\_Shekar](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@Chandra\_Shekar](https://community.wowza.com/u/Chandra_Shekar)
#### Post date: [January 3, 2011, 12:05pm UTC](https://community.wowza.com/t/ffmpeg-out-to-udp-is-not-working/34985/8 "2011-01-03T12:05:16Z")

</div>

Hi,

Thanks for the reply. Above code works just fine. But i am having this issue,

```auto
[h264 @ 0x889e5e0]number of reference frames exceeds max (probably corrupt input), discarding one
[h264 @ 0x889e5e0]number of reference frames exceeds max (probably corrupt input), discarding one

```

, looks like above is encoder problem, or the source stream itself gone bad.

But, when encoded live, wowza tries to restart the stream now and then, so i can’t even play the stream on my rtmp player (rtmpdump).

Is this also problem with encoder?

Thanks,

---

<div class="post-metadata">

### Author: ![Chandra\_Shekar](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@Chandra\_Shekar](https://community.wowza.com/u/Chandra_Shekar)
#### Post date: [January 4, 2011, 11:37am UTC](https://community.wowza.com/t/ffmpeg-out-to-udp-is-not-working/34985/9 "2011-01-04T11:37:04Z")

</div>

Hi,

Thanks for the reply.

In addtion to the output above, i am getting wowza resetting now and then,

```auto
INFO server comment - RTPMediaCaster.Reconnector[1580650567:live/_definst_:live.stream]: start: 11
INFO server comment - RTPSessionDescriptionDataProviderBasic.getStreamInfo[live/_definst_]: URI: udp://127.0.0.1:41130
INFO stream create - -
INFO stream publish live.stream -
INFO server comment - RTPUDPTransport.bind[live/_definst_]: /127.0.0.1:41130
INFO server comment - RTPMediaCaster.Reconnector[1580650567:live/_definst_:live.stream]: done: 11
INFO server comment - UDPTransport.firstPacket: /127.0.0.1:41130
INFO server comment - RTPDePacketizerMPEGTS.handleRTPPacket: videoPID[H264]: 0x100
INFO server comment - RTPDePacketizerMPEGTS.handleRTPPacket: audioPID[AAC]: 0x101
WARN server comment - RTPDePacketizerMPEGTS.handleRTPPacket: Incomplete packet: 1504:1472
WARN server comment - RTPDePacketizerMPEGTS.handleRTPPacket: Incomplete packet: 1504:1472
INFO server comment - RTPDePacketizerMPEGTS.handleRTPPacket: MPEG-TS over RTP
WARN server comment - RTPDePacketizerMPEGTS.handleRTPPacket: Incomplete packet: 1504:1472
WARN server comment - RTPDePacketizerMPEGTS.handleRTPPacket: Incomplete packet: 1504:1472
INFO server comment - RTPMediaCaster.streamTimeout[1580650567:live/_definst_:live.stream]: timeout:12000 diff:12048 reason:101
INFO server comment - RTPMediaCaster.resetConnection[1580650567:live/_definst_:live.stream]: 
INFO server comment - RTPMediaCaster.closeRTPSession[1580650567:live/_definst_:live.stream]
INFO server comment - RTPUDPTransport.unbind[live/_definst_]: /127.0.0.1:41130
INFO stream unpublish live.stream -
INFO stream destroy live.stream -

```

Now the input stream is proper (not corrupted, playing smooth on vlc/mplayer).

My system is

Dell server with Intel® Xeon® CPU E5506 @ 2.13GHz, 898.3 GB HD, 16GB Ram, 4 cores with 2128.051 mhz.

Command used to encode is ,

```auto
 time ffmpeg -i "http://STREAMURL" -vcodec libx264 -vpre default -vpre baseline -g 60 -vb 150000 -strict experimental -acodec aac -ab 96000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -f mpegts udp://127.0.0.1:41130

```

Please suggest , where all i can tune this.

Thanks.

---

<div class="post-metadata">

### Author: ![Chandra\_Shekar](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@Chandra\_Shekar](https://community.wowza.com/u/Chandra_Shekar)
#### Post date: [January 5, 2011, 11:04am UTC](https://community.wowza.com/t/ffmpeg-out-to-udp-is-not-working/34985/10 "2011-01-05T11:04:47Z")

</div>

Thanks for the reply.

What could be the reason wowza is loosing the stream? Video players (mplayer, vlc) plays the stream without jerks, how can wowza loose the stream?

I can provide more logs if required.

Thanks
