In the developing process of broadcasting system I have encountered with the problem, which, probably, is faced by all developers of such systems – it is audio and video synchronization.
I have built my system in such way, that one working program thread was transcoding video, and other thread - was transcoding audio. Then the results were multiplexing. As a result, when viewing by player, there was a considerable mistiming.
At first I tried to solve it, as it called, “head-on”. I noticed that mistiming on each channel was the same every time, so, I just added the appropriate delay in necessary execution thread of the program. And it worked perfectly – the mistiming disappeared.
But my joy did not last for long. Everything worked exactly before the moment, until I worked with only one TV channel. As soon as I ran in parallel processing of several channels, everything was falling apart - the delay was floating and my method didn’t work. And it is clear, adding the delay in necessary execution thread - it is like an attempt to slant the result, but not to solve the problem.
So the only working way is synchronization by PTS marks, derived from Mpeg-2 thread. And so did I, and it have solved the problem completely.
Igor, October 2012.
|