如何使用 FFmpeg 在 C++ 中将 AVFrame 保存为图像

2024-04-05

在我的项目中,我想保存 Hevc 文件中的一帧。我在源代码中使用 FFmpeg 来解码 Hevc 文件并获取 AVFrame 和 AVCodecContext。 我需要的是将框架保存为图片(全彩)。

我尝试将其保存为 *.pgm 文件,因此图片只是灰色的,这并不是我真正需要的。

有什么建议吗?谢谢!

void HevcDecoder::Images_Save(char* filename, AVFrame *frame)
{
    FILE* file;
    int i;

    fopen_s(&file, filename, "wb");
    fprintf(file, "P5\n%d %d\n%d\n", frame->width, frame->height, 255);
    for (i = 0; i < frame->height; i++)
        fwrite(frame->data[0] + i * frame->linesize[0], 1, frame->width, file);

    fclose(file);
}

void HevcDecoder::Decode(AVCodecContext* dec_ctx, AVFrame* frame, AVPacket* pkt, const char* filename)
{
    char buf[1024];
    int ret;

    ret = avcodec_send_packet(dec_ctx, pkt);
    if (ret < 0) {
        fprintf(stderr, "Error sending a packet for decoding\n");
        exit(1);
    }

    while (ret >= 0) {
        ret = avcodec_receive_frame(dec_ctx, frame);
        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
            return;
        else if (ret < 0) {
            fprintf(stderr, "Error during decoding\n");
            exit(1);
        }

        printf("saving frame %3d\n", dec_ctx->frame_number);
        fflush(stdout);

        /* the picture is allocated by the decoder. no need to
           free it */
        snprintf(buf, sizeof(buf), "%s-%d.pgm", filename, dec_ctx->frame_number);
        Images_Save(buf, frame/*, dec_ctx*/);
    }
}

使用 FFmpeg CLI 将原始 HEVC 文件转换为图像序列非常简单。

Assume input.265是输入文件(原始 HEVC 视频流):
转换为 PNG 图像:

ffmpeg -i input.265 %05d.png

转换为 PPM 图像:

ffmpeg -i input.265 %05d.ppm

如果输入视频使用 MP4 容器并且您想要 JPEG 图像:

ffmpeg -i input.265 %05d.jpg


使用 FFmpeg C 接口(Libav):

为了使事情可重现,首先使用 FFmpeg CLI 创建输入视频文件:

ffmpeg -y -f lavfi -i testsrc=size=192x108:rate=1:duration=10 -vcodec libx265 -pix_fmt yuv420p input.265

上述命令创建 HEVC (H.265) 编码流 - 10 帧,分辨率为 192x108,像素格式为 YUV420(合成模式)。
编码流是原始视频流(没有容器)。

Note:

  • RAW HEVC (H.265) 视频流不是常用的文件格式。
    通常流由容器包装(如 MP4 / MKV / AVI ...)。
    我们将原始视频流用于教育目的 - 用于解码的代码更简单。

将图像保存为彩色图像:

该代码示例重用了来自这个帖子 https://stackoverflow.com/questions/71363536/avcodec-not-able-to-decode-hevc.

  • PGM 是一种灰度格式,对于等效的颜色格式,我们可以使用PPM 格式 https://en.wikipedia.org/wiki/Netpbm.
  • 我们可以使用SWS Scale将格式从YUV420转换为RGB。

我们可以使用以下代码示例这个帖子 https://stackoverflow.com/questions/69442603/ffmpeg-convert-ycbcr-to-rgb-using-sws-scale

这是代码示例:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

extern "C" {
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
}

#define INBUF_SIZE 1024

//static void pgm_save(unsigned char* buf, int wrap, int xsize, int ysize, char* filename)
//{
//    FILE* f;
//    int i;
//
//    f = fopen(filename, "wb");
//    fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255);
//    for (i = 0; i < ysize; i++)
//        fwrite(buf + i * wrap, 1, xsize, f);
//    fclose(f);
//}


//Save RGB image as PPM file format
static void ppm_save(unsigned char* buf, int wrap, int xsize, int ysize, char* filename)
{
    FILE* f;
    int i;

    f = fopen(filename, "wb");
    fprintf(f, "P6\n%d %d\n%d\n", xsize, ysize, 255);

    for (i = 0; i < ysize; i++)
    {
        fwrite(buf + i * wrap, 1, xsize*3, f);
    }

    fclose(f);
}


static void decode(AVCodecContext* dec_ctx, AVFrame* frame, AVPacket* pkt, const char* filename)
{
    struct SwsContext* sws_ctx = NULL;
    char buf[1024];
    int ret;
    int sts;

    ret = avcodec_send_packet(dec_ctx, pkt);
    if (ret < 0)
    {
        fprintf(stderr, "Error sending a packet for decoding\n");
        exit(1);
    }

    //Create SWS Context for converting from decode pixel format (like YUV420) to RGB
    ////////////////////////////////////////////////////////////////////////////
    sws_ctx = sws_getContext(dec_ctx->width,
                             dec_ctx->height,
                             dec_ctx->pix_fmt,
                             dec_ctx->width,
                             dec_ctx->height,
                             AV_PIX_FMT_RGB24,
                             SWS_BICUBIC,
                             NULL,
                             NULL,
                             NULL);

    if (sws_ctx == nullptr)
    {
        return;  //Error!
    }
    ////////////////////////////////////////////////////////////////////////////


    //Allocate frame for storing image converted to RGB.
    ////////////////////////////////////////////////////////////////////////////
    AVFrame* pRGBFrame = av_frame_alloc();

    pRGBFrame->format = AV_PIX_FMT_RGB24;
    pRGBFrame->width = dec_ctx->width;
    pRGBFrame->height = dec_ctx->height;

    sts = av_frame_get_buffer(pRGBFrame, 0);

    if (sts < 0)
    {
        return;  //Error!
    }
    ////////////////////////////////////////////////////////////////////////////


    while (ret >= 0) 
    {
        ret = avcodec_receive_frame(dec_ctx, frame);
        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
        {
            return;
        }
        else if (ret < 0) 
        {
            fprintf(stderr, "Error during decoding\n");
            exit(1);
        }

        printf("saving frame %3d\n", dec_ctx->frame_number);
        fflush(stdout);

        /* the picture is allocated by the decoder. no need to
           free it */
        //snprintf(buf, sizeof(buf), "%s_%03d.pgm", filename, dec_ctx->frame_number);
        //pgm_save(frame->data[0], frame->linesize[0],
        //    frame->width, frame->height, buf);
         
        //Convert from input format (e.g YUV420) to RGB and save to PPM:
        ////////////////////////////////////////////////////////////////////////////
        sts = sws_scale(sws_ctx,                //struct SwsContext* c,
                        frame->data,            //const uint8_t* const srcSlice[],
                        frame->linesize,        //const int srcStride[],
                        0,                      //int srcSliceY, 
                        frame->height,          //int srcSliceH,
                        pRGBFrame->data,        //uint8_t* const dst[], 
                        pRGBFrame->linesize);   //const int dstStride[]);

        if (sts != frame->height)
        {
            return;  //Error!
        }

        snprintf(buf, sizeof(buf), "%s_%03d.ppm", filename, dec_ctx->frame_number);
        ppm_save(pRGBFrame->data[0], pRGBFrame->linesize[0], pRGBFrame->width, pRGBFrame->height, buf);
        ////////////////////////////////////////////////////////////////////////////
    }

    //Free
    sws_freeContext(sws_ctx);
    av_frame_free(&pRGBFrame);
}

int main(int argc, char** argv)
{
    const char* filename, * outfilename;
    const AVCodec* codec;
    AVCodecParserContext* parser;
    AVCodecContext* c = NULL;
    FILE* f;
    AVFrame* frame;
    uint8_t inbuf[INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
    uint8_t* data;
    size_t   data_size;
    int ret;
    AVPacket* pkt;    

    filename = argv[1];
    outfilename = argv[2];

    pkt = av_packet_alloc();
    if (!pkt)
    {
        exit(1);
    }

    //memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE);
    memset(inbuf, 0, sizeof(inbuf));

    codec = avcodec_find_decoder(AV_CODEC_ID_HEVC);
    if (!codec)
    {
        fprintf(stderr, "Codec not found\n");
        exit(1);
    }

    parser = av_parser_init(codec->id);
    if (!parser)
    {
        fprintf(stderr, "parser not found\n");
        exit(1);
    }

    c = avcodec_alloc_context3(codec);
    if (!c)
    {
        fprintf(stderr, "Could not allocate video codec context\n");
        exit(1);
    }

    if (avcodec_open2(c, codec, NULL) < 0)
    {
        fprintf(stderr, "Could not open codec\n");
        exit(1);
    }

    f = fopen(filename, "rb");
    if (!f)
    {
        fprintf(stderr, "Could not open %s\n", filename);
        exit(1);
    }

    frame = av_frame_alloc();
    if (!frame)
    {
        fprintf(stderr, "Could not allocate video frame\n");
        exit(1);
    }

    while (!feof(f))
    {
        /* read raw data from the input file */
        data_size = fread(inbuf, 1, INBUF_SIZE, f);

        if (!data_size)
        {
            break;
        }

        /* use the parser to split the data into frames */
        data = inbuf;
        while (data_size > 0) 
        {
            ret = av_parser_parse2(parser, c, &pkt->data, &pkt->size, data, (int)data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);

            if (ret < 0)
            {
                fprintf(stderr, "Error while parsing\n");
                exit(1);
            }

            data += ret;
            data_size -= ret;


            if (pkt->data) 
            {
                printf("NICE\n");
                decode(c, frame, pkt, outfilename);
            }
        }
    }

    /* flush the decoder */
    decode(c, frame, NULL, outfilename);

    fclose(f);

    av_parser_close(parser);
    avcodec_free_context(&c);
    av_frame_free(&frame);
    av_packet_free(&pkt);

    return 0;
}

使用 OpenCV 显示图像:

显示图像最简单的方法之一是使用OpenCV https://opencv.org/图书馆。

首次设置同时使用 FFmpeg 和 OpenCV 的项目可能具有挑战性。

  • 我们需要 BGR 格式的图像。
  • 要显示图像,请使用:cv::imshow其次是cv::waitKey.

代码示例:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//Use OpenCV for showing the inage
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>


extern "C" {
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
}

#define INBUF_SIZE 1024

//static void pgm_save(unsigned char* buf, int wrap, int xsize, int ysize, char* filename)
//{
//    FILE* f;
//    int i;
//
//    f = fopen(filename, "wb");
//    fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255);
//    for (i = 0; i < ysize; i++)
//        fwrite(buf + i * wrap, 1, xsize, f);
//    fclose(f);
//}


//Save RGB image as PPM file format
//static void ppm_save(unsigned char* buf, int wrap, int xsize, int ysize, char* filename)
//{
//    FILE* f;
//    int i;
//
//    f = fopen(filename, "wb");
//    fprintf(f, "P6\n%d %d\n%d\n", xsize, ysize, 255);
//
//    for (i = 0; i < ysize; i++)
//    {
//        fwrite(buf + i * wrap, 1, xsize*3, f);
//    }
//
//    fclose(f);
//}


static void decode(AVCodecContext* dec_ctx, AVFrame* frame, AVPacket* pkt, const char* filename)
{
    struct SwsContext* sws_ctx = NULL;
    char filename_buf[1024];
    int ret;
    int sts;

    ret = avcodec_send_packet(dec_ctx, pkt);
    if (ret < 0)
    {
        fprintf(stderr, "Error sending a packet for decoding\n");
        exit(1);
    }

    //Create SWS Context for converting from decode pixel format (like YUV420) to BGR
    ////////////////////////////////////////////////////////////////////////////
    sws_ctx = sws_getContext(dec_ctx->width,
                             dec_ctx->height,
                             dec_ctx->pix_fmt,
                             dec_ctx->width,
                             dec_ctx->height,
                             AV_PIX_FMT_BGR24, //For OpenCV, we want BGR pixel format.
                             SWS_BICUBIC,
                             NULL,
                             NULL,
                             NULL);

    if (sws_ctx == nullptr)
    {
        return;  //Error!
    }
    ////////////////////////////////////////////////////////////////////////////


    //Allocate frame for storing image converted to RGB.
    ////////////////////////////////////////////////////////////////////////////
    AVFrame* pBGRFrame = av_frame_alloc();

    pBGRFrame->format = AV_PIX_FMT_BGR24;
    pBGRFrame->width = dec_ctx->width;
    pBGRFrame->height = dec_ctx->height;

    sts = av_frame_get_buffer(pBGRFrame, 0);

    if (sts < 0)
    {
        return;  //Error!
    }
    ////////////////////////////////////////////////////////////////////////////


    while (ret >= 0) 
    {
        ret = avcodec_receive_frame(dec_ctx, frame);
        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
        {
            return;
        }
        else if (ret < 0) 
        {
            fprintf(stderr, "Error during decoding\n");
            exit(1);
        }

        printf("saving frame %3d\n", dec_ctx->frame_number);
        fflush(stdout);

        /* the picture is allocated by the decoder. no need to
           free it */
        //snprintf(buf, sizeof(buf), "%s_%03d.pgm", filename, dec_ctx->frame_number);
        //pgm_save(frame->data[0], frame->linesize[0],
        //    frame->width, frame->height, buf);
         
        //Convert from input format (e.g YUV420) to BGR:
        ////////////////////////////////////////////////////////////////////////////
        sts = sws_scale(sws_ctx,                //struct SwsContext* c,
                        frame->data,            //const uint8_t* const srcSlice[],
                        frame->linesize,        //const int srcStride[],
                        0,                      //int srcSliceY, 
                        frame->height,          //int srcSliceH,
                        pBGRFrame->data,        //uint8_t* const dst[], 
                        pBGRFrame->linesize);   //const int dstStride[]);

        if (sts != frame->height)
        {
            return;  //Error!
        }

        snprintf(filename_buf, sizeof(filename_buf), "%s_%03d.jpg", filename, dec_ctx->frame_number);
        //ppm_save(pBGRFrame->data[0], pBGRFrame->linesize[0], pBGRFrame->width, pBGRFrame->height, buf);        
        ////////////////////////////////////////////////////////////////////////////

        //Use OpenCV for showing the image (and save the image in JPEG format):
        ////////////////////////////////////////////////////////////////////////////
        cv::Mat img = cv::Mat(pBGRFrame->height, pBGRFrame->width, CV_8UC3, pBGRFrame->data[0], pBGRFrame->linesize[0]);    //cv::Mat is OpenCV "thin image wrapper".
        cv::imshow("img", img);
        cv::waitKey(100);   //Wait 100msec (relativly long time - for testing).

        //Save the inage in JPEG format using OpenCV
        cv::imwrite(filename_buf, img);
        ////////////////////////////////////////////////////////////////////////////

    }

    //Free
    sws_freeContext(sws_ctx);
    av_frame_free(&pBGRFrame);
}

int main(int argc, char** argv)
{
    const char* filename, * outfilename;
    const AVCodec* codec;
    AVCodecParserContext* parser;
    AVCodecContext* c = NULL;
    FILE* f;
    AVFrame* frame;
    uint8_t inbuf[INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
    uint8_t* data;
    size_t   data_size;
    int ret;
    AVPacket* pkt;    

    filename = argv[1];
    outfilename = argv[2];

    pkt = av_packet_alloc();
    if (!pkt)
    {
        exit(1);
    }

    //memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE);
    memset(inbuf, 0, sizeof(inbuf));

    codec = avcodec_find_decoder(AV_CODEC_ID_HEVC);
    if (!codec)
    {
        fprintf(stderr, "Codec not found\n");
        exit(1);
    }

    parser = av_parser_init(codec->id);
    if (!parser)
    {
        fprintf(stderr, "parser not found\n");
        exit(1);
    }

    c = avcodec_alloc_context3(codec);
    if (!c)
    {
        fprintf(stderr, "Could not allocate video codec context\n");
        exit(1);
    }

    if (avcodec_open2(c, codec, NULL) < 0)
    {
        fprintf(stderr, "Could not open codec\n");
        exit(1);
    }

    f = fopen(filename, "rb");
    if (!f)
    {
        fprintf(stderr, "Could not open %s\n", filename);
        exit(1);
    }

    frame = av_frame_alloc();
    if (!frame)
    {
        fprintf(stderr, "Could not allocate video frame\n");
        exit(1);
    }

    while (!feof(f))
    {
        /* read raw data from the input file */
        data_size = fread(inbuf, 1, INBUF_SIZE, f);

        if (!data_size)
        {
            break;
        }

        /* use the parser to split the data into frames */
        data = inbuf;
        while (data_size > 0) 
        {
            ret = av_parser_parse2(parser, c, &pkt->data, &pkt->size, data, (int)data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);

            if (ret < 0)
            {
                fprintf(stderr, "Error while parsing\n");
                exit(1);
            }

            data += ret;
            data_size -= ret;


            if (pkt->data) 
            {
                printf("NICE\n");
                decode(c, frame, pkt, outfilename);
            }
        }
    }

    /* flush the decoder */
    decode(c, frame, NULL, outfilename);

    fclose(f);

    av_parser_close(parser);
    avcodec_free_context(&c);
    av_frame_free(&frame);
    av_packet_free(&pkt);

    return 0;
}

示例输出:

output_001.jpg:
enter image description here

output_002.jpg:
enter image description here

output_003.jpg:
enter image description here

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 FFmpeg 在 C++ 中将 AVFrame 保存为图像 的相关文章

  • 电话号码的正则表达式,不允许全零

    需要您的正则表达式帮助 我当前的正则表达式是 d 8 最小长度为 8 不允许包含字母 特殊字符和空格 我还想禁止全零 如 00000000 Thanks 该模式应该可以满足您的需求 0 d 8 The 0 部分是负前瞻 将阻止仅输入零 Ex
  • setContextProperty 和对象的 setProperty 之间的区别

    我现在真的很困惑 有什么区别 QQmlApplicationEngine engine engine rootContext setContextProperty myObject userData and object gt setPro
  • 起订量要求?违背了目的?

    是否需要虚拟化您想要模拟的所有属性访问器就违背了模拟的目的 我的意思是 如果我必须修改我的对象并虚拟化我想要模拟的每个访问器 我难道不能继承我的类并自己模拟它吗 你的问题非常有效 但如果你仔细想想 没有其他方法可以模拟课程 如果你采用一个接
  • Accept() 是线程安全的吗?

    我目前正在用 C 语言为我正在做的课程编写一个简单的网络服务器 我们的一项要求是实现一个线程池来使用 pthread 处理连接 我知道我将如何粗略地执行此操作 在主线程中调用accept并将文件描述符传递给freee线程 但是我的朋友建议了
  • 访问“if”语句之外的变量

    我怎样才能使insuranceCost以外可用if陈述 if this comboBox5 Text Third Party Fire and Theft double insuranceCost 1 在 if 语句之外定义它 double
  • 如何在 Asp.net Gridview 列中添加复选框单击事件

    我在 asp 中有一个 gridview 其中我添加了第一列作为复选框列 现在我想选择此列并获取该行的 id 值 但我不知道该怎么做 这是我的 Aspx 代码
  • Paradox 表 - Oledb 异常:外部表不是预期的格式

    我正在使用 Oledb 从 Paradox 表中读取一些数据 我遇到的问题是 当我将代码复制到控制台应用程序时 代码可以工作 但在 WinForms 中却不行 两者都以 x86 进行调试 我实际上只是复制代码 在 WinForms 应用程序
  • 有没有办法使用 i387 fsqrt 指令获得正确的舍入?

    有没有办法使用 i387 fsqrt 指令获得正确的舍入 除了改变精确模式在 x87 控制字中 我知道这是可能的 但这不是一个合理的解决方案 因为它存在令人讨厌的重入型问题 如果 sqrt 操作中断 精度模式将出错 我正在处理的问题如下 x
  • 方法“xxx”不能是事件的方法,因为该类派生的类已经定义了该方法

    我有一个代码 public class Layout UserControl protected void DisplayX DisplayClicked object sender DisplayEventArgs e CurrentDi
  • 序列化和反序列化 Visual Studio 解决方案文件 - 或以编程方式编辑?

    我想以编程方式添加和删除项目 解决方案文件夹和其他项目 例如解决方案的资源文件 但我不确定最好的方法是什么 对于那些不知道的人 高度简化 解决方案文件 sln 通常如下所示 Microsoft Visual Studio Solution
  • 默认值 C# 类 [重复]

    这个问题在这里已经有答案了 我在控制器中有一个函数 并且我收到表单的信息 我有这个代码 public Actionresult functionOne string a string b string c foo 我尝试将其转换为类似的类
  • 指向字节数组的指针

    由于 Misra C 的要求 我的一位同事想要使用指针声明 但我遇到了一些问题 Misra 安全关键指南 不会让我们纯粹的程序员使用指针 但会让我们对数组字节进行操作 他打算获取一个指向字节数组的指针 因此我们不会在堆栈上传递实际的数组 T
  • 编译器错误“错误:在文件范围内可变地修改了‘字符串’”

    考虑 include
  • 无法加载文件或程序集“EntityFramework,版本=6.0.0.0”

    我究竟做错了什么 我该如何解决这个问题 我有一个包含多个项目的解决方案 它是一个 MVC NET 4 5 Web 应用程序 在调试模式下启动后调用其中一个项目时 出现此错误 导致此错误的项目具有以下参考 两个都是版本6 0 0 0 应用程序
  • 从事务范围调用 WCF 服务方法

    我有这样的代码 using TransactionScope scope TransactionScopeFactory CreateTransactionScope some methodes calls for which scope
  • 错误左值需要作为赋值C++的左操作数

    整个程序基本上只允许用户移动光标 如果用户位于给定的坐标范围 2 2 内 则允许用户键入输入 我刚刚提供了一些我认为足以解决问题的代码 我不知道是什么导致了这个问题 你能解释一下为什么会发生吗 void goToXY int int 创建一
  • 设计 Javascript 前端 <-> C++ 后端通信

    在我最近的将来 我将不得不制作一个具有 C 后端和 Web 前端的系统 要求 目前 我对此了解不多 我认为前端将触发数据传输 而不是后端 所以不需要类似 Comet 的东西 由于在该领域的经验可能很少 我非常感谢您对我所做的设计决策的评论
  • 如何访问窗口?

    我正在尝试使用其句柄访问特定窗口 即System IntPtr value Getting the process of Visual Studio program var process Process GetProcessesByNam
  • #pragma pack(16) 和 #pragma pack(8) 的效果总是相同吗?

    我正在尝试使用来对齐数据成员 pragma pack n http msdn microsoft com en us library 2e70t5y1 28v vs 100 29 aspx 以下面为例 include
  • 在 C++ 和 Windows 中使用 XmlRpc

    我需要在 Windows 平台上使用 C 中的 XmlRpc 尽管我的朋友向我保证 XmlRpc 是一种 广泛可用的标准技术 但可用的库并不多 事实上 我只找到一个库可以在 Windows 上执行此操作 另外一个库声称 您必须做很多工作才能

随机推荐

  • JSF 2.2 - 文件上传不适用于 Ajax。表单的 enctype 似乎不正确(仅通过 AJAX)

    尝试实现 JSF 2 2 示例 我有以下代码
  • Java中有二进制文字吗?

    我想用二进制文字来声明我的整数 在Java中可以吗 在 JDK 7 中可以 int binaryInt 0b101 只需在您的号码前添加前缀即可0b
  • HornetQ 重启后不会保留消息

    我使用 HornetQ 作为队列提供程序 因为它具有持久性功能 但是 在我重新启动应用程序后 队列中的所有消息都会丢失 也许是配置问题 这是代码 Step 1 Create the Configuration and set the pro
  • Excel VBA 禁用快捷键有时会禁用数据输入

    为什么我的代码会随机偶尔禁用数据输入 但即使我隔离它并删除所有其他宏 大多数时间仍然可以工作 该代码禁用了几乎所有快捷键 但不应影响简单的数据输入 Option Explicit Rem mod ShortCutKeys Ctrl Alt
  • WebGet 的 WCF 响应格式

    WCF 为 ServiceContract 中的 WebGet 注释中的 ResponseFormat 属性提供了两个选项 ServiceContract public interface IService1 OperationContra
  • Drupal 6:打印纯正的主链接和所有子链接

    世界上怎么可能 我发誓 我读了相当于三本百科全书的书 却毫无用处 我已经尝试过区域 page tpl php 和块内的解决方案 他们都没有给我我需要的东西 而且我知道还有很多其他人也需要这个 我得出的结论是 我想打印出 page tpl p
  • 模糊除 div 之外的整个页面

    我有以下代码 除了中心的红色 div 之外 我需要将所有内容都模糊化 我尝试使用filter none or filter blur 0 但这行不通 如何模糊背景中除红色 div 之外的所有内容 编辑 我也尝试将它与 z index 一起使
  • iOS 11:蜂窝信号强度

    我正在获取蜂窝信号强度 iOS let statusBarView UIApplication shared value forKey statusBar as UIView if let foregroundView statusBarV
  • Spark:当我在 Range 中使用累加器时,它无法正常工作

    我不明白为什么 Spark 没有正确更新我的累加器 object AccumulatorsExample extends App val acc sc accumulator 0L acc sc range 0 20000 step 25
  • 在 C++17 中使用 const std::string& 参数是否有意义?

    通过得到string view在 C 17 中 我们得到了传递两者的廉价方法std string and char 不拥有字符串所有权并避免制作临时副本的函数 通过使用std string按值传递和std move我们可以显式且快速地传递右
  • 指定 NVCC 用于编译主机代码的编译器

    运行 nvcc 时 它始终使用 Visual C 编译器 cl exe 我怎样才能让它使用GCC编译器 设置CC环境变量到gcc没有修复它 我在可执行文件帮助输出中也找不到任何选项 在 Windows 上 NVCC 仅支持 Visual C
  • 为什么某些基本类型在 TypeScript 中不能传递赋值——它们是否按预期运行?

    本来想在 TypeScript 存储库的问题跟踪器中打开一个错误报告 我意识到我问了太多问题 所以我在错误报告之前在这里打开一个问题 带有相关代码的 Playground 链接 https www typescriptlang org pl
  • SecurityException - GoogleCertificatesRslt:不允许

    我们有一个拥有数百万用户的应用程序 在过去的一周里 我们从 Firebase Crashlytics 的旧版本应用程序中收到了大约 30 个 速度警报 其中包含如下错误消息 Fatal Exception java lang Securit
  • 使用按钮在打印机中打印 jLabel 的图标[关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 我有一个带有图标的 jLabel 我想使用按钮在打印机 佳能 惠普 爱普生任何打印机 中打印该图标 我怎样才能做到这一点 有什么有用的代码
  • 在 MS Access 上与多个程序员一起工作

    您是否建议与多个程序员一起开发 MS Access 应用程序 我们的一款 MS Access 应用程序已经发展到了这样的程度 一名程序员无法在要求的时间范围内处理大量的更改 错误修复 和新功能 我们正在尝试使用 VBA 中未记录的 Save
  • 如何缩小自定义 Skobbler 离线地图应用程序的大小

    我正在将 Skobbler 地图集成到我的 iOS 应用程序中 目前 该应用程序的大小为 160Mb 这太大了 但我注意到已经集成了一堆地图 我想删除所有地图并让用户下载他需要的地图 现在 当我包含 SKMaps framework 时 其
  • Typescript 编译器突然开始生成错误

    我正在开发一个 Angular 2 项目 当我尝试运行打字稿编译器时 突然开始出现很多很多错误 有人可以建议从哪里开始搜索吗 我没有故意更改任何基本内容 即使当我从存储库克隆一个新副本时 错误仍然存 在 错误如下 node modules
  • Facebook SDK 3.1 - 错误:HTTP 状态代码:400

    自昨天 10 月 9 日起我已更新至 facebook SDK 3 1 后 我收到以下错误 错误 HTTP 状态代码 400 但就与 Facebook 连接而言 一切功能都完全正常 每次在我的应用程序上启动 Facebook 会话时 我都会
  • Rails 3 和图形数据库

    在 Postgresql 上运行的 Rails 3 应用程序需要切换到图形数据库才能成长 它们有很多 并且都提供不同类型的 API 主要是 REST 我深受启发talks http nosql mypopescu com post 3429
  • 如何使用 FFmpeg 在 C++ 中将 AVFrame 保存为图像

    在我的项目中 我想保存 Hevc 文件中的一帧 我在源代码中使用 FFmpeg 来解码 Hevc 文件并获取 AVFrame 和 AVCodecContext 我需要的是将框架保存为图片 全彩 我尝试将其保存为 pgm 文件 因此图片只是灰