I have a IP Camera which sends 8000hz Sampling rate configured audio and H264 video. I made a program generating TS-file from this IP camera and it works fine on VLC, Android Media player except IPhone, Mac OSX Safari. (The program works with HLS Server that I made.)

Video playing in Iphone, Safari is fine, but Audio isn't. (I can hear sound, but it's not played smoothly)

I understand that Audio PTS in the TS packet should be MPEG2 Sytem PCR Clock based (90000hz). Timestamp value IP camera sends is based Sampling rate based(8000hz), so I multiply 90000/8000 to Timestamp to make PTS be MPEG2 PCR clock when I write audio's PTS in TS-file.

Is the wrong way multiplying 90000/8000 to Audio PTS? any help will be appreciated.

有帮助吗?

解决方案

You are most likely suffering from rounding errors. The PTS in TS MUST be perfect or many players will attempt to resynchronize playback with the reference clock , this will often appears as dropped samples, or inserted silence.

Make sure your starting PTS is accurate by counting samples and converting to to 90khz. Do your multiply before your divide e.g. (sampleCount * 90000) / sampleRate (NOT sampleCount * ( 90000 / sampleRate ), and make sure you are using a 64bit integer to avoid integer overflows. Or better yet, use av_rescale from libavutil.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top