MCPcopy Create free account
hub / github.com/BabitMF/bmf / TEST

Function TEST

bmf/test/cpp_builder/cpp_sync_mode.cpp:21–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19#include "cpp_test_helper.h"
20
21TEST(cpp_sync_mode, sync_videoframe) {
22 std::string output_file = "./videoframe.jpg";
23 BMF_CPP_FILE_REMOVE(output_file);
24
25 bmf::builder::Graph graph = bmf::builder::Graph(bmf::builder::NormalMode);
26
27 // create decoder
28 nlohmann::json decoder_option = {{"input_path", "../../files/overlay.png"}};
29 auto decoder =
30 graph.Sync(std::vector<int>{}, std::vector<int>{0},
31 bmf_sdk::JsonParam(decoder_option), "c_ffmpeg_decoder");
32
33 // create scale
34 nlohmann::json scale_option = {{"name", "scale"}, {"para", "320:240"}};
35 auto scale =
36 graph.Sync(std::vector<int>{0}, std::vector<int>{0},
37 bmf_sdk::JsonParam(scale_option), "c_ffmpeg_filter");
38
39 // create encoder
40 nlohmann::json encoder_option = {{"output_path", output_file},
41 {"format", "mjpeg"},
42 {"video_params", {{"codec", "jpg"}}}};
43 auto encoder =
44 graph.Sync(std::vector<int>{0}, std::vector<int>{},
45 bmf_sdk::JsonParam(encoder_option), "c_ffmpeg_encoder");
46
47 // call init if necessary, otherwise we skip this step
48 graph.Init(decoder);
49 graph.Init(scale);
50 graph.Init(encoder);
51
52 // decode
53 auto decoded_frames = decoder.ProcessPkts();
54
55 // scale
56 bmf::builder::SyncPackets input_scale;
57 input_scale.Insert(0, decoded_frames[0]);
58 auto scaled_frames = scale.ProcessPkts(input_scale);
59
60 // encode
61 bmf::builder::SyncPackets input_encode;
62 input_encode.Insert(0, scaled_frames[0]);
63 encoder.ProcessPkts(input_encode);
64
65 encoder.SendEOF();
66
67 // call close if necessary, otherwise we skip this step
68 graph.Close(decoder);
69 graph.Close(scale);
70 graph.Close(encoder);
71
72 BMF_CPP_FILE_CHECK(output_file, "./"
73 "videoframe.jpg|240|320|0.04|IMAGE2|950000|"
74 "4750|mjpeg|{\"fps\": \"25.0\"}");
75}
76
77TEST(cpp_sync_mode, sync_audioframe) {
78 std::string output_file = "./audioframe.mp4";

Callers

nothing calls this directly

Calls 11

SyncMethod · 0.80
ProcessPktsMethod · 0.80
InsertMethod · 0.80
SendEOFMethod · 0.80
insertMethod · 0.80
GraphClass · 0.50
InitMethod · 0.45
CloseMethod · 0.45
emptyMethod · 0.45
ProcessMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected