[FFmpeg-devel] how to change the pcr pid value muxing transport stream

Michael Niedermayer michaelni at gmx.at
Sun Sep 23 03:37:48 CEST 2012


On Fri, Sep 21, 2012 at 05:37:40PM +0200, Ekaitz D. wrote:
> Hello!
> This is my first message here, so I hope I'm not making any mistake, if so,
> I'm sorry.
> Ok, so I need to use the ffmpeg libraries with CLI to convert vids to mpeg2
> transport stream, with some fixed parameters of bitrate, framerate, etc...
> I have managed to do it using a Windows build ( all this in windows) for
> the resulting video to be playable, it needs to have a exact value for the
> video stream pid, the audio stream pid and for the pcr pid. I've managed to
> change the video and audio pids, but I find impossible to change the pcr
> pid using command line. Its value is always the same as the video stream
> pid, and for me it is a very big problem.
> With all this on mind, I'm going with my questions.
> As I can't change the value of the pcr pid using Command Line, I decided to
> take the source code, search for the place where the pcr pid value is set
> and try to change it. ( and then using crosscompiling, build the library
> again, this I have managed to do correctly)
> Ok, I found that the value is set in the source code file: "mpegtsenc.c"
> there are a couple of places where the value of the video pid is assigned
> to the pcr_pid, so I made modifications to the code to change that value (
> a simple: "+2" should make the trick) And after trying it for the first
> time, and after building correctly the ffmpeg.exe, the video is created,
> its size is the correct, the pcr pid value is correctly set, but the video
> lenght wont appear and the video aint play. It happened that the value
> wasn't introduced to the pmt table so it was like there was no time.
> Looking more in the code of mpegtsenc.c I found that the value of the
> pcr_pid was used in an if so it wasn't entering it, so I made a little
> modification to leave it as it was. With this "trick" I built again the
> library and made a new try.
> ( the modification is just a "-2" to compensate the earlier done "+2" to
> let it enter the comparision)
> In this case, the video was created with the changed pid for the pcr, it
> was introduced in the pmt, and the video has the correct size and lenght,
> but it wont play, just a second and the video ends and the time
> dissapears...
> I will continue investigating, but I have more clues for now in how wich
> modification to do for changing the pid of the pcr of the transport stream.
> Does anyone have any idea about what can I do??

I suggest you check the mpeg systems spec or H.222 (they are more or
less the same) to make sure the changes follow the requirements of the
spec and nothing is missing.

you can also look into the mpegts demuxer to see what happens when
the video stops

good luck!

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120923/6f4bf742/attachment.asc>

More information about the ffmpeg-devel mailing list