[FFmpeg-devel] NC camera patch

Vitor Sessak vitor1001
Sat Jan 10 16:10:46 CET 2009


nicolas martin wrote:
> 
>> nicolas martin wrote:
>>>
>>>> nicolas martin wrote:
>>>>
>>>>> Hi all,
>>>>>
>>>>> I finally made some code to read the camera feed sent by NC46** types
>>>>> cameras.

[...]

>>
>> Just my two cents...
>>
>> [...]
>>
>>> +/*
>>> + * NC cameras feed demuxer.
>>> + * Copyright (c) 2008  Nicolas Martin <martinic at iro.umontreal.ca>, 
>>> Edouard Auvinet
>>> + *
>>> + * This file is part of FFmpeg.
>>> + *
>>> + * FFmpeg is free software; you can redistribute it and/or
>>> + * modify it under the terms of the GNU Lesser General Public
>>> + * License as published by the Free Software Foundation; either
>>> + * version 2.1 of the License, or (at your option) any later version.
>>> + *
>>> + * FFmpeg is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>>> + * Lesser General Public License for more details.
>>> + *
>>> + * You should have received a copy of the GNU Lesser General Public
>>> + * License along with FFmpeg; if not, write to the Free Software
>>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
>>> 02110-1301 USA
>>> + */
>>> +
>>> +#include "avformat.h"
>>> +
>>> +#define NC_VIDEO_FLAG 0xA5010000
>>> +
>>> +static int nc_probe(AVProbeData *probe_packet)
>>> +{
>>> +    return 
>>> (AV_RL32(probe_packet->buf)==NC_VIDEO_FLAG?AVPROBE_SCORE_MAX:0);
>>> +}
>>> +
>>
>> If I understood well the format, the next four bytes should also be
>> NC_VIDEO_FLAG for valid files. So, its better to check also for them to
>> avoid false positives.
> 
> Just the first four bytes should be NC_VIDEO_FLAG, the next one is 
> unused and the two following are the size of the next paquet.

Indeed. I should not read code so late ;-) So maybe something like the 
following would be more robust:

static int nc_probe(AVProbeData *probe_packet)
{
     int size;

     if (AV_RL32(probe_packet->buf) != NC_VIDEO_FLAG)
         return 0;

     size = AV_RL16(probe_packet->buf + 5);

     if (size + 20 > probe_packet->buf_size)
         return 3*AVPROBE_SCORE_MAX/2;

     if (AV_RL32(probe_packet->buf+16+size) == NC_VIDEO_FLAG)
         return AVPROBE_SCORE_MAX;
     else
         return 0;
}

Also your code gives the warning

> Seems stream 0 codec frame rate differs from container frame rate: 100.00 (100/1) -> 25.00 (25/1)

Is the frame rate correct? I cannot be seem with your sample (no 
movement)...

-Vitor




More information about the ffmpeg-devel mailing list