Tizen Native API
4.0
|
The Video Util APIs provides functions that transcode a media file.
#include <video_util.h>
Video Util API provides support for transcoding of a media file. Codec and the format that the API supported :
This API is related with the following features:
It is recommended to design feature related codes in your application for reliability.
You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
More details on featuring your application can be found from Feature Element.
FOREACH | CALLBACK | DESCRIPTION |
---|---|---|
video_util_foreach_supported_file_format() | video_util_supported_file_format_cb() | Retrieves the list of supported media format |
video_util_foreach_supported_video_codec() | video_util_supported_video_encoder_cb() | Retrieves the list of supported video codec |
video_util_foreach_supported_audio_codec() | video_util_supported_audio_encoder_cb() | Retrieves the list of supported audio codec |
Functions | |
int | video_util_create (video_util_h *handle) |
Creates a handle to video util. | |
int | video_util_destroy (video_util_h handle) |
Destroys a handle to video util. | |
int | video_util_set_file_path (video_util_h handle, const char *path) |
Sets the video util's file path. | |
int | video_util_set_accurate_mode (video_util_h handle, bool mode) |
Sets the video util's accurate mode. | |
int | video_util_set_video_codec (video_util_h handle, video_util_video_codec_e codec) |
Sets the video codec for encoding video stream. | |
int | video_util_set_audio_codec (video_util_h handle, video_util_audio_codec_e codec) |
Sets the audio codec for encoding audio stream. | |
int | video_util_set_file_format (video_util_h handle, video_util_file_format_e format) |
Sets the file format for transcoding media stream. | |
int | video_util_set_resolution (video_util_h handle, int width, int height) |
Sets the resolution(width and height). | |
int | video_util_set_fps (video_util_h handle, int fps) |
Sets the frame rate. | |
int | video_util_start_transcoding (video_util_h handle, unsigned long start, unsigned long duration, const char *out_path, video_util_transcoding_progress_cb progress_cb, video_util_transcoding_completed_cb completed_cb, void *user_data) |
Transcodes the video for given video util handle. | |
int | video_util_cancel_transcoding (video_util_h handle) |
Cancels transcoding the video for given video util handle. | |
int | video_util_get_progress_transcoding (video_util_h handle, unsigned long *current_position, unsigned long *duration) |
Retrieves the current position and duration of the video transcoding. | |
int | video_util_foreach_supported_file_format (video_util_h handle, video_util_supported_file_format_cb callback, void *user_data) |
Retrieves all supported media formats by invoking a specific callback for each supported media format. | |
int | video_util_foreach_supported_video_codec (video_util_h handle, video_util_supported_video_encoder_cb callback, void *user_data) |
Retrieves all supported video encoders by invoking a specific callback for each supported video encoder. | |
int | video_util_foreach_supported_audio_codec (video_util_h handle, video_util_supported_audio_encoder_cb callback, void *user_data) |
Retrieves all supported audio encoders by invoking a specific callback for each supported audio encoder. | |
Typedefs | |
typedef struct video_util_s * | video_util_h |
Video util handle. | |
typedef void(* | video_util_transcoding_progress_cb )(unsigned long current_position, unsigned long duration, void *user_data) |
Called regularly during the video transcoding. | |
typedef void(* | video_util_transcoding_completed_cb )(video_util_error_e error_code, void *user_data) |
Called when transcoding is finished just before storing in the file. | |
typedef bool(* | video_util_supported_file_format_cb )(video_util_file_format_e format, void *user_data) |
Called iteratively to notify you about the supported file formats. | |
typedef bool(* | video_util_supported_video_encoder_cb )(video_util_video_codec_e codec, void *user_data) |
Called iteratively to notify you of supported video codec. | |
typedef bool(* | video_util_supported_audio_encoder_cb )(video_util_audio_codec_e codec, void *user_data) |
Called iteratively to notify you about the supported audio codec. |
typedef struct video_util_s* video_util_h |
Video util handle.
typedef bool(* video_util_supported_audio_encoder_cb)(video_util_audio_codec_e codec, void *user_data) |
Called iteratively to notify you about the supported audio codec.
[in] | format | The codec of audio |
[in] | user_data | The user data passed from the foreach function |
true
to continue with the next iteration of the loop, otherwise false
to break out of the looptypedef bool(* video_util_supported_file_format_cb)(video_util_file_format_e format, void *user_data) |
Called iteratively to notify you about the supported file formats.
[in] | format | The format of media files |
[in] | user_data | The user data passed from the foreach function |
true
to continue with the next iteration of the loop, otherwise false
to break out of the looptypedef bool(* video_util_supported_video_encoder_cb)(video_util_video_codec_e codec, void *user_data) |
Called iteratively to notify you of supported video codec.
[in] | format | The codec of video |
[in] | user_data | The user data passed from the foreach function |
true
to continue with the next iteration of the loop, otherwise false
to break out of the looptypedef void(* video_util_transcoding_completed_cb)(video_util_error_e error_code, void *user_data) |
Called when transcoding is finished just before storing in the file.
[in] | error_code | The error code of video util |
[in] | user_data | The user data passed from the callback registration function |
typedef void(* video_util_transcoding_progress_cb)(unsigned long current_position, unsigned long duration, void *user_data) |
Called regularly during the video transcoding.
The interval of callback invocation depends on the framework.
[in] | current_position | The current position in milliseconds |
[in] | duration | The duration in seconds |
[in] | user_data | The user data passed from the callback registration function |
enum video_util_error_e |
Enumeration for errors of a video util.
int video_util_cancel_transcoding | ( | video_util_h | handle | ) |
Cancels transcoding the video for given video util handle.
This function cancels the transcoding for given video util handle.
.
[in] | handle | The handle to video util |
0
on success, otherwise a negative error valueVIDEO_UTIL_ERROR_NONE | Successful |
VIDEO_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
VIDEO_UTIL_ERROR_INVALID_OPERATION | Invalid operation |
VIDEO_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
VIDEO_UTIL_ERROR_NOT_SUPPORTED | Not supported |
int video_util_create | ( | video_util_h * | handle | ) |
Creates a handle to video util.
This function creates a handle to video util.
[out] | handle | A handle to video util |
0
on success, otherwise a negative error valueVIDEO_UTIL_ERROR_NONE | Successful |
VIDEO_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
VIDEO_UTIL_ERROR_OUT_OF_MEMORY | Out of memory |
VIDEO_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
VIDEO_UTIL_ERROR_NOT_SUPPORTED | Not supported |
int video_util_destroy | ( | video_util_h | handle | ) |
Destroys a handle to video util.
The function frees all resources related to the video util handle. The video util handle no longer can be used to perform any operation. A new video util handle has to be created before the next usage.
[in] | handle | The handle to video util |
0
on success, otherwise a negative error valueVIDEO_UTIL_ERROR_NONE | Successful |
VIDEO_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
VIDEO_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
VIDEO_UTIL_ERROR_NOT_SUPPORTED | Not supported |
int video_util_foreach_supported_audio_codec | ( | video_util_h | handle, |
video_util_supported_audio_encoder_cb | callback, | ||
void * | user_data | ||
) |
Retrieves all supported audio encoders by invoking a specific callback for each supported audio encoder.
[in] | handle | The handle to video util |
[in] | callback | The callback function to be invoked |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error valueVIDEO_UTIL_ERROR_NONE | Successful |
VIDEO_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
VIDEO_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT | Not supported format |
VIDEO_UTIL_ERROR_NOT_SUPPORTED | Not supported |
int video_util_foreach_supported_file_format | ( | video_util_h | handle, |
video_util_supported_file_format_cb | callback, | ||
void * | user_data | ||
) |
Retrieves all supported media formats by invoking a specific callback for each supported media format.
[in] | handle | The handle to video util |
[in] | callback | The callback function to invoke |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error valueVIDEO_UTIL_ERROR_NONE | Successful |
VIDEO_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
VIDEO_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT | Not supported format |
VIDEO_UTIL_ERROR_NOT_SUPPORTED | Not supported |
int video_util_foreach_supported_video_codec | ( | video_util_h | handle, |
video_util_supported_video_encoder_cb | callback, | ||
void * | user_data | ||
) |
Retrieves all supported video encoders by invoking a specific callback for each supported video encoder.
[in] | handle | The handle to video util |
[in] | callback | The callback function to be invoked |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error valueVIDEO_UTIL_ERROR_NONE | Successful |
VIDEO_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
VIDEO_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT | Not supported format |
VIDEO_UTIL_ERROR_NOT_SUPPORTED | Not supported |
int video_util_get_progress_transcoding | ( | video_util_h | handle, |
unsigned long * | current_position, | ||
unsigned long * | duration | ||
) |
Retrieves the current position and duration of the video transcoding.
[in] | handle | The handle to video util |
[out] | current_position | Current position of transcoding |
[out] | duration | The duration is in seconds. If duration is 0, transcoding happens until end of the video |
0
on success, otherwise a negative error value VIDEO_UTIL_ERROR_NONE | Successful |
VIDEO_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
VIDEO_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
VIDEO_UTIL_ERROR_NOT_SUPPORTED | Not supported |
int video_util_set_accurate_mode | ( | video_util_h | handle, |
bool | mode | ||
) |
Sets the video util's accurate mode.
false
.[in] | handle | The handle to video util |
[in] | mode | Set true if the user can get an accurated frame for given the duration in video_util_start_transcoding(), otherwise set false if user can only get the nearest i-frame |
0
on success, otherwise a negative error valueVIDEO_UTIL_ERROR_NONE | Successful |
VIDEO_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
VIDEO_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
VIDEO_UTIL_ERROR_NOT_SUPPORTED | Not supported |
int video_util_set_audio_codec | ( | video_util_h | handle, |
video_util_audio_codec_e | codec | ||
) |
Sets the audio codec for encoding audio stream.
[in] | handle | The handle to video util |
[in] | codec | The audio codec |
0
on success, otherwise a negative error valueVIDEO_UTIL_ERROR_NONE | Successful |
VIDEO_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
VIDEO_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT | Not supported format |
VIDEO_UTIL_ERROR_NOT_SUPPORTED | Not supported |
int video_util_set_file_format | ( | video_util_h | handle, |
video_util_file_format_e | format | ||
) |
Sets the file format for transcoding media stream.
[in] | handle | The handle to video util |
[in] | format | The media file format |
0
on success, otherwise a negative error valueVIDEO_UTIL_ERROR_NONE | Successful |
VIDEO_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
VIDEO_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
VIDEO_UTIL_ERROR_NOT_SUPPORTED | Not supported |
int video_util_set_file_path | ( | video_util_h | handle, |
const char * | path | ||
) |
Sets the video util's file path.
This function sets the source path to transcode.
[in] | handle | The handle to video util |
[in] | path | The source file path |
0
on success, otherwise a negative error valueVIDEO_UTIL_ERROR_NONE | Successful |
VIDEO_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
VIDEO_UTIL_ERROR_OUT_OF_MEMORY | Out of memory |
VIDEO_UTIL_ERROR_NOT_SUPPORTED | Not supported |
VIDEO_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
int video_util_set_fps | ( | video_util_h | handle, |
int | fps | ||
) |
Sets the frame rate.
0
, the default is original fps from source.[in] | handle | The handle to video util |
[in] | fps | The frame rate(minimum value is 5, maximum value is 30) |
0
on success, otherwise a negative error valueVIDEO_UTIL_ERROR_NONE | Successful |
VIDEO_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
VIDEO_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
VIDEO_UTIL_ERROR_NOT_SUPPORTED | Not supported |
int video_util_set_resolution | ( | video_util_h | handle, |
int | width, | ||
int | height | ||
) |
Sets the resolution(width and height).
[in] | handle | The handle to video util |
[in] | width | The media's width If the width is 0, it set original size.(minimum value is 128) |
[in] | height | The media's height If the height is 0, it set original size.(minimum value is 96) |
0
on success, otherwise a negative error valueVIDEO_UTIL_ERROR_NONE | Successful |
VIDEO_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
VIDEO_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
VIDEO_UTIL_ERROR_NOT_SUPPORTED | Not supported |
int video_util_set_video_codec | ( | video_util_h | handle, |
video_util_video_codec_e | codec | ||
) |
Sets the video codec for encoding video stream.
[in] | handle | The handle to video util |
[in] | codec | The video codec |
0
on success, otherwise a negative error value VIDEO_UTIL_ERROR_NONE | Successful |
VIDEO_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
VIDEO_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT | Not supported format |
VIDEO_UTIL_ERROR_NOT_SUPPORTED | Not supported |
int video_util_start_transcoding | ( | video_util_h | handle, |
unsigned long | start, | ||
unsigned long | duration, | ||
const char * | out_path, | ||
video_util_transcoding_progress_cb | progress_cb, | ||
video_util_transcoding_completed_cb | completed_cb, | ||
void * | user_data | ||
) |
Transcodes the video for given video util handle.
This function starts the transcoding from start time and for given duration.
video_util_transcoding_progress_cb() function is called during the video transcoding regularly after some interval.
video_util_transcoding_completed_cb() function is called and the transcoded video will be saved at the given output path when transcoding is finished.
[in] | handle | The handle to video util |
[in] | start | The start position to transcode |
[in] | duration | The duration in seconds if duration is 0 , transcoding happens until end of the video. |
[out] | out_path | The file path to save |
[in] | progress_cb | The callback function to be invoked |
[in] | completed_cb | The callback function to be invoked |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error valueVIDEO_UTIL_ERROR_NONE | Successful |
VIDEO_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
VIDEO_UTIL_ERROR_INVALID_OPERATION | Invalid operation |
VIDEO_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
VIDEO_UTIL_ERROR_NOT_SUPPORTED | Not supported |