1- Which one is better to use for streaming video ? TCP or UDP socket and why?
2- While streaming live, audio and video are coming from the server separately, so how can i make sure that the video i display and the audio I play on the device are in sync?
Audio sync issues that you can run into while streaming can happen when your internet connection has issues. Bugs in the streaming app can also cause audio desync issues, but those are rarer. Getting your internet connection checked out can help with desync issues on streaming services.
If you are experiencing audio lag, you can adjust the audio delay in the app settings. In the app, go to Settings > Output > Audio Delay, and you can adjust the audio delay between 300ms = 0.3 sec. You may need to experiment and test your adjustments to precisely sync the audio and video.
I wrote a voice chat application a while ago and TCP was out of the question, UDP multicasting is really the only way to go if you're looking for near-realtime data flow. There's two main issues with streaming stuff over UDP though:
I would do UDP. However it depends on what you want. UDP will drop packets rather than wait (TCP). The trade off is whether you want a stable, but sometimes slow and costly, or one that is efficient, but sometimes may not get delivered. The choice is yours when it comes to how you want to implement it and how you are using it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With