【问题标题】:send console output to Visual Studio 2010将控制台输出发送到 Visual Studio 2010
【发布时间】:2014-09-08 02:35:45
【问题描述】:

我正在使用 Visual Studio 2010 c++ 开发一些自定义的直接显示过滤器。我正在使用 ffmpeg 进行编码过程,如果我将测试作为标准控制台运行,那么任何 ffmpeg 错误都会显示在控制台窗口中,正如人们所期望的那样。然而,主应用程序是一个没有控制台窗口的 Windows 应用程序。当我从 ffmpeg 收到错误时,我只能使用一个相当通用的错误返回编号,很高兴看到控制台窗口中显示的内容。

是否可以从 ffmpeg 中获取将进入控制台窗口的输出以显示在“Studio 输出窗口”之一中。我在 Tools->Options->Debugging->General 中勾选了“Redirect all output window text to the immediate window”选项,但这不喜欢正确的选项,而且无论如何它都不起作用。

谢谢!

戴夫

【问题讨论】:

    标签: visual-studio-2010 ffmpeg console window


    【解决方案1】:

    您可以使用自定义输出例程重定向 ffmpeg 输出:

    av_log_set_callback(&FfmpegLog);
    
    void FfmpegLog(void *ptr, int level, const char *fmt, va_list vl)
    {
        static char message[8192];
        const char *module = NULL;
    
        if (ptr)
        {
            AVClass *avc = *(AVClass**) ptr;
            if (avc->item_name)
                module = avc->item_name(ptr);
        }
        vsnprintf_s(message, sizeof message, sizeof message, fmt, vl);
        std::cout << "[ffmpeg][" << (module ? module : "") << "][" << level << "] : " << message;
    }
    

    【讨论】:

    • 方便的回调允许我将输出重定向到我需要的地方。非常感谢!
    猜你喜欢
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 2017-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多