MediaSDK-Cpp is a C++ library to handle stitching, editing of media from Insta360 Cameras.
Platform | Version |
---|---|
Windows | Windows 7 or later, only x64 supported |
MacOS | 10.8.2 or later, only x64 supported |
Linux | Ubuntu, other distributions need to be tested |
filetype | import format | export format |
---|---|---|
Video | insv | mp4 |
Image | insp | jpg |
On Ubuntu, follow the steps below to build and run stitcherSDKDemo.
$ gcc main.cc -o stitcherSDKDemo -I/path/to/libmediaSDK -lMediaSDK
$ sudo chmod +x stitcherSDKDemo
$ export LD_LIBRARY_PATH=LD_LIBRARY_PATH:/path/to/libMediaSDK.so
$ ./stitcherSDKDemo -h
The video stitcher runs asynchronously. Before StartStitch
, you can call the function SetStitchProgressCallback
to set a callback for receiving the current process during stitching, and call the function SetStitchStateCallback
to set an error callback so that you can get the error info if an error occurs during stitching. After running StartStitch function, you must set a blocking state to prevent the program from ending. You can end the blocking state by using the status returned by these two callback functions. It can be referred to main.cc.
The image stitcher runs synchronously.
#include <stitcher/stitcher.h>
#include <stitcher/common.h>
auto imageStitcher = std::make_shared<ins_media::ImageStitcher>();
//set params
imageStitcher->SetInputPath(input_paths);
imageStitcher->SetStitchType(stitch_type);
imageStitcher->SetHDRType(hdr_type);
imageStitcher->SetOutputPath(output_path);
imageStitcher->SetOutputSize(output_width, output_height);
imageStitcher->EnableFlowState(bEnableFlowState);
//perform stitch
imageStitcher->Stitch();
#include <stitcher/stitcher.h>
#include <stitcher/common.h>
auto videoStitcher = std::make_shared<ins_media::VideoStitcher>();
videoStitcher->SetInputPath(input_paths);
videoStitcher->SetOutputPath(output_path);
videoStitcher->SetStitchType(stitch_type);
videoStitcher->SetOutputSize(output_width, output_height);
videoStitcher->SetOutputBitRate(output_bitrate);
videoStitcher->EnableFlowState(bEnableFlowState);
void process_callback(long lContext, int process, int error) {
printf("\rprocess = %d%% ", process);
}
...
videoStitcher->SetStitchProgressCallback(process_callback, 0);
void error_callback(long lContext, int error, const char* errinfo) {
//you can print the error info
}
...
videoStitcher->SetStitchStateCallback(error_callback, 0);
videoStitcher->StartStitch();
videoStitcher->CancelStitch();
On video The maximum size of the vector is 2. For 5.7k separated videos like /path/to/VID_20190123_113402_00_032.insv
and /path/to/VID_20190123_113402_10_032.insv
, please input urls of both videos with order like this {"/path/to/VID_20190123_113402_00_032.insv
","/path/to/VID_20190123_113402_10_032.insv
"},xxx_00_xx.insv
means the first eye while xxx_10_xx.insv
means the second.
On image Generally the size of the vector is 1 , if you enable HDR , there might be multiple paths.
StitchType is an enum.
enum class STITCH_TYPE {
TEMPLATE, //very fast but not good stitching effect
OPTFLOW,//slow but best stitching effect
DYNAMICSTITCH,//fast and keeps a relatively good stitching effect
};
HDRType is an enum.
enum class HDR_TYPE {
ImageHdr_NONE = -1, //do not perform HDR, this is the default value.
SingleImageHdr = 0, //perform HDR on a single image
MultiImageHdr_mbb = 1,//perform HDR with multiple images with a ev gap.
MultiImageHdr_mpl = 2,//same as MultiImageHdr_mbb, with a different algorithm and a little faster.
};
Bool value indicating whether you want to enable the super flowstate feature of Insta360.