NOTE: If you are having audio/video sync problems with a Captiva HD input device, see this article here.
There are several things that can cause a problem with audio and video being out of sync when watching a live stream. Almost always, however, this is not something that can be corrected by changing encoder settings, but is caused by a problem either with the video source device or the interface the device uses to connect with the encoder on the encoding side, or is caused by a problem on the viewer side with either the bandwidth available to the viewing device or the device hardware or software.
While the encoding settings are not the most likely cause of the problem, one setting that can be adjusted in DVME is the iframe period. This setting tells the encoder how often (every how many frames) the encoder should create a reference frame (or keyframe). This setting will affect HLS (iOS) playback more than RTMP (Flash) playback. When streaming at 30 FPS, a good iframe period setting is 90 so that it creates an iframe every 3 seconds. It is not necessary for the iframe period to be divisible by the number of frames per second, but it is a good rule of thumb as it can be helpful when diagnosing problems like this. Keep in mind that when HLS streams are viewed, the iOS player may play audio but will not display the video until it receives an initial iframe. This means it could take as long as 3 seconds with the aforementioned setting for the video to appear in the player.
The way live streams work on iOS devices is to record bits of the live stream and save them as “chunks” and then the player connects to a playlist that plays those chunks in order. The iOS device then attempts to download the chunks fast enough to play the stream back continuously. If it cannot download them fast enough, the player will usually pause (buffer) long enough to save some chunks to continue playback. In that case, the delay between the actual live content and the playback on the viewing device will increase by how long it had to wait to download the next chunks. This can cause an ever increasing delay in playback, or it can cause the player to simply skip ahead to the most current chunks and skip over content that it could not download in time.
The first step to diagnosing an audio/video sync issue is to isolate when and where it is being seen. It is important to know whether the playback is out of sync only on iOS or other mobile devices viewing the stream using HLS, or if it is also apparent viewing the live stream on a computer in Flash player. If both are out of sync, then it could potentially be either the encoder, the input device itself (i.e. webcam or external camera) or the interface between the camera and the encoder (i.e. the drivers and/or cables connecting them) . In that case, try one of the following:
- Try another camera or input device and see if the sync issue is resolved.
- Ensure that the drivers for the camera or input device are the most current versions.
- Change out any audio, video, or digital cables connecting the input source to the camera. Also, if an external audio or video mixer is being used, ensure that the mixer is not introducing a delay in either the audio or video signal.
- Ensure that the correct audio source is selected in DVME. When using a webcam, for example, ensure that the webcam's microphone is the selected and not another internal audio source.
If the streaming playing in a Flash player on a computer is not out of sync, then it is definitely not the encoder, camera, or interface between them. In that case, it could simply be the iPad player itself or the wireless bandwidth available to the iPad. Bandwidth inconsistency can cause of audio/video sync issues on some players. This is because most players handle a bandwidth limitation by allowing the audio through and dropping the video. Sometimes when the video comes back, it may not be synced correctly. A less likely cause would be the media server that is creating the HLS chunks for viewing on iOS devices. This is less likely because it would then be a problem on all HLS streams served by the media server and not just the stream having the sync problem.
In the scenario where the audio is out of sync with the video, and the problem manifests itself only while viewing on an iOS device, it could be helpful to download and analyze an HLS chunk file to see whether the chunk itself is out of sync. If the chunks themselves are recorded out of sync, then it is not the iOS device, its bandwidth, or its player application, but is something between the input device and the media server.
In order to test whether the HLS chunks are recorded out of sync, please contact Discover Video technical support so that technical staff can download the chunks directly from the server and analyze them. This can only be done if a live stream has been streaming at some point previously that day, as old HLS chunks and playlists are typically deleted on a daily basis as a part of regular server maintenance.