ffmpeg+D3D实现的MFC音视频播放器,支持录像、截图、音视频播放、码流信息显示等功能

一、简介

    本播放器是在vs2019下开发,通过ffmpeg实现拉流解码功能,通过D3D实现视频的渲染功能。截图功能采用libjpeg实现,可以截取jpg图片,图片的默认保存路径是在C:\MYRecPath中。录像功能采用封装好的类Mp4Record实现,在Mp4Record类中主要还是采用ffmpeg的相关函数方法进行mp4视频的录制。音频的播放采用DirectSound实现,将ffmpeg解码后的音频数据存储到DirectSound的buffer中,再调用DirectSound的play实现对音频的播放功能。码流信息的显示,通过D3D的文本绘制实现。本播放器提供源码下载,直接下载请点击最后的下载链接。

二、界面展示

在这里插入图片描述

三、相关代码

开始播放

int CVideoPlayer::StartPlay(const char* sUrl)
{
    m_bStop = false;
    m_nVideoIndex = -1;
    m_nAudioIndex = -1;
    int i = 0, res = 0,  nValue = 0;
    char buf[64] = { 0 };
    m_bPlaying = false;
    AVStream* in_stream;
    

    _snprintf_s(m_sConnectUrl, sizeof(m_sConnectUrl), sizeof(m_sConnectUrl) - 1, "%s", sUrl);

    //av_register_all();
    avformat_network_init();

    AVDictionary* optionsDict = nullptr;

    av_dict_set(&optionsDict, "rtsp_transport", "tcp", 0);
    av_dict_set(&optionsDict, "stimeout", "5000000", 0);
    av_dict_set(&optionsDict, "buffer_size", "8192000", 0);
    av_dict_set(&optionsDict, "recv_buffer_size", "8192000", 0);

    m_lastReadPacktTime = av_gettime();
    m_pAVFmtCxt = avformat_alloc_context();
    m_pAVFmtCxt->interrupt_callback.opaque = this;
    m_pAVFmtCxt->interrupt_callback.callback = decodeInterruptCb;

    res = avformat_open_input(&m_pAVFmtCxt, m_sConnectUrl, NULL, &optionsDict);
    if (res < 0)
    {
        myprint("avformat_open_input fail: %d", res);
        return -1;
    }
    
    if (!m_pAVFmtCxt)
    {
        return -1;
    }

    m_pAVFmtCxt->probesize = 100 * 1024;    
    m_pAVFmtCxt->max_analyze_duration = 1 * AV_TIME_BASE; 

    res = avformat_find_stream_info(m_pAVFmtCxt, NULL);
    if (res < 0)
    {
        myprint("error %x in avformat_find_stream_info\n", res);
        return -1;
    }

    av_dump_format(m_pAVFmtCxt, 0, m_sConnectUrl, 0);

    for (i = 0; i < m_pAVFmtCxt->nb_streams; i++)
    {
        if (m_pAVFmtCxt->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
        {
            m_nVideoIndex = i;
        }
        else if (m_pAVFmtCxt->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
            m_nAudioIndex = i;
        }

        myprint("m_pAVFmtCxt->streams[i]->codec->codec_type:%d", m_pAVFmtCxt->streams[i]->codecpar->codec_type);

    }

    //videoindex not find
    if (m_nVideoIndex == -1)
    {
        myprint("can't find video stream.");
        return -1;
    }

    m_pCodec = avcodec_find_decoder(m_pAVFmtCxt->streams[m_nVideoIndex]->codecpar->codec_id);
    if (!m_pCodec)
    {
        myprint("video decoder not found\n");
        return -1;
    }
    if (m_bSupportAudio && m_nAudioIndex != -1)
    {
        myprint("start audio decoder \n");

        if (!m_pAudioCodecCxt)
            m_pAudioCodecCxt = avcodec_alloc_context3(NULL);
        auto pAudioCodecpar = m_pAVFmtCxt->streams[m_nAudioIndex]->codecpar;
        avcodec_parameters_to_context(m_pAudioCodecCxt, pAudioCodecpar);

        m_pAudioCodec = avcodec_find_decoder(pAudioCodecpar->codec_id);

        if (nullptr == m_pAudioCodec || nullptr == m_pAudioCodecCxt)
        {
            myprint("audio decoder not found\n");
            return -1;
        }

        m_pSwrContext = swr_alloc_set_opts(0,                                 
            av_get_default_channel_layout(m_channels_play),
            AV_SAMPLE_FMT_S16,                         
            m_nSampleRate,                     
            av_get_default_channel_layout(m_pAudioCodecCxt->channels),
            m_pAudioCodecCxt->sample_fmt,       
            m_pAudioCodecCxt->sample_rate,      
            0,
            0);
        auto ret = swr_init(m_pSwrContext);
        if (ret < 0)
        {
            myprint("Failed to swr_init(pSwrContext);");
            return -1;
        }

        if (InitDirectSound() == FALSE)
            m_bSupportAudio = false;
    }

    m_CodecId = m_pCodec->id;
    if(!m_pCodecCxt)
        m_pCodecCxt = avcodec_alloc_context3(NULL);
    avcodec_parameters_to_context(m_pCodecCxt, m_pAVFmtCxt->streams[m_nVideoIndex]->codecpar);
    if (m_pCodecCxt)
    {
        if (m_pCodecCxt->width == 0 || m_pCodecCxt->height == 0)
        {
            myprint("m_pCodecCxt->width:%d, m_pCodecCxt->height:%d", m_pCodecCxt->width, m_pCodecCxt->height);
            return -1;
        }
    }
    else
        return -1;

    AVCodecContext* temp_codecctx = m_pCodecCxt;
    memcpy(temp_codecctx, m_pCodecCxt, sizeof(m_pCodecCxt));
    if (m_pCodecCxt->codec_type == AVMEDIA_TYPE_VIDEO)
    {
        myprint("Soft Solution");
        avcodec_close(m_pCodecCxt);
        m_pCodecCxt = temp_codecctx;
        m_pCodecCxt->thread_count = 4;
        if (m_Dxva2D3DRender.InitD3DRender(m_showWnd, m_pCodecCxt->width, m_pCodecCxt->height) == false)
        {
            myprint("InitD3DRender fail");
        }
        m_pOutBuffer = (uint8_t*)av_malloc(av_image_get_buffer_size(AV_PIX_FMT_YUV420P, m_pCodecCxt->width, m_pCodecCxt->height, 1));
        if (nullptr == m_pOutBuffer)
            return -1;

        av_image_fill_arrays(m_pFrameBGR->data, m_pFrameBGR->linesize, m_pOutBuffer, AV_PIX_FMT_YUV420P, m_pCodecCxt->width, m_pCodecCxt->height, 1); //填充AVFrame数据缓冲
        m_pImgConvertCtx = sws_getContext(m_pCodecCxt->width, m_pCodecCxt->height, m_pCodecCxt->pix_fmt, m_pCodecCxt->width, m_pCodecCxt->height, AV_PIX_FMT_YUV420P, SWS_FAST_BILINEAR, NULL, NULL, NULL);
        if (nullptr == m_pImgConvertCtx)
            return -1;

      
        m_nActualWidth = m_pCodecCxt->width;
        m_nActualHeight = m_pCodecCxt->height;

        res = avcodec_open2(m_pCodecCxt, m_pCodec, NULL);
        if (res < 0)
        {
            myprint("avcodec_open2 video fail  error:%x", res);
            return -1;
        }
    }

    if (m_bSupportAudio && m_pAudioCodecCxt)
    {
        if (m_pAudioCodecCxt->codec_type == AVMEDIA_TYPE_AUDIO)
        {
            res = avcodec_open2(m_pAudioCodecCxt, m_pAudioCodec, NULL);
            if (res < 0)
            {
                myprint("avcodec_open2 audio fail  error:%x", res);
                avcodec_close(m_pAudioCodecCxt);
                return -1;
            }

            myprint("===Audio Message===");
            myprint(" bit_rate = %d ", m_pAudioCodecCxt->bit_rate);
            myprint(" sample_rate = %d ", m_pAudioCodecCxt->sample_rate);
            myprint(" channels = %d ", m_pAudioCodecCxt->channels);
            myprint(" code_name = %s ", m_pAudioCodecCxt->codec->name);
            myprint(" block_align = %d ", m_pAudioCodecCxt->block_align);
        }
    }

    m_pDecodeThread = (my_thread_t*)my_malloc(sizeof(my_thread_t));
    if (nullptr != m_pDecodeThread)
    {
        m_bDecodeThreadRun = true;
        res = my_thread_create(m_pDecodeThread, ThreadDecode, this);
        if (res == -1)
        {
            myprint("my_thread_create ThreadDecode failed  res:%x", res);
            return -1;
        }
    }

    return 0;
}

停止播放

void CVideoPlayer::StopPlay()
{
    m_bPlaying = false;
    m_CaptureAudio.SetGrabAudioFrames(FALSE, NULL);
    m_CaptureAudio.Close();

    m_bStopAudio = true;
    while (!m_AudioPlayQue.empty())
    {
        m_AudioPlayQue.pop();
    }
    while (!m_AudioTalkQue.empty())
    {
        EnterCriticalSection(&m_talklock);
        m_AudioTalkQue.pop();
        LeaveCriticalSection(&m_talklock);
    }

    m_bDecodeThreadRun = false;

    if (m_pDecodeThread)
    {
        my_thread_join(m_pDecodeThread);
        my_free(m_pDecodeThread);
        m_pDecodeThread = nullptr;
    }

    if (m_pAudioPlayThread) {
        SetEvent(m_event);
        if (m_pAudioPlayThread->handle) {
            my_thread_join(m_pAudioPlayThread);
            m_pAudioPlayThread->handle = nullptr;
        }
    }

    if (m_pDSBuffer8)
    {
        m_pDSBuffer8->Stop();
        m_pDSBuffer8->Restore();
    }

    m_Dxva2D3DRender.UnitD3DRender();

    if (m_pCodecCxt)
    {
        avcodec_close(m_pCodecCxt);
    }

    if (m_pAudioCodecCxt)
    {
        avcodec_close(m_pAudioCodecCxt);
    }

    if (m_pSwrContext)
    {
        swr_free(&m_pSwrContext);
        m_pSwrContext = nullptr;
    }

    if (m_pAVFmtCxt) {
        avformat_close_input(&m_pAVFmtCxt);
        avformat_free_context(m_pAVFmtCxt);
        m_pAVFmtCxt = nullptr;
    }

}

解码线程

void CVideoPlayer::DecodeAndShow()
{
    if (m_pAVFmtCxt == nullptr || m_pCodecCxt == nullptr)
        return;

    AVPacket pkt = { 0 };
    m_bPlaying = true;
    uint8_t* pBuffer;
    bool bEnoughSpace = true;
    int nTimeCnt = 0;
    int res = 0;
    struct SwsContext* img_convert_ctx = nullptr;
    int nRectDrawWait = 0;
    bool bRecordLastIFrame = false;
    int num_av_read_frame_err = 0;
    int num_stream_index_err = 0;
    uint8_t * outData[2] = {0};
    outData[0] = (uint8_t*)av_malloc(1152 * 8);
    outData[1] = (uint8_t*)av_malloc(1152 * 8);

    uint8_t* pktdata;
    int pktsize;
    int len = 0;
    bool bPushAudioToQueue = false;
    m_bStopAudio = false;
    CRect ShowRect;

    AVFrame* pAvFrame = av_frame_alloc();
    if (nullptr == pAvFrame)
        return;

    AVFrame* pFrameRGB = av_frame_alloc();
    if (nullptr == pFrameRGB)
        return;

    int numBytes = av_image_get_buffer_size(AV_PIX_FMT_RGB24, m_pCodecCxt->width, m_pCodecCxt->height, 1);
    pBuffer = (uint8_t*)av_malloc(numBytes);
    if (nullptr == pBuffer)
        return;

    av_image_fill_arrays(pFrameRGB->data,pFrameRGB->linesize, pBuffer, AV_PIX_FMT_RGB24, m_pCodecCxt->width, m_pCodecCxt->height, 1);
    img_convert_ctx = sws_getCachedContext(img_convert_ctx, m_pCodecCxt->width, m_pCodecCxt->height,
        m_pCodecCxt->pix_fmt, m_pCodecCxt->width, m_pCodecCxt->height, AV_PIX_FMT_RGB24, SWS_FAST_BILINEAR/*SWS_BICUBIC*/, NULL, NULL, NULL);


    //Audio
    if (m_bSupportAudio && m_pAudioPlayThread)
    {
        res = my_thread_create(m_pAudioPlayThread, ThreadAudioPlay, this);
        if (res < 0)
            myprint("my_thread_create ThreadAudioPlay fail");
    }

    while (m_bDecodeThreadRun && !m_bQuit)
    {
        if (m_bPause)
        {
            Sleep(100);
            continue;
        }

        {
            if (m_bReconnect)
            {
                myprint("bReConnect = true, break");
                break;
            }
        }

        m_lastReadPacktTime = av_gettime();
        if (av_read_frame(m_pAVFmtCxt, &pkt) >= 0)
        {
            num_av_read_frame_err = 0;

            if (pkt.stream_index == m_nVideoIndex || pkt.stream_index == m_nAudioIndex)
            {
                if (m_bRecord)//Record
                {
                    if (nTimeCnt != 0 || (!bRecordLastIFrame && pkt.flags == AV_PKT_FLAG_KEY)) {
                        if (m_sRecPath[0] != '\0' && nTimeCnt++ % 200 == 0)
                        {
                            bEnoughSpace = CheckRemainSpace(m_sRecPath);
                            if (bEnoughSpace == true)
                            {
                                myprint("bEnoughSpace = true");
                            }
                            else
                                myprint("bEnoughSpace = false");
                        }

                        m_nRecordCurrentTime = time(NULL);
                        if ((m_nRecordCurrentTime - m_nRecordStartTime) >= (m_nRecordTime * 60))
                        {
                            myprint("Record Finsh!");
                            stopRecord();
                        }
                        else if (bEnoughSpace == false)
                        {
                            myprint("bEnoughSpace == false");
                            stopRecord();
                        }
                        else
                        {
                            AVPacket* pPkt = av_packet_clone(&pkt);
                            m_mp4Recorder.saveOneFrame(*pPkt, m_CodecId);
                            av_packet_free(&pPkt);
                        }
                    }
                    bRecordLastIFrame = pkt.flags == AV_PKT_FLAG_KEY;
                }
                else
                    nTimeCnt = 0;
            }

            
            if (pkt.stream_index == m_nVideoIndex)
            {
                num_stream_index_err = 0;
                nTimeCnt = 0;

                if (pkt.flags == 1)
                    bPushAudioToQueue = true;
                if (nullptr == m_pCodecCxt || nullptr == pAvFrame) {
                    myprint("m_pCodecCxt == NULL || pAvFrame == NULL");
                    break;
                }
                int gotvframe = 0;
                auto sd_ret = avcodec_send_packet(m_pCodecCxt, &pkt);
                if (sd_ret != 0 && sd_ret != AVERROR(EAGAIN)) {
                    myprint("avcodec_send_packet err, rt=%d", sd_ret);
                    enableReConnect();
                }
                else {
                    while (gotvframe == 0 && !m_bQuit) {
                        gotvframe = avcodec_receive_frame(m_pCodecCxt, pAvFrame);
                        if (gotvframe == 0)
                        {
                            try
                            {
                                GetShowRectSize(&ShowRect);
                            }
                            catch (const std::exception&)
                            {
                                myprint("GetClientRect throw, error");
                                break;
                            }

                            m_nCurPKSize = pkt.size;   
                            SetStreamInfoToD3d();

                            if (pAvFrame->width != m_nActualWidth || pAvFrame->height != m_nActualHeight)
                            {
                                myprint("video size change reconnect...");
                                enableReConnect();
                                m_nActualWidth = pAvFrame->width;
                                m_nActualHeight = pAvFrame->height;
                                av_packet_unref(&pkt);
                                continue;
                            }

                            if (m_pImgConvertCtx && m_pFrameBGR && m_pOutBuffer && pAvFrame)
                            {
                                sws_scale(m_pImgConvertCtx, (const uint8_t* const*)pAvFrame->data, pAvFrame->linesize, 0,
                                    m_pCodecCxt->height, m_pFrameBGR->data, m_pFrameBGR->linesize);

                                {                                    
                                    try
                                    {
                                        int re = 5;
                                        for (int i = 0; m_bPlaying && re == 5 && i < 10; ++i) {     // LockRect失败时重复尝试,最多10次
                                            re = m_Dxva2D3DRender.D3DSoftDisplayFrame(m_pOutBuffer, pAvFrame->width, pAvFrame->height, ShowRect);
                                            Sleep(1);
                                        }
                                    }
                                    catch (int re)
                                    {
                                        myprint("m_Dxva2D3DRender.InitD3DRender again");
                                        if (m_Dxva2D3DRender.InitD3DRender(m_showWnd, m_pCodecCxt->width, m_pCodecCxt->height) == false)
                                        {
                                            myprint("m_Dxva2D3DRender.InitD3DRender again fail");
                                            av_packet_unref(&pkt);
                                            continue;
                                        }
                                    }
                                }                                
                            }
                            if (m_bCapture /*&& pkt.flags == 1*/ && img_convert_ctx)
                            {
                                sws_scale(img_convert_ctx, (const uint8_t* const*)pAvFrame->data, 
                                         pAvFrame->linesize, 0, m_pCodecCxt->height,
                                    pFrameRGB->data, pFrameRGB->linesize);
                                SaveIFrameImage(pFrameRGB->data[0], m_pCodecCxt->width, m_pCodecCxt->height);
                                m_bCapture = false;
                            }
                            
                        }
                    }
                }
            }
            else if (pkt.stream_index == m_nAudioIndex)
            {
                num_stream_index_err = 0;
                if (m_bSupportAudio) {
                    pktdata = pkt.data;
                    pktsize = pkt.size;

                    if (pktsize > 0)
                    {
                        int gotframe = 0;
                        if (nullptr == m_pAudioCodecCxt || nullptr == pAvFrame) {
                            myprint("m_pAudioCodecCxt == NULL || pAvFrame == NULL");
                            break;
                        }
                        len = avcodec_send_packet(m_pAudioCodecCxt, &pkt);
                        if (len != 0 && len != AVERROR(EAGAIN))
                        {
                            pktsize = 0;
                            myprint("avcodec_send_packet len < 0");
                            break;
                        }
                        auto data_size = av_get_bytes_per_sample(m_pAudioCodecCxt->sample_fmt); 
                        if (data_size < 0) {
                            myprint("Failed to calculate data size\n");
                            break;
                        }
                        while (gotframe == 0 && !m_bQuit) {
                            gotframe = avcodec_receive_frame(m_pAudioCodecCxt, pAvFrame);
                            if (!gotframe)
                            {

                                if (bPushAudioToQueue == true && m_bEnableAudio && !m_bStopAudio)
                                {
                                    audio_frame_t audioFrame;
                                    numBytes = av_get_bytes_per_sample(AV_SAMPLE_FMT_S16);
                                    auto dstNbSamples = av_rescale_rnd(pAvFrame->nb_samples,
                                        m_src_sample_rate,
                                        pAvFrame->sample_rate,
                                        AV_ROUND_ZERO);
                                      
                                    int data_size = 0;
                                    try
                                    {
                                        auto nb = swr_convert(m_pSwrContext,
                                            (uint8_t**)outData,
                                            dstNbSamples,
                                            (const uint8_t**)pAvFrame->data,
                                            pAvFrame->nb_samples);
                                        data_size = av_samples_get_buffer_size(nullptr, m_channels_play, nb, AV_SAMPLE_FMT_S16, 1);
                                    }
                                    catch (const std::exception&)
                                    {
                                        m_bSupportAudio = false;
                                        myprint("swr_convert throw err, set m_bSupportAudio false");
                                        continue;
                                    }
                                    
                                    int copy_size = 0; 
                                    int copy_ptr = 0;                              
                                    for (int isub = data_size; isub > 0; isub -= copy_size) {
                                        if (isub > m_audio_buffer_notify_size) {
                                            copy_size = m_audio_buffer_notify_size;
                                            copy_ptr = data_size - isub;
                                        }
                                        else
                                            copy_size = isub;
                                        audioFrame.data_size = copy_size;
                                        memcpy(audioFrame.data, outData[0] + copy_ptr, copy_size);
                                        EnterCriticalSection(&m_lock);
                                        m_AudioPlayQue.push(audioFrame);
                                        LeaveCriticalSection(&m_lock);
                                    }
                                }

                            }
                        }
                    }
                }
            }
            else if (++num_stream_index_err > 20) {
                myprint("pkt.stream_index unfind, %d",pkt.stream_index);
                enableReConnect();
            }

            av_packet_unref(&pkt);
        }
        else {
            if (++num_av_read_frame_err > 10) {
                myprint("num_av_read_frame_err is more than 10");
                enableReConnect();
            }
        }
    }
    if (m_bDecodeThreadRun) {
        myprint("m_bDecodeThreadRun is true");
        enableReConnect();
    }

    if (pAvFrame)
        av_free(pAvFrame);

    if (pFrameRGB)
        av_free(pFrameRGB);

    if (pBuffer)
        av_free(pBuffer);

    if (img_convert_ctx)
        sws_freeContext(img_convert_ctx);

    if (outData[0] && outData[1])
    {
        av_free(outData[0]);
        av_free(outData[1]);
        outData[0] = 0;
        outData[1] = 0;
    }
}

四、相关下载

链接: 可执行程序下载

链接: 源码下载

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/915225.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

LLM在Transformer上的改动

LLM在Transformer上的改动 1.multi-head共享1.1BERT的逻辑1.2multi-head共享 2.attention的前后网络2.1传统Transformer&#xff1a;2.2GPTJ结构&#xff1a; 3.归一化层的位置&#xff08;LayerNorm&#xff09;4.归一化层函数的选择4.1LayerNorm4.2RMSNorm 3.激活函数4.LLama…

git命令及原理

git: 目录则被称之为“树” 文件被称作 Blob 对象. git help <command>: 获取 git 命令的帮助信息 git init: 创建一个新的 git 仓库&#xff0c;其数据会存放在一个名为 .git 的目录下 git status: 显示当前的仓库状态 git add <filename>: 添加文件到暂存区 git …

scala 迭代更新

在Scala中&#xff0c;迭代器&#xff08;Iterator&#xff09;是一种用于遍历集合&#xff08;如数组、列表、集合等&#xff09;的元素而不暴露其底层表示的对象。迭代器提供了一种统一的方法来访问集合中的元素&#xff0c;而无需关心集合的具体实现。 在Scala中&#xff0c…

快速掌握——python类 封装[私有属性方法]、继承【python进阶】(内附代码)

1.类的定义 与 实例化对象 在python中使用class关键字创建一个类。 举例子 class Stu(object):id 1001name 张三def __init__(self):passdef fun1(self):pass# 实例化对象 s1 Stu() s2 Stu() print(s1.name) print(s2.name) 第一个方法 __init__是一种特殊的方法&#x…

51c自动驾驶~合集10

我自己的原文哦~ https://blog.51cto.com/whaosoft/11638131 #端到端任务 说起端到端&#xff0c;每个从业者可能都觉得会是下一代自动驾驶量产方案绕不开的点&#xff01;特斯拉率先吹响了方案更新的号角&#xff0c;无论是完全端到端&#xff0c;还是专注于planner的模型&a…

BFS 算法专题(三):BFS 解决边权为 1 的最短路问题

目录 1. 迷宫中离入口最近的出口 1.1 算法原理 1.2 算法代码 2. 最小基因变化 ★★★ 2.1 算法原理 2.2 算法代码 3. 单词接龙 3.1 算法原理 3.2 算法代码 4. 为高尔夫比赛砍树 (hard) 4.1 算法原理 4.2 算法代码 1. 迷宫中离入口最近的出口 . - 力扣&#xff08;…

Flink_DataStreamAPI_执行环境

DataStreamAPI_执行环境 1创建执行环境1.1getExecutionEnvironment1.2createLocalEnvironment1.3createRemoteEnvironment 2执行模式&#xff08;Execution Mode&#xff09;3触发程序执行 Flink程序可以在各种上下文环境中运行&#xff1a;我们可以在本地JVM中执行程序&#x…

46.第二阶段x86游戏实战2-拆解自动打怪流程

免责声明&#xff1a;内容仅供学习参考&#xff0c;请合法利用知识&#xff0c;禁止进行违法犯罪活动&#xff01; 本次游戏没法给 内容参考于&#xff1a;微尘网络安全 本人写的内容纯属胡编乱造&#xff0c;全都是合成造假&#xff0c;仅仅只是为了娱乐&#xff0c;请不要…

解决C盘空间不足的三种方案

方案一&#xff1a;网上盛传的C盘磁盘碎片整理&#x1f9e9;&#xff08;原理&#xff1a;将分散的文件片段整理到相邻的磁盘区域&#xff0c;减少文件的碎片化程度&#xff09;(效果不明显) 方案二&#xff1a;把其他盘的空间给C盘 &#x1f4bd;&#xff08;效果显著&#xf…

同一套SDK 兼容第二块板卡

尽可能分开写,避免兼容性变差

计算机网络高频八股文面试题及参考答案

请简述 TCP 和 UDP 的区别&#xff1f; TCP&#xff08;传输控制协议&#xff09;和 UDP&#xff08;用户数据报协议&#xff09;是两种不同的传输层协议&#xff0c;它们有以下区别。 从连接方式上看&#xff0c;TCP 是面向连接的协议。在通信之前&#xff0c;需要通过三次握手…

前缀和算法习题篇(上)

1.一维前缀和 题目描述&#xff1a; 解法一&#xff1a;暴力解法&#xff1a;模拟 时间复杂度是O(n*q),会超时。 解法二&#xff1a;前缀和解法&#xff1a;快速求出数组中某一个连续区间的和 快速是指O(1),前缀和思想可把时间复杂度可降到O(q)。 算法思路&#xff1a; 先预处…

uniapp路由与页面跳转详解:API调用与Navigator组件实战

UniApp路由与页面跳转详解&#xff1a;API调用与Navigator组件实战 路由 uniapp页面路由为框架统一管理&#xff0c;开发者需要在page.json里面配置每个路由页面的路径及页面样式。 路由跳转 uniapp有两种页面路由跳转方式&#xff0c;调用API跳转和navigator组件跳转。 调…

linux-DNS解析

dns解析 dns&#xff1a;域名系统&#xff0c;将域名和ip地址互相映射的一个分布式的数据库&#xff0c;方便用户访问互联网。 ip地址&#xff1a;是所有设备和网站在互联网上的唯一地址&#xff0c;通信一定是ip和ip之间的通信。 dns解析&#xff1a;根据域名在互联网当中找…

Playwright 快速入门:Playwright 是一个用于浏览器自动化测试的 Node.js 库

Playwright 是一个用于浏览器自动化测试的 Node.js 库&#xff0c;它支持 Chromium, Firefox 和 WebKit 浏览器引擎。Playwright 提供了一套强大的 API 来进行网页自动化测试&#xff0c;包括页面导航、元素选择、表单提交等操作&#xff0c;并且能够处理现代网页中的异步加载内…

【maven踩坑】一个坑 junit报错 但真正导致这个的不是junit的原因

目录 事件起因环境和工具操作过程解决办法结束语 事件起因 报错一&#xff1a; Internal Error occurred. org.junit.platform.commons.JUnitException: TestEngine with ID junit-vintage failed to discover tests报错二&#xff1a; Internal Error occurred. org.junit.pl…

ONNX: export failure: DLL load failed while importing _message: 找不到指定的程序。

ONNX: export failure 问题其他解决快速解决 问题 使用pytorch导出onnx&#xff08;Open Neural Network Exchange&#xff09;模型&#xff0c;结果使用conda安装完onnx之后&#xff0c;问题就出现了 ONNX: export failure: DLL load failed while importing _message: 找不到…

Redis做分布式锁

&#xff08;一&#xff09;为什么要有分布式锁以及本质 在一个分布式的系统中&#xff0c;会涉及到多个客户端访问同一个公共资源的问题&#xff0c;这时候我们就需要通过锁来做互斥控制&#xff0c;来避免类似于线程安全的问题 因为我们学过的sychronized只能对线程加锁&…

用Tokio掌握Rust异步编程

在Rust中构建可伸缩且高效的应用程序时&#xff0c;异步编程必不可少。异步编程能显著提高性能&#xff0c;让代码在不阻塞的情况下并发处理多个任务。在本教程中&#xff0c;我们将探索Tokio&#xff0c;介绍异步编程原理及应用场景&#xff0c;并逐步带你编写异步代码。 Toki…

推荐一款3D建模软件:Agisoft Metashape Pro

Agisoft Metashape Pro是一款强大的多视点三维建模设计辅助软件&#xff0c;Agisoft Metashape是一款独立的软件产品&#xff0c;可对数字图像进行摄影测量处理&#xff0c;并生成3D空间数据&#xff0c;用于GIS应用&#xff0c;文化遗产文档和视觉效果制作&#xff0c;以及间接…