[FFmpeg-devel] NC camera patch

Aurelien Jacobs aurel
Fri Jan 9 23:59:57 CET 2009


nicolas martin wrote:

> Hi all,
> 
> I finally made some code to read the camera feed sent by NC46** types  
> cameras.
> 
> Thanks for reading and sharing your thoughts !

The format looks quite simple and your code quite complicated.
Maybe I missed some subtlety in the format.
So let me first describe the format as I understand it:
Each frame is composed of:
  - A header (16 bytes)
    * 4 bytes : a flag (eg: 0x1A5  (big-endian))
    * 1 byte  : unknown/unused
    * 2 bytes : data_size (only when flag == 0x1A5)
    * 9 bytes : unknown/unused
  - MPEG4 data frame (data_size bytes)
Please correct me if there's something wrong here.

If my description is right, you could write your frame reader
function trivially, with something like that:

  flag = get_be32(pb);
         get_byte(pb);
  size = get_le16(pb);
  url_fskip(pb, 9);
  if (flag != 0x1A5)
      /* error handling */;
  av_new_packet(pkt, size)
  get_buffer(pb, pkt->data, size);

You need some more error checking, etc...
But basically, this code should be enough.

BTW: you should upload a sample file like described in [1] to allow
other developers to test your code.

Oh, and your nc_read_header() seems to contain code which is
totally unrelated to your format (MJPEG, DIRAC, etc...).
And you don't need to use s->iformat->value if it's hardcoded
to MPEG4.

Aurel

[1] http://ffmpeg.org/bugreports.html




More information about the ffmpeg-devel mailing list