开发者

Getting frame dimension from raw mpeg4 stream?

does anyone know how i can retrieve the frame dimension of a mpeg4 video (non h264, i.e. Mpeg4 Part 2) from the raw video开发者_StackOverflow社区 bitstream? i´m currently writing a custom media source for windows media foundation, i have to provide a mediatype which needs the frame size. it doesn´t work without it. any ideas? thanks


I am not getting you. Are you trying to know the width and the height of the video being streamed? If so (and I guess that it is the "dimension" you are looking for) heres how:

  1. Parse the stream for this integer 000001B0(hex) its always the first thing you get streamed. If not, see the SDP of the stream (if you have any, and search for config= field, and there it is... only now it is a Base16 string!
  2. Read all the bytes until you get to the integer 000001B6(hex)
  3. You should get something like this (hex): 000001B0F5000001B5891300000100000001200086C40FA28 A021E0A2
  4. This is the "stream configuration header" or frame or whatever, exact name is Video Object Sequence. It holds all the info a decoder would need to decode the video stream.
  5. Read the last 4 bytes (in my example they are separated by one space -- A021E0A2)
  6. Now observe these bytes as one 32-bit unsigned integer...
  7. To get width read the first 8 bits, and then multiply what you get with 4
  8. Skip next 7 bits
  9. To get height read next 9 bits
  10. In pseudo code:

      WIDTH = readBitsUnsigned(array, 8) * 4;
      readBitsUnsigned(array, 7);
      HEIGHT = readBitsUnsigned(array, 9);
    

There you go... width and height. (:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜