开发者

Need help on handling MPEG4V1 data

开发者 https://www.devze.com 2023-04-05 00:02 出处:网络
I\'m in situation where I need to get a chunk of MPEG4V1 (Microsoft MPEG-4 VKI Codec V1) data located in the beginning of a packet (that was sent by some DVR unit).

I'm in situation where I need to get a chunk of MPEG4V1 (Microsoft MPEG-4 VKI Codec V1) data located in the beginning of a packet (that was sent by some DVR unit).

Packet structure looks something like this:

  • Compressed MPEG4 data.
  • Long integer - Number of events and tripwires.
  • Long integer - Number of events.
  • Event - Event's sequence.
  • Long integer - Number of tripwires.
  • Tripwire - Tripwires sequence.
  • Long integer - Cyclical redundant code (CRC).

So there is no indication of how to know where does the MPEG4 data ends (Or is there?), and from where should I start reading this additional data like "Number of events and tripwires" and etc...

I uploaded two packet's so you could see how the actual data looks like: recvData1.txt, recvData2.txt.

I've tried to decode those packets using FFmpeg library with avcodec_decode_video function and by removing byte by byte from the end of my recvData buffer in a hope for any results,

but FFmpeg just allways returned with an error messages like this:

"[msmpeg4v1 @ 038865a0] invalid startcode", "[msmpeg4v1 @ 038865a0] header damaged".

I'm not that good specialist on knowing of how does the MPEG4 works from the inside, but judging by the error messages it's clearly seen that I'm missing some data for decoding at the start of the buffer.

So I'm not sure of what part / kind of MPEG data I'm getting here..

Maybe it's some kind of MPEG开发者_JAVA技巧's "frame" data with it's "end" indication or something?

I've even compared the start of my recvData buffer to some of MPEG4V1 encoded video files I found on the net "http://www.trekmania.net/clips/video_clips4.htm" to check if the start of my buffer really contains the MPEG data ..and not some kind of DVR vendor specific stuff..

And I noticed that there are about 20bytes of data (at the start of my packet data, and in .avi files right after about ~180bytes..) that looks like some kind of header or something..

Please check this image: "http://ggodis.gamedev.lt/stackOverflow/recvData.jpg"

Maybe someone knows what this part of MPEG4V1 data represents?

P.S. ..I've checked the CRC values for my received packets and they were correct..


I successfully decoded my packets. The data at the start of my buffer was "BITMAPINFOHEADER".. This is all I needed to know.


You're dealing with two different things here: Containers and Codecs. A Codec is used to encode/decode (hence enCOder DECoder → CODEC) the data in some digital form. MPEG4 Video in all it variants is such a family of codecs.

The other thing you need to be aware of are containers. AVI is a container, but there are many others. MPEG2-TS, MPEG2-PS, MP4, MKV, MOV (Quicktime), FLV, Ogg, just to name a few. What all container formats have in common is, that they provide the framework for storing and/or streaming Codec frames/packets. Containers give you the information neccesary to address into the frames/packets.

Containers are dealt with de-/multiplexers, short "muxers".

Please check this image: "http://ggodis.gamedev.lt/stackOverflow/recvData.jpg"

Seriously? You know that one uses Hex editors for looking/manipulating RAW data streams? Opening them in a text editor can cause all sorts of essential information to get missing, due to misinterpretation of Unicode compound codepoints or similar.

So I'm not sure of what part / kind of MPEG data I'm getting here.. Maybe it's some kind of MPEG's "frame" data with it's "end" indication or something?

This looks like part of a MP4 container file . MP4 is a very delicate container format, which heavily relies on an intact header. If the header is damaged, it cannot be played properly.

0

精彩评论

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

关注公众号