Short video release: upload a .mp4 file to Tencent Video Cloud and get the online watch URL. Tencent Video Cloud can meet various video watch needs such as nearby scheduling, instant live streaming and playback, dynamic acceleration, and global connection, delivering a smooth watch experience.
TXUGCRecordAPI to shoot a short video, and a .mp4 short video file will be generated after the shoot ends and be called back.
TXUGCPublishAPI to publish the video. After the video is successfully published, the SDK will call back the watch URL to you.
SecretKeyfor upload signature calculation into the client code of the application, as their disclosure will cause security risks. If attackers get such information by cracking the application, they can misappropriate your traffic and storage service.
SecretKeyon your server and send the signature to the application.
Signaturefield is correctly passed in; otherwise, the release will fail.
Integrate the short video upload feature as instructed in Upload SDK for Android.
Uploaded a shot, edited, or spliced video or select a local video for upload.
TXVideoEditer.generateVideo(int videoCompressed, String videoOutputPath)API to compress the video. Four resolutions are supported for compression currently, and compression with customizable bitrate will be supported in the future.
Publish the generated .mp4 file to Tencent Cloud. The application needs to get the upload signature with a short validity period for file upload as instructed in Signature Distribution.
TXUGCPublish.java) is used to publish .mp4 files to VOD so as to meet various video watch needs such as nearby scheduling, instant live streaming and playback, dynamic acceleration, and global connection.
mVideoPublish = new TXUGCPublish(TCVideoPublisherActivity.this.getApplicationContext()); // Checkpoint restart is used for file release by default TXUGCPublishTypeDef.TXPublishParam param = new TXUGCPublishTypeDef.TXPublishParam(); param.signature = mCosSignature; // Enter the upload signature calculated in step 4 // Video file path generated by shoot, which can be obtained through the `onRecordComplete` callback of `ITXVideoRecordListener` param.videoPath = mVideoPath; // First-frame video preview generated by shoot, which can be obtained through the `onRecordComplete` callback of `ITXVideoRecordListener` param.coverPath = mCoverPath; mVideoPublish.publishVideo(param);
The release process and result will be returned through the
TXRecordCommon.ITXVideoPublishListener API (in the
TXRecordCommon.java header file):
onPublishProgress is used to return the release progress, the
uploadBytes parameter indicates the number of uploaded bytes, and the
totalBytes parameter indicates the total number of bytes that need to be uploaded.
void onPublishProgress(long uploadBytes, long totalBytes);
onPublishComplete is used to return the release result.
void onPublishComplete(TXPublishResult result);
The fields in the
TXPublishResult parameter and their descriptions are as detailed below:
|videoURL||VOD address of short video.|
|coverURL||Cloud storage address of video cover.|
|videoId||Cloud storage ID of video file, through which you can call VOD's server APIs.|
You can check the short video release result against the error code table.
After the video is successfully uploaded in step 3, the video
fileId, playback URL, and cover URL will be returned. You can directly pass in the
fileId or playback URL to the VOD player for video playback.