api_usage.html
来自「这个库实现了录象功能」· HTML 代码 · 共 724 行 · 第 1/3 页
HTML
724 行
int out_w, /* Dimensions of output frame */</span><br style="font-family: monospace;"><span style="font-family: monospace;"> int out_h,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> int color_model,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> unsigned char **row_pointers,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> int track);</span><br><br>It lets you take a rectangular area from the file and writes it intothe buffer at a specified location. If input size and output size aredifferent, the image will be scaled. Finally, there is a legacyversion, which will only work for BC_RGB888:<br><br><span style="font-family: monospace;">intquicktime_decode_video(quicktime_t *file,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> unsigned char **row_pointers,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> int track);</span><br><h4><a name="3.6_Video_seeking"></a>3.6 Video seeking</h4>There are different approaches depending on your timing method.<br><br><span style="font-family: monospace;">lqt_seek_video(quicktime_t *file, int track, </span><span style="font-family: monospace;">int64_ttime);</span><br style="font-family: monospace;"><br>seeks to the specified time given in timescale tics. Since thetimestamp of the next frame might be slightly different from<br>the time you seeked to, use <span style="font-family: monospace;">lqt_frame_time</span>to get the timestamp of the next frame. If you trust theframerate and just count frames, you can use:<br><br><span style="font-family: monospace;">intquicktime_set_video_position(quicktime_t *file, int64_t frame, inttrack);</span><br><h4><a name="3.7_Global_information"></a>3.7 Global information</h4>These are for information only. They play no role in the decodingprocess. To find out, if the file is an AVI, use<br><br><span style="font-family: monospace;">int lqt_is_avi(quicktime_t *file);<br><br></span>Then, you can get the metadata as strings:<br><br><span style="font-family: monospace;">char*quicktime_get_copyright(quicktime_t *file);</span><br style="font-family: monospace;"><span style="font-family: monospace;">char*quicktime_get_name(quicktime_t *file);</span><br style="font-family: monospace;"><span style="font-family: monospace;">char*quicktime_get_info(quicktime_t *file);</span><br><span style="font-family: monospace;">char * lqt_get_album(quicktime_t* file);</span><br style="font-family: monospace;"><span style="font-family: monospace;">char * lqt_get_artist(quicktime_t* file);</span><br style="font-family: monospace;"><span style="font-family: monospace;">char * lqt_get_genre(quicktime_t* file);</span><br style="font-family: monospace;"><span style="font-family: monospace;">char * lqt_get_track(quicktime_t* file);</span><br style="font-family: monospace;"><span style="font-family: monospace;">char *lqt_get_comment(quicktime_t *file);</span><br style="font-family: monospace;"><span style="font-family: monospace;">char * lqt_get_author(quicktime_t*file);</span><br><br>Treat the return values as if they were const. No, libquicktime isn'treally const friendly ;-(<br><h3><a name="4._Writing_Quicktime_files"></a>4. Writing Quicktime files</h3><h4><a name="4.1_Setting_metadata"></a>4.1 Setting metadata</h4>First, you might want to insert some information strings into yourfile. Do this with:<br><br><span style="font-family: monospace;">voidquicktime_set_copyright(quicktime_t *file, char *string);</span><br style="font-family: monospace;"><span style="font-family: monospace;">voidquicktime_set_name(quicktime_t *file, char *string);</span><br style="font-family: monospace;"><span style="font-family: monospace;">voidquicktime_set_info(quicktime_t *file, char *string);</span><br style="font-family: monospace;"><span style="font-family: monospace;">void lqt_set_album(quicktime_t*file, char *string);</span><br style="font-family: monospace;"><span style="font-family: monospace;">void lqt_set_artist(quicktime_t*file, char *string);</span><br style="font-family: monospace;"><span style="font-family: monospace;">void lqt_set_genre(quicktime_t*file, char *string);</span><br style="font-family: monospace;"><span style="font-family: monospace;">void lqt_set_track(quicktime_t*file, char *string);</span><br style="font-family: monospace;"><span style="font-family: monospace;">void lqt_set_comment(quicktime_t*file, char *string);</span><br style="font-family: monospace;"><span style="font-family: monospace;">void lqt_set_author(quicktime_t*file, char *string);</span><span style="font-weight: bold;"><br></span><h4><a name="4.2_Setting_up_tracks"></a>4.2 Setting up tracks</h4>To add an audio track, call:<br><br><span style="font-family: monospace;">intlqt_add_audio_track(quicktime_t *file,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> int channels, longsample_rate, int bits, lqt_codec_info_t * info);</span><br><br>The bits argument is only relevant for the twos and sowt codecs. Itshould be set to 16 by default. To add a video track, use:<br><br><span style="font-family: monospace;">intlqt_add_video_track(quicktime_t *file,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> int frame_w, int frame_h,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> int frame_duration, int timescale,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> lqt_codec_info_t * info);</span><br><br>The <span style="font-family: monospace;">frame_duration</span> shouldis only important, if you use<span style="font-family: monospace;">quicktime_encode_video</span>(see below).<br><br><h4><a name="4.3_Setting_codec_parameters"></a>4.3 Setting codecparameters</h4>To set a parameter of audio and video codecs, call<br><br><span style="font-family: monospace;">voidlqt_set_audio_parameter(quicktime_t *file,int stream, char *key,void*value);</span><br style="font-family: monospace;"><span style="font-family: monospace;">voidlqt_set_video_parameter(quicktime_t *file,int stream, char *key,void*value);</span><br><br>value must be of type <span style="font-family: monospace;">char*</span>for string parameters and <span style="font-family: monospace;">int*</span>for integer parameters. See <a href="#6._Codec_registry_interface">Codecregistry interface</a> for methods to find out the encoding parameters.<br><h4><a name="4.4_Making_an_AVI"></a>4.4 Making an AVI</h4>After you configured all codecs, you can tell the library to make anAVI instead of a Quicktime file. It's done with:<br><br><span style="font-family: monospace;">voidquicktime_set_avi(quicktime_t *file, 1);</span><br style="font-family: monospace;"><br>Please note, that not all codecs are supported with AVI files. Some areonly supported in AVIs. See <a href="#6._Codec_registry_interface">Codecregistry interface</a> for more informtation about this.<br><h4><a name="4.5_Encoding_audio"></a>4.5 Encoding audio</h4>To encode a buffer full of samples, use<br><br><span style="font-family: monospace;">intlqt_encode_audio_track(quicktime_t *file,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> int16_t **channels_i,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> float **channels_f,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> long samples,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> int track);</span><br style="font-family: monospace;"><br>Either channels_i or channels_f must be NULL.<br><h4><a name="4.6_Encoding_video"></a>4.6 Encoding video</h4>Before you encode the first frame, you must decide which colormodel youuse (see <a href="#5._Colormodels">Colormodels</a>). You tell thelibrary about the colormodel with:<br><br><span style="font-family: monospace;">void lqt_set_cmodel(quicktime_t*file, int track, int colormodel);</span><br><br>Then, if you will use a planar format, and your memory had paddedscanlines, tell the byte offsets between the scanlines of the luminanceand chrominance planes:<br><br><span style="font-family: monospace;">void lqt_set_row_span(quicktime_t*file, int track, int row_span);</span><br style="font-family: monospace;"><span style="font-family: monospace;">voidlqt_set_row_span_uv(quicktime_t *file, int track, int row_span_uv);</span><br style="font-family: monospace;"><br>Finally, if you source has individual tinestamps for all frames, call<br><br><span style="font-family: monospace;">int lqt_encode_video(quicktime_t*file,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> unsigned char **row_pointers,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> int track, int64_t time);</span><br style="font-family: monospace;"><br>The timestamp is given in timescale tics. <span style="font-family: monospace;">row_pointers</span> contains thescanlines for packet formats and the planes <br>for planar formats. If you have a constant frame duration and passed itto <span style="font-family: monospace;">lqt_add_video_track</span>,you might also use:<br><br><span style="font-family: monospace;">intquicktime_encode_video(quicktime_t *file,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> unsigned char **row_pointers,</span><br style="font-family: monospace;"><span style="font-family: monospace;"> int track);<br></span><h4><a name="4.7_Making_streamable_Quicktime"></a>4.7 Making streamableQuicktime</h4>By default, libquicktime will put the header (the moov atom) at the endof the file. This means, that it won't be playable from a non-seekablesource (i.e. a http connection). To reorder the file to have the headerat the start, call:<br><br><span style="font-family: monospace;">intquicktime_make_streamable(char *in_path, char *out_path);<br><br></span>This function must be called after you closed the file with <span style="font-family: monospace;">quicktime_close</span>. Note that youneed twice the disk space for this function.<span style="font-family: monospace;"><br></span><h3><a name="5._Colormodels"></a>5. Colormodels</h3>The supported colormodels are defined in colormodels.h. Libquicktimeadds another value <span style="font-family: monospace;">LQT_COLORMODEL_NONE</span>,which specifies an uninitialized or unknown colormodel. Informationsabout the supported colormodels can be obtained with:<br><br><span style="font-family: monospace;">const char *lqt_colormodel_to_string(int colormodel);</span><br style="font-family: monospace;"><span style="font-family: monospace;">intlqt_string_to_colormodel(const char * str);</span><br style="font-family: monospace;"><span style="font-family: monospace;">int lqt_colormodel_is_planar(intcolormodel);</span><br style="font-family: monospace;">
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?