Wowza Community

Sync HLS stream using FFmpeg and MPEG-TS?

Hi,

I have two ip camera’s that i would like to stream to the wowza server of our hosting partner.

After that i would like to view those streams in a webplayer and chose which camera i want to see.

At the moment i use ffmpeg to push the streams seperately to the wowza server and a JWplayer to view them.

Everything works great so far but the two streams aren’t sync.

I’ve read al lot on forums about syncing and cuepoints and finally came across this thread:

https://www.wowza.com/docs/how-to-use-alternative-audio-or-video-tracks-with-apple-hls-streams

That seems to describe what i’m searching for! But i’m not sure where to begin? Obviously our service provider has to change some stuff on their side but what can i do on my side?

When i read this: “For live streams, Wowza Streaming Engine can ingest a single MPEG-TS stream that has multiple tracks” something tells me i need to make a mpeg-ts stream of my two cameras?

Questions:

Should i combine somehow my two camera streams into one mpeg-TS? Or does the wowza server do that?

And is Wowza version 3 also capable to do this? Or only version 4…?

Thanks!

Wim

In the article you referenced please note that several stream files are used to achieve the ability to switch from one of the Apple HLS input track to another. Each stream file can be thought of as a separate incoming live feed that contains one video track and one audio track. You can have multiple audio and video tracks in an MPEG-TS stream or you can keep each live feed separate. It is the .stream files, at least in this case, that each video stream will use for playback. This method works only with Wowza 4.x.

You should consider UDP packet loss if you use MPEG-TS as a live delivery mechanism from any encoder including FFmpeg. RTMP may work better if your MPEG-TS stream goes through the Internet or through a noisy network.

The line below can be used as a starting point for FFmpeg. This can help to reduce audio and video sync issues when delivering a live feed or creating VOD content. It is not guaranteed to work in your environment:

ffmpeg -i [input] -pix_fmt yuv420p -vsync 1 -vcodec libx264 -r 23.976 -threads 0 -b:v: 1024k -bufsize 1024k -maxrate 1024k -minrate 1024k -preset veryfast -profile:v baseline -tune film -g 48 -x264opts no-scenecut -acodec aac -b:a 192k -ac 2 -ar 44100 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -f mp4 output.mp4

That line will generate 24fps (technically 23.976fps) output and have a keyframe every two seconds (-g 48 -x264opts no-scenecut). Two second keyframes are recommended. Your output should be adjusted accordingly.

For Windows you would use this for authenticated RTMP output:

-f flv "rtmp://192.168.1.2:1935/live/myStream flashver=FMLE/3.0\20(compatible;\20FMSc/1.0) live=true pubUser=username pubPasswd=password"

For Linux you would use this for authenticated RTMP output:

-f flv rtmp://username:password@192.168.1.2:1935/live/myStream

Please note that we can provide only a limited amount of information on using FFmpeg as it is a free and open source tool.

I would suggest getting a trial version of Wowza Streaming Engine so that you can test your use case in your own environment and then pass on the configuration details to your hosting partner.

There can be several problems with your setup.

1) You updated the information in your router to point external connections to your internal computer, however the setting was not saved or was not applied.

2) You updated the information in your router to point external connections to your internal computer, however your ISP blocks streaming media ports.

3) You updated the information in your router to point external connections to your internal computer, but your router or the NAT itself does not allow a person on the internal network to use the external address.

You should either use nmap from outside of your network or use the free Shields UP service provided by Gibson Research from any computer inside of your network and specifically scan ports 443, 554, 1935, and 8088

More on network troubleshooting can be found here.

Thanks! For now i will use a wirecast encoder.

I’ve installed the trial version of Wowza Streaming Engine and forwarded port 1935 (tcp)

Then all i did was walk through this: https://www.wowza.com/docs/how-to-set-up-live-streaming-using-an-rtmp-based-encoder

Unfortunately i can’t seem to get it to work. In wirecast i stream to rtmp://MyExternalIPaddress:1935/live with a random streamname and the credentials set.

Is there maybe anything more i need to configure on the Wowza Streaming Engine besides the “How-to-set-up-live-streaming-using-an-RTMP-based-encoder”??