BabitMF / bmf

Cross-platform, customizable multimedia/video processing framework. With strong GPU acceleration, heterogeneous design, multi-language support, easy to use, multi-framework compatible and high performance, the framework is ideal for transcoding, AI inference, algorithm integration, live video streaming, and more.
https://babitmf.github.io/
Apache License 2.0
807 stars 71 forks source link

bmf::builder::Node::AddCallback设置回调之后RealNode::NodeMetaInfo::Dump的时候抛出异常cannot use operator[] with a numeric argument with #105

Open zhzhjr opened 8 months ago

zhzhjr commented 8 months ago

cannot use operator[] with a numeric argument with 1、RealNode::NodeMetaInfo::Dump()中使用数值类型作为json的key抛出异常 另外还有个问题: 2、RealNode::NodeMetaInfo::Dump()的时候和NodeMetaInfo::to_json()里面callback_binding字段名不一致格式也不一致

zhzhjr commented 8 months ago

NodeMetaInfo-Dump NodeMetaInfo-tojson

sfeiwong commented 8 months ago

方便提供一下复现步骤吗

zhzhjr commented 8 months ago

dump_graph:1构造graph->创建解码器->创建编码器->任意一个node AddCallback->run 代码如下: nlohmann::json graph_para = {{"dump_graph", 1}}; auto graph = bmf::builder::Graph(bmf::builder::NormalMode, bmf_sdk::JsonParam(graph_para));

nlohmann::json decode_para = {
    {"input_path", "../../files/big_bunny_10s_30fps.mp4"}};
auto video = graph.Decode(bmf_sdk::JsonParam(decode_para));

nlohmann::json encode_para = {{"output_path", output_file},
                              {"video_params",
                               {{"codec", "h264"},
                                {"width", 320},
                                {"height", 240},
                                {"crf", 23},
                                {"preset", "veryfast"}}},
                              {"audio_params",
                               {{"codec", "aac"},
                                {"bit_rate", 128000},
                                {"sample_rate", 44100},
                                {"channels", 2}}}};

auto node = graph.Encode(video["video"], video["audio"],
             bmf_sdk::JsonParam(encode_para));
node.AddCallback(0, bmf::BMFCallback([](bmf_sdk::CBytes data)-> bmf_sdk::CBytes {
    std::string strInfo;
    strInfo.assign(reinterpret_cast<const char*>(data.buffer), data.size);
    return data; }));

graph.Run();
sfeiwong commented 7 months ago

dump_graph:1构造graph->创建解码器->创建编码器->任意一个node AddCallback->run 代码如下: nlohmann::json graph_para = {{"dump_graph", 1}}; auto graph = bmf::builder::Graph(bmf::builder::NormalMode, bmf_sdk::JsonParam(graph_para));

nlohmann::json decode_para = {
    {"input_path", "../../files/big_bunny_10s_30fps.mp4"}};
auto video = graph.Decode(bmf_sdk::JsonParam(decode_para));

nlohmann::json encode_para = {{"output_path", output_file},
                              {"video_params",
                               {{"codec", "h264"},
                                {"width", 320},
                                {"height", 240},
                                {"crf", 23},
                                {"preset", "veryfast"}}},
                              {"audio_params",
                               {{"codec", "aac"},
                                {"bit_rate", 128000},
                                {"sample_rate", 44100},
                                {"channels", 2}}}};

auto node = graph.Encode(video["video"], video["audio"],
             bmf_sdk::JsonParam(encode_para));
node.AddCallback(0, bmf::BMFCallback([](bmf_sdk::CBytes data)-> bmf_sdk::CBytes {
    std::string strInfo;
    strInfo.assign(reinterpret_cast<const char*>(data.buffer), data.size);
    return data; }));

graph.Run();

看起来应是个bug或不完善的点,我们继续验证fix一下