Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zhzhjr opened this issue Mar 8, 2024 · 5 comments · May be fixed by #171
Assignees
Labels
bug Something isn't working

Comments

@zhzhjr
Copy link

zhzhjr commented Mar 8, 2024

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

@zhzhjr
Copy link
Author

zhzhjr commented Mar 8, 2024

NodeMetaInfo-Dump
NodeMetaInfo-tojson

@sfeiwong
Copy link
Collaborator

方便提供一下复现步骤吗

@zhzhjr
Copy link
Author

zhzhjr commented Mar 28, 2024

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
Copy link
Collaborator

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一下

@sfeiwong sfeiwong assigned sfeiwong, HuHeng and taoboyang and unassigned HuHeng Mar 29, 2024
@JackLau1222 JackLau1222 added the bug Something isn't working label Nov 28, 2024
@JackLau1222
Copy link
Collaborator

JackLau1222 commented Jan 4, 2025

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();

@zhzhjr #171 在这个patch里 我们解决了这个问题 可以试一试

@JackLau1222 JackLau1222 self-assigned this Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants