I want to multiplex two PES (Packetized Elementary Stream) streams. One video stream and a audio stream. Both streams contain PES packets including PTS (Presentation TimeStamp) and DTS (Decoding TimeStamp) information. I want to generate a MPEG-2 compliant program stream. A program stream contains (among others) pack headers. The pack header should contain valid SCR (System Clock Reference) values. The SCR value is used for the synchronization of the audio and video stream.

I have created a software program that is able to generate a MPEG-2 compliant stream, but there is a problem with the playback of generated video. It does not run smooth. When I separately playback the generated audio or video stream the playback is ok.

Now my main question is, how can I generate values for the SCR so that my video and audio will run smoothly? Or is there a program (including sourcecode) that does it correct? Is it important where to place the audio packets within a GOP (group of pictures)?

Any information / experience on this subject is welcome.

Best regards, Rogier