Wowza Community

ffmpeg out to udp is not working

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

 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,

 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 to get the work done.

Any help is appriciated.

Thanks.

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:

/content/ffmpeg.stream

Make the contents of that file the udp stream:

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

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

Charlie

Hi,

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

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

 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

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

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

Hi,

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

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

Hi,

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

[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,

Hi,

Thanks for the reply.

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

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 ,

 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.

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