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

📄 qt4l_writing.html

📁 这个库实现了录象功能
💻 HTML
字号:
<TITLE>Quicktime for Linux</TITLE><H1>Writing a file</H1>The following commands are good for writing to a file.<P>Immediately after opening the file, set up some tracks to write withthese commands:<P><CODE>	quicktime_set_audio(quicktime_t *file, int channels, long sample_rate, int bits, char *compressor);<BR>	quicktime_set_video(quicktime_t *file, int tracks, int frame_w, int frame_h, float frame_rate, char *compressor);</CODE><P>Don't call the audio command if you don't intend to store any audiodata.  Likewise, don't call the video command if you're just going tosave audio.<P>Notice the channels argument for audio channels but there is noargument for total audio tracks. Currently the library only supportswriting one audio track of any number of channels.<P>If you intend to use the library's built-in compression routinesspecify a compressor #define from quicktime.h as the compressorargument.  If you want to write your own compression routine, specifyany 4 byte identifier you want but don't expect the library to handlecompression.  The compressor applies to all tracks of the same mediatype, for sanity reasons.<P>Once these routines are called you can optionally call <P><CODE>void quicktime_set_parameter(quicktime_t *file, char *key, void *value);<P></CODE><P>to set compression parameters for the codecs.  Each parameter for acodec consists of a unique string and a pointer to a value.  The stringis unique to the codec and the parameter.  The value is in a specificdata type recognized by the parameter.<P>To set a jpeg compression quality of 80, for example, do the following:<P><CODE>int quality = 80;<BR>quicktime_set_parameter(file, "jpeg_quality", &quality);<BR></CODE><P>The data type of the value depends on the parameter.  Currently thebest way to determine what parameters and value data types a particularcodec supports is to look at the codec's source code.  A better way maybecome available in the future.<P>If you don't call quicktime_set_parameter the codecs will use defaultparameters.<P><A NAME="Encodingvideo"><H1>Encoding video</H1>The library generates compressed video frames from a frame buffer ofany colormodel in colormodels.h.  First use<P><CODE>int quicktime_supported_video(quicktime_t *file, int track);</CODE><P>to find out if the codec for the track is in the library.  This returns1 if it is and 0 if it isn't supported.  Then use<P><CODE>int quicktime_writes_cmodel(quicktime_t *file, 		int colormodel, 		int track);</CODE><P>To query the library for a colormodel which doesn't requiredownsampling to drive the codec.  <B>colormodels.h</B> contains a setof colormodel #defines which supply the colormodel argument.  Thefunction returns True or False depending on whether the colormodelargument is optimum.  When a colormodel doesn't require downsampling itreturns 1.  Then call<P><CODE>quicktime_set_cmodel(quicktime_t *file, int colormodel);</CODE><P>to set the colormodel your frame buffer is in.  Finally call<P><CODE>	int quicktime_encode_video(quicktime_t *file, unsigned char **row_pointers, int track);</CODE><P>to compress the frame pointed to by **row_pointers, write it at thecurrent position of the track and advance the current position.  Thereturn value is always 1 for failure and 0 for success.  The rowpointers must point to rows stored in the colormodel.  Planarcolormodels use only the first 3 row pointers, each pointing to one ofthe planes.<P><A NAME="Encodingaudio"><H1>Encoding audio</H1>The library also supports encoding certain audio codecs.  Beforewriting a buffer of samples, try <P><CODE>int quicktime_supported_audio(quicktime_t *file, int track);</CODE><P>The track argument is really hypothetical here, since you should onlypass 0 for it.  If you get a TRUE return value, you are free to use <P><CODE>int quicktime_encode_audio(quicktime_t *file, int16_t **input_i, float **input_f, long samples);</CODE><P>to encode the sample buffer.  Pass an array of buffers to either theint16_t** or the float** argument, depending on what format your datais in.  Pass a NULL to the undesired format.  The array of buffers isone buffer of samples for each channel.  This means all the channelshave to be written simultaneously.  The return value is 0 on success.<P><A NAME="Writingrawvideo"><H1>Writing raw video</H1>For writing raw data, you need to supply a buffer of data exactly asyou intend the read operations to see it, with the encoding done, thencall one of these functions to write it.  For video, specify the numberof bytes in the frame buffer and the track this frame belongs to. Video can only be written one frame at a time.<P><CODE>int quicktime_write_frame(quicktime_t *file, unsigned char *video_buffer, long bytes, int track);</CODE><P>Now some of you are going to want to write frames directly to a filedescriptor using another library like libjpeg or something.  For everyframe start by calling quicktime_write_frame_init to initialize theoutput.<P><CODE>int quicktime_write_frame_init(quicktime_t *file, int track);</CODE><P>Then write your raw, compressed data to the file descriptor given byquicktime_get_fd.<P><CODE>FILE* quicktime_get_fd(quicktime_t *file);</CODE><P>End the frame by calling quicktime_write_frame_end.<P><CODE>int quicktime_write_frame_end(quicktime_t *file, int track);</CODE><P>Repeat starting at quicktime_write_frame_init for every frame.<A NAME="Writingkeyframes"><H1>Writing Keyframes</H1>Quicktime offers very simple support for keyframes: a table of all thekeyframe numbers in a track.  Many students think there's a massivekeyframe programming language in Quicktime.  Really all there is is atable.<P>There are two things you can with the keyframe table: insert keyframenumbers and retrieve keyframe numbers.<P><CODE>void quicktime_insert_keyframe(quicktime_t *file, long frame, int track)</CODE><P>Inserts a keyframe number corresponding to the <B>frame</B> argument inthe table.<P><A NAME="Encodingrawaudio"><H1>Writing raw audio data</H1>This functionality is obsolete due to the idiosyncracies in compressedaudio handling.  If you want to write an audio codec you should put itinto the library.<P>Writing audio involves writing the raw audio data exactly the way theread operations are going to see it.<P><CODE>int quicktime_write_audio(quicktime_t *file, char *audio_buffer, long samples, int track);</CODE><P>The library automatically converts the sample count to the number ofbytes of data in the buffer, based on channels and bits values youpassed to quicktime_set_audio.<P>When you're done, call quicktime_close to close the file.<P><CODE>int quicktime_close(file);</CODE>

⌨️ 快捷键说明

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