⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.avilib

📁 最新的spcaview linux视频采集 包含spcaserve和spcacat
💻 AVILIB
字号:
avilib: Reading and writing avi files=====================================Copyright (C) 1999 Rainer Johanni <Rainer@Johanni.de>avilib is a open source library for dealing with AVIfiles under Linux or other UNIX operating systems.It provides a framework for extracting or adding rawaudio and single raw (=compressed) frames from/to AVI Files.It does not deal with any compression issues which have to behandled on a higher level by the user of avilib.AVI files may have several video and audiotracks.avilib writes only one video track and (optionally) oneaudio track and also extracts only the first video and audiotrack (but input files may contain more than one track, the othersjust being ingored).The interface to avilib is kept similar to the quicktime4linux interface(by Adam Williams) with the following important differences:- since only the first track of video and audio is considered,  there is no track argument in any of the routines.- audio is generally considered as a byte stream and therefore  all size arguments used in reading/writing audio are in bytes  and not in samples.- as mentioned above, there are no routines dealing with compression issues.Compiling:==========Since the library consists only of one c source file, I have not provideda Makefile or similar, just compile withcc -c <your favorite options> avilib.cPortability:============AVI-Files use little endian numbers throughout the file, I have triedto read/write these numbers in a way which doesn't depent on endianness.This library should therefore also be useable on big endian machines.This feature is not so heavily tested, however.Usage:======Basics, opening, closing------------------------Include "avilib.h" in your source and declare a pointer:   avi_t *avifile;Open the AVI file with:   avifile = AVI_open_input_file("xxx.avi",1);or   avifile = AVI_open_output_file("xxx.avi");You may either only read from the input file (leaving it unchanged)or create a completly new AVI file. There is no editing or appendmode available.Both routines will either return a pointer to avi_t or a zero pointerin the case of an error.For closing the file, use:   int  AVI_close(avi_t *AVI);Files you have written MUST be closed (the header is written at close time),else they will not be readable by any other software.Files opened for reading should be closed to free the file descriptorand some data (unless your program is finishing anyway).Error handling:---------------Most routines (besides open/close) will return 0 or a usefull number if successfulland a -1 in the case of an error. If an error occured, the external variableAVI_errno is set. See avilib.h for the meaning of the error codes in AVI_errno.There is also a routine (which acts like perror) to output a descriptionof the last error to stderr:AVI_print_error(char *str)Reading from an AVI file:-------------------------After opening the file, you can obtain the parameters of the AVIwith the following routines:long AVI_video_frames(avi_t *AVI);   number of video frames in the fileint  AVI_video_width(avi_t *AVI);int  AVI_video_height(avi_t *AVI);   width and height of the video in pixelsdouble AVI_frame_rate(avi_t *AVI);   frame rate in frames per second, notice that this is a double value!char* AVI_video_compressor(avi_t *AVI);   string describing the compressorint  AVI_audio_channels(avi_t *AVI);   number of audio channels, 1 for mono, 2 for stereo, 0 if no audio presentint  AVI_audio_bits(avi_t *AVI);   audio bits, usually 8 or 16int  AVI_audio_format(avi_t *AVI);   audio format, most common is 1 for raw PCM, look into avilib.h for otherslong AVI_audio_rate(avi_t *AVI);   audio rate in samples/secondlong AVI_audio_bytes(avi_t *AVI);   total number of audio bytes in the fileIn order to read the video frame by frame, use(frame numbers are starting from 0 !!!!!)long AVI_frame_size(avi_t *AVI, long frame);   to get the size of frame with number "frame"long AVI_read_frame(avi_t *AVI, char *vidbuf);   to read the next  frame (frame posittion is advanced by 1 after the read)int  AVI_seek_start(avi_t *AVI);int  AVI_set_video_position(avi_t *AVI, long frame);   to position in the AVI file   (for reading the frames out of order)Read audio withint  AVI_set_audio_position(avi_t *AVI, long byte);   to position to an arbitrary byte position within the audio streamlong AVI_read_audio(avi_t *AVI, char *audbuf, long bytes);   to actually read "bytes" number of audio bytes.   the audio position is advanced by "bytes", so there is no   need to reposition before every call when reading in order.Avoiding lengthy index searches:--------------------------------When opening the AVI file, avilib looks if the file has an index attachedand if this is not the case, it creates one by reading through the whole file.If you want to read through the file only once, creation of an index isnot necessary in that case. You may use AVI_open_input_file with the secondargument set to 0 and then use AVI_read_data for readin through the file.Look to the source for the arguments of AVI_read_data.Writing to an AVI file:-----------------------After you have opened the file, use the following routines to setthe properties of the AVI file:void AVI_set_video(avi_t *AVI, int width, int height, double fps, char *compressor);void AVI_set_audio(avi_t *AVI, int channels, long rate, int bits, int format);with:width, height   width and height of the video in pixelsfps             frame rate in frames per second, notice that this is a double value!compressor      string describing the compressorchannels        number of audio channels, 1 for mono, 2 for stereo, 0 if no audio presentrate            audio rate in samples/secondbits            audio bits, usually 8 or 16, 0 if no audio presentformat          audio format, most common is 1 for raw PCM, look into avilib.h for othersto write video frames or audio, use:int  AVI_write_frame(avi_t *AVI, char *data, long bytes);int  AVI_write_audio(avi_t *AVI, char *data, long bytes);there is also a feature to duplicate the index entry of the lastframe without writing the data again to the file, this shouldused with care since I don't know if all AVI players can handlethe resulting file (xanim can do it!):int  AVI_dup_frame(avi_t *AVI);AVI files have a 2 GB limit (as has the Linux ext2 file system),avilib will return an error if you try to add more data to the file(and it cares that the file still can be correctly closed).If you want to check yourself how far you are away from that limit(for example to synchronize the amount of audio and video data) use:long AVI_bytes_remain(avi_t *AVI);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -