[FFmpeg-devel] [PATCH v5] avformat/ifv: added support for ifv cctv files

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun May 26 22:44:35 EEST 2019


On Sun, May 26, 2019 at 01:46:32AM +0530, Swaraj Hota wrote:
> +    st = avformat_new_stream(s, NULL);
> +    if (!st)
> +        return AVERROR(ENOMEM);
> +
> +    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
> +    st->codecpar->codec_id = AV_CODEC_ID_H264;
> +    st->codecpar->width = ifv->width;
> +    st->codecpar->height = ifv->height;
> +    st->start_time = 0;
> +    ifv->video_stream_index = st->index;

I suspect that it would have been ok to
just assume/assert this will always be 0.

> +static int ifv_read_packet(AVFormatContext *s, AVPacket *pkt)

As far as I can tell, you just choose between audio
and video by the closest timestamp.
While this might be ok considering the limited importance
and uses of the format, it is rather simplistic.
I do not know if it follows the latest best practices,
but mov_find_next_sample is an example of a more
sophisticated way.
It takes into account whether the underlying transport
has issues seeking (like http, or even worse piped input)
and in that case prefers file position over timestamp
position.
It also avoids wasting time reading streams marked as
AVDISCARD_ALL (in mov_read_packet is that check).
Maybe others following the project more closely
can give additional/better best practice tips.


More information about the ffmpeg-devel mailing list