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
809 stars 71 forks source link

ffmpegenc 参数能否透传? #122

Closed KkemChen closed 5 months ago

KkemChen commented 5 months ago
int main(int argc, char** argv) {
    std::cout << "hello world!" << std::endl;
    std::string output_file = "rtsp://172.31.60.105/live/test";
    // BMF_CPP_FILE_REMOVE(output_file);

    nlohmann::json graph_para = {{"dump_graph", 0}};
    auto graph = bmf::builder::Graph(bmf::builder::NormalMode, bmf_sdk::JsonParam(graph_para));

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

    nlohmann::json logoPara = {{"input_path", "/d1/video/Snipaste_2024-04-27_20-10-56.png"}};
    auto logo = graph.Decode(bmf_sdk::JsonParam(logoPara));

    auto output_stream =
        video["video"].Scale("1280:720").Trim("start=0:duration=7").Setpts("PTS-STARTPTS");

    auto overlay = logo["video"].Scale("300:200").Loop("loop=0:size=10000").Setpts("PTS+0/TB");

    nlohmann::json encode_para = {{"output_path", output_file},
                                {"format", "rtsp"},
                                {"video_params",
                                 {
                                     {"rtsp_transport", "tcp"},
                                     {"width", 640},
                                     {"height", 480},
                                     {"codec", "h264"},
                                 }}};

    output_stream[0]
        .Overlay({overlay}, "x=if(between(t,0,7),0,NAN):y=if(between(t,0,7),0,NAN):repeatlast=1")
        .EncodeAsVideo(bmf_sdk::JsonParam(encode_para));

    graph.Run();

    return 0;
}

我想尝试 指定tcp的方式推流到一个rtsp地址,但是 这个参数好像并未生效,还是使用的默认udp

KkemChen commented 5 months ago

刚试了一下好像 encode_para里面可以通过 mux_params 来透传"rtsp_transport", "tcp"

sfeiwong commented 5 months ago

刚试了一下好像 encode_para里面可以通过 mux_params 来透传"rtsp_transport", "tcp"

感谢更新!这种方式没错。 跟codec有关的参数,可以通过video_params透传,跟muxer有关的可尝试用mux_params透传。