| 19 | #include "cpp_test_helper.h" |
| 20 | |
| 21 | TEST(cpp_premodule, premodule) { |
| 22 | std::string output_file = "./output.mp4"; |
| 23 | BMF_CPP_FILE_REMOVE(output_file); |
| 24 | |
| 25 | nlohmann::json pre_module_option = {{"name", "analysis_SR"}, |
| 26 | {"para", "analysis_SR"}}; |
| 27 | auto pre_module = bmf::builder::GetModuleInstance( |
| 28 | "analysis", pre_module_option.dump(), bmf::builder::Python, |
| 29 | "../../test/pre_module", "analysis:analysis"); |
| 30 | |
| 31 | for (int i = 0; i < 3; i++) { |
| 32 | nlohmann::json graph_para = {{"dump_graph", 1}}; |
| 33 | nlohmann::json decode_para = { |
| 34 | {"input_path", "../../files/big_bunny_10s_30fps.mp4"}}; |
| 35 | auto graph = bmf::builder::Graph(bmf::builder::NormalMode, |
| 36 | bmf_sdk::JsonParam(graph_para)); |
| 37 | auto video = graph.Decode(bmf_sdk::JsonParam(decode_para)); |
| 38 | |
| 39 | auto output = video["video"].Scale("320:240"); |
| 40 | auto analyzed = |
| 41 | output.PythonModule({}, "analysis", bmf_sdk::JsonParam()); |
| 42 | analyzed.SetPreModule(pre_module); |
| 43 | |
| 44 | nlohmann::json encode_para = { |
| 45 | {"output_path", output_file}, |
| 46 | {"video_params", {{"width", 300}, {"height", 200}}}}; |
| 47 | analyzed.EncodeAsVideo(bmf_sdk::JsonParam(encode_para)); |
| 48 | graph.Run(); |
| 49 | |
| 50 | BMF_CPP_FILE_CHECK(output_file, "../pre_module/" |
| 51 | "output.mp4|200|300|10.0|MOV,MP4,M4A," |
| 52 | "3GP,3G2,MJ2|62956|78695|h264|{\"fps\":" |
| 53 | " \"30.0662251656\"}"); |
| 54 | } |
| 55 | } |
nothing calls this directly
no test coverage detected