Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Compression Techniques [SOLVED] Setting video PID and audio PID. (MPEG-TS output)

  • [SOLVED] Setting video PID and audio PID. (MPEG-TS output)

    Posted by Jordan Johnson on November 4, 2013 at 11:43 pm

    SOLVED. SEE LATER POSTS.

    First time posting here, long time lurker so here’s to hoping it’s int he right spot.

    Anyway, I have this MPEG-2 and AC3 stream I want to send to GNURadio for processing. Only problem is, my GNURadio application needs specific PIDs for video and audio streams (eg 0x050 for video, and 0x052 for audio; 0x070 for video 2, etc). Really, that’s it. However, the -map or streamid functions can’t do this, and the -mpegts metadata options don’t seem to specify it either.

    Any way to insert manual PIDs for each stream without sending it to another program to do so? Perhaps there is a patch or means for me to patch my ffmpeg to do this?

    Thank you in advance. 🙂

    Yantao Song replied 11 years, 6 months ago 3 Members · 8 Replies
  • 8 Replies
  • Reuben Martin

    November 5, 2013 at 4:53 pm

    There are muxing options available for mpeg-ts, among them the ability to set the PID values.

    mpeg-ts documentation

  • Reuben Martin

    November 5, 2013 at 5:14 pm

    Reading your post a second time, I think I misunderstood what you are trying to ask.

    “map” has to do with matching input streams to output streams.

    “streamid” has more to do with specifying different settings as the codec level, not at the format level.

    You might want to try the “stream_index” option which works at the format level since this is info you want to pass to the muxer, rather than the encoder.

    stream specifiers

  • Jordan Johnson

    November 6, 2013 at 6:12 am

    Thank you or the response. I’m afraid I have tried the specifiers as well and as you said, map pertains to the stream assignment as opposed to a readable PID that my application can recognize. FFMPEG seems to assign constant values though, (0x100 = 256) for video, and (0x101 = 257) for audio. What I would like to do is assign those IDs myself. I am also aware of mpegts metadata fields, but those apply to a whole MPEG-TS. Not the elementary streams.

  • Reuben Martin

    November 6, 2013 at 7:28 pm

    Well, I ran a couple short tests to see what I would get. (I’ve never had to deal with situations where specific PID numbers were required.)

    I didn’t have any issue using the streamid options to manually set PIDs for the elementary streams.

    What version of ffmpeg are you using and what is the exact terminal command you are attempting to use?

    Be aware that the ffmpeg syntax uses base-10 numbering when setting stream ids. So don’t get that confused with base-16. For instance the test streams I made would have 50 and 52 assigned to video and audio streams as you had mentioned, but examining the result with tstools, shows the stream IDs as 0032 and 0034 (the hexadecimal equivalent)

  • Jordan Johnson

    November 6, 2013 at 8:02 pm

    Hmm, what does your command look like? I’d love to do some testing real quick.

    Thanks for your response. 🙂

  • Reuben Martin

    November 6, 2013 at 11:06 pm

    I’m remuxing an mp4 file (h264 && aac) to mpegts, and setting PIDs:


    ffmpeg -i input.mp4 -codec:v copy -codec:a copy -streamid 0:50 -streamid 1:52 -bsf h264_mp4toannexb -f mpegts output.ts

  • Jordan Johnson

    November 8, 2013 at 5:01 am

    Wow…can’t believe that’s what I did wrong the whole time.

    Thank you very much. 🙂

  • Yantao Song

    December 21, 2014 at 2:34 pm

    Hi
    Reuben Martin

    I am a new for ffmpeg , I got the problem similar as this topic talked. Application needs specific video PID and audio PID and PCR PID and PMT PID, and i try the command as you said .

    ffmpeg -i input.mp4 -codec:v copy -codec:a copy -streamid 0:50 -streamid 1:52-f mpegts output.ts

    Result is video and audio ‘s pid are correct , but this command changed PCR PID too . I don’t understand why ?
    when i try command to modify PCR PID like
    ffmpeg -i d:\1.m2t -acodec copy -vcodec copy -f mpegts -mpegts_start_pid 0x150 d:\test.m2t

    Result is PCR PID 0x150 ,problem happen for stream pid , video pid is changed also
    0x151(original is 0x200) , audio pid is changed to 0x152(original is 0x201).

    I don’t know why?

    I just want to specified value respectively.

    wait for you help . thanks a lot !

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy