Hello all.
 
I've been reading the questions and answers in this forum for about a
month, hoping that I would see the answers to some problems that I'm
having with the libavformat library and it's friends. Since I haven't
seen problems very similar to mine go past, now is the time for me to
ask my questions.
 
I am writing code for a project that reads video files (not interested
in audio data), performs some operations on the frames, without
displaying them, and then moves on. No syncing involved or needed. The
operations that are performed on the frames have to do with being able
to read (i.e. recognise) text strings added to (overlaid on) the raw
video by the original camera or editing software - the text strings are
timecodes; in other words, there is some graphical processing on the
frames as well as encoder noise/artefact reduction and OCR. The videos
are encoded in a variety of different formats, e.g. MPEG-1, MPEG-2
(including VOB dvd format), AVI (including DivX/Xdiv), MOV, WMV and so
on.
 
The good news for me is that the graphics processing, noise/artefact
reduction and OCR functionality is all working pretty well. It's in
libavformat that I'm getting most problems. I'm doing my development
under Windows at the moment using Visual Studio 6 (yes I know it's old,
but I don't like the later versions), although I also need to produce
Linux and Apple OS/X versions of the code at some point; since none of
these needs to display anything (results are fed back to another
application), the program is console based. The version of the library
is 52.23.1, which I built using gcc 4.2.1 under MSYS/MINGW32. My code is
all written in C and assembler. I have no problems calling any of the
library functions, and everything seems to be working well except for a
couple of things:
 
1) I need to be able to get the duration of a video, and most of the
time when I use dump_format I get "Duration: N/A" displayed. Is there a
simple way of getting the duration of the video stream in the files? I'm
quite happy with either a time or frame count (as long as I can get the
frame rate).
 
2) I'm looking for timecode discontinuities (either when the timecode
that I'm reading from the frames jumps ahead, or freezes for one or more
frames). Rather than process each frame in turn, I need to be able to
jump around inside the file to find the points at which these
discontinuities occur, and to be able to relate the timecode read from
the frame to the time/frame number of the frame. I'm probably missing
something here, but i can't seem to make the av_seek_frame function
work. I've tried using av_rescale_q to rebase the target frame, but
av_seek_frame always returns an error status for me. For example, I will
need to return to the start of the file to read the opening timecode to
use as a base time/frame number. How do I do that? I might then need to
seek to the end of the stream and read the timecode at that point. If
the difference in timecodes between the start and end of the file is
very different, then I need to be able to seek to anywhere in the
stream.
 
I have written a function to wrap av_seek_frame, and it's something like
this (apologies for the formatting):
 
int
VidSeek ( AVFormatContext *pFormatCtx, int StreamIdx, int Offset, int
Direction )
{
    int                RetVal;
    __int64         Target = Offset;
    AVRational    RatTimeBase = { 1, AV_TIME_BASE };
 
    Target = av_rescale_q ( Target, RatTimeBase,
pFormatCtx->streams[StreamIdx]->time_base );
    if ( (RetVal = av_seek_frame ( pFormatCtx, StreamIdx, Target,
Direction )) < 0 )
        printf ( "Error seeking to frame %d.\n", Offset );
    return ( RetVal );
}
 
Thank you for reading this far down. I never did get the hang of writing
short emails.
 
Regards,
 
Clive
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to