基于ImGui+FFmpeg實現播放器

基于ImGui+FFmpeg實現播放器

演示:

ImGui播放器

繼續研究FFmpeg,之前做了一個SDL的播放器,發現SDL的可視化UI界面的功能稍微差了點,所以今天我們換了一個新的工具,也就是ImGui。

ImGui官方文檔:https://github.com/ocornut/imgui

接下來講解一下播放器的主要功能,以及實現的方案

播放頁面

在這里插入圖片描述
播放頁面是基于OpenGL渲染,ImGui實現UI界面完成的。
實現流程如下:

  1. FFmpeg解析視頻文件,將每一幀寫入數組中
  2. 根據幀率計算每一幀的播放時間
  3. 循環渲染每一幀
frame = frame_vector.at(current_index).frame;
render_image(frame);
ImGui::Image((ImTextureID)(intptr_t)texture_ids[0],ImVec2(codec_ctx->width, codec_ctx->height));

暫停/快進功能

暫停和快進功能相對比較簡單
定義一個 is_pause變量控制視頻播放
定義一個 delay變量控制播放速度

/**播放線程*/
int play_thread(void* arg) {for (;;) {while (!is_pause && current_index < frame_vector.size()) {SDL_Delay((Uint32) delay);current_index ++;// 從頭播放if (current_index == frame_vector.size() -1) {current_index = 0;}}}return 1;
}

幀解析

在這里插入圖片描述
幀解析就是將數組中的每一幀展示出來,程序對幀的類型進行了區分,使用不同的顏色來區分 I幀,P幀,B幀。

ImGui::BeginGroup();
ImGui::BeginChild("ScrollArea", ImVec2(0, codec_ctx->height), true, ImGuiWindowFlags_HorizontalScrollbar);
for(int i=0;i<frame_vector.size();i++) {if (frame_vector.at(i).frame->pict_type == AV_PICTURE_TYPE_I) {ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.5f, 0.0f, 0.0f, 1.0f));}else if (frame_vector.at(i).frame->pict_type == AV_PICTURE_TYPE_P) {ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.5f, 0.0f, 1.0f));}else {ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.0f, 0.5f, 1.0f));}if (ImGui::Button(get_frame_title(i))) {current_index = i;}// 恢復樣式ImGui::PopStyleColor();
}
ImGui::EndChild();
ImGui::EndGroup();

宏塊解析

在這里插入圖片描述
根據鼠標的位置,找到對應的宏塊 16*16,必將對應的字節打印出來,方便我們進行逐個宏塊的分析。

源代碼

//
//  main.cpp
//  analyser
//
//  Created by chenhuaiyi on 2025/4/3.
//#include <SDL.h>
#include "imgui.h"                      // ImGui核心
#include "imgui_impl_sdl2.h"             // SDL2后端
#include "imgui_impl_opengl3.h"         // OpenGL渲染器
#include "iostream"
#include "glew.h"
#include <vector>
#include "string.h"
#include <iomanip> // 包含格式控制函數
#include <cstdint>// ffmpeg
extern "C" {
#include "libavcodec/avcodec.h"
#include "libswresample/swresample.h"
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
#include "libavutil/imgutils.h"
#include "libavutil/time.h"
#include "libavutil/channel_layout.h"
#include "libavutil/log.h"
}#define Y_SIZE 256
#define U_SIZE 64
#define V_SIZE 64typedef struct Frame {AVFrame* 			frame;int64_t  			pts;		// pts 播放相關int64_t				duration;	// durationAVPictureType 		pict_type;	// 幀類型
}Frame;/**單個宏塊的定義 16*16 個字節y 256 byteu 64 bytev 64 byte*/
typedef struct MircoBlock{uint8_t y[Y_SIZE];uint8_t u[U_SIZE];uint8_t v[V_SIZE];
} MircoBlock;// 窗口尺寸
const int WIDTH = 1600;
const int HEIGHT = 1200;GLuint texture_ids[2];std::vector<Frame> frame_vector;
int current_index = 0;const char* file = "//Users/chenhuaiyi/workspace/ffmpeg/files/戀愛_重編碼.mp4";
AVFormatContext* format_ctx = avformat_alloc_context();
int video_stream = -1;
const AVCodec* 		codec = NULL;
AVCodecContext*		codec_ctx;
double				delay; 			// 延遲單位ms
int					is_pause = 0;char* get_frame_title(int num) {// 為最大整數長度(含符號和結束符)分配空間char buffer[32];// 將整數寫入緩沖區snprintf(buffer, sizeof(buffer), "frame:%d", num);// 復制到動態內存char* str = strdup(buffer);return str;
}/**獲取當前幀的時間戳*/
double getCurrentTimeStamp() {AVFrame* frame = frame_vector.at(current_index).frame;double tag = av_q2d(format_ctx->streams[video_stream]->time_base);return frame->pts * tag;
}/**播放線程*/
int play_thread(void* arg) {for (;;) {while (!is_pause && current_index < frame_vector.size()) {SDL_Delay((Uint32) delay);current_index ++;// 從頭播放if (current_index == frame_vector.size() -1) {current_index = 0;}}}return 1;
}/**宏塊渲染*/
void render_block(float x, float y, AVFrame* frame, uint8_t* src[]) {src[0] = static_cast<uint8_t*>(av_malloc(Y_SIZE));src[1] = static_cast<uint8_t*>(av_malloc(U_SIZE));src[2] = static_cast<uint8_t*>(av_malloc(V_SIZE));int x_int = static_cast<int>(x);int y_int = static_cast<int>(y);// 計算當前坐標是哪個宏塊int block_x = x / 16;int block_y = y / 16;int cb_block_x = block_x / 2;int cb_block_y = block_y / 2;// yuint8_t* y_start = frame->data[0] +(block_y * 16) * frame->linesize[0] +  // 行偏移(block_x * 16);                        // 列偏移for (int row = 0; row < 16; row++) {const uint8_t* src_row = y_start + row * frame->linesize[0];std::memcpy(src[0] + (row * 16), src_row, 16);}// === 提取 Cb 分量 ===uint8_t* cb_start = frame->data[1] +(cb_block_y * 8) * frame->linesize[1] +  // 行偏移(cb_block_x * 8);                        // 列偏移for (int row = 0; row < 8; row++) {const uint8_t* src_row = cb_start + row * frame->linesize[1];std::memcpy(src[1] + (row * 8), src_row, 8);}// === 提取 Cr 分量 ===uint8_t* cr_start = frame->data[2] +(cb_block_y * 8) * frame->linesize[2] +  // 行偏移(cb_block_x * 8);                        // 列偏移for (int row = 0; row < 8; row++) {const uint8_t* src_row = cr_start + row * frame->linesize[2];std::memcpy(src[2] + (row * 8), src_row, 8);}// 渲染當前宏塊到圖像struct SwsContext*	sws_ctx;sws_ctx = sws_getContext(16,16,AV_PIX_FMT_YUV420P,16,16,AV_PIX_FMT_RGBA,SWS_BILINEAR,NULL, NULL, NULL);/**初始數據分配*/int linesize[3] = {16, 8, 8};AVFrame* frame2 = av_frame_alloc();frame2->width = 16;frame2->height = 16;frame2->format = AV_PIX_FMT_RGBA;av_frame_get_buffer(frame2, 0);sws_scale(sws_ctx,(uint8_t const **)src,linesize,0,frame2->height,frame2->data,frame2->linesize);sws_freeContext(sws_ctx);glBindTexture(GL_TEXTURE_2D, texture_ids[1]);glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,16,16,0,GL_RGBA,GL_UNSIGNED_BYTE,frame2->data[0]);av_free(frame2);
}/**幀渲染*/
void render_image(AVFrame* frame) {AVFrame* frame2 = av_frame_alloc();struct SwsContext*	sws_ctx;sws_ctx = sws_getContext(frame->width,frame->height,(AVPixelFormat)frame->format,frame->width,frame->height,AV_PIX_FMT_RGBA,SWS_BILINEAR,NULL, NULL, NULL);if (sws_ctx == NULL) {av_log(NULL, AV_LOG_ERROR, "sws context init error\n");return;}frame2->width = frame->width;frame2->height = frame->height;frame2->format = AV_PIX_FMT_RGBA;av_frame_get_buffer(frame2, 0);sws_scale(sws_ctx,(uint8_t const **)frame->data,frame->linesize,0,frame2->height,frame2->data,frame2->linesize);sws_freeContext(sws_ctx);glBindTexture(GL_TEXTURE_2D, texture_ids[0]);glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,frame2->width,frame2->height,0,GL_RGBA,GL_UNSIGNED_BYTE,frame2->data[0]);av_free(frame2);}int main(int argc, char* argv[]) {int ret = -1;ret = avformat_open_input(&format_ctx, file, NULL, NULL);if (ret < 0) {av_log(NULL, AV_LOG_ERROR, "Format open error: %s\n", av_err2str(ret));return -1;}if (avformat_find_stream_info(format_ctx, NULL) < 0) {printf("文件探測流信息失敗");}video_stream = av_find_best_stream(format_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &codec, 0);if (video_stream == -1) {av_log(NULL, AV_LOG_ERROR, "do not find video stream\n");return -1;}codec = avcodec_find_decoder(format_ctx->streams[video_stream]->codecpar->codec_id);if (codec == NULL) {av_log(NULL, AV_LOG_ERROR, "do not find encoder\n");return -1;}codec_ctx = avcodec_alloc_context3(codec);ret = avcodec_parameters_to_context(codec_ctx, format_ctx->streams[video_stream]->codecpar);if (ret < 0) {av_log(NULL, AV_LOG_ERROR, "codec context init error: %s\n", av_err2str(ret));return -1;}ret = avcodec_open2(codec_ctx, codec, NULL);if (ret < 0) {av_log(NULL, AV_LOG_ERROR, "encoder open error: %s\n", av_err2str(ret));return -1;}AVFrame* frame = av_frame_alloc();AVPacket packet;while (!av_read_frame(format_ctx, &packet)) {if (packet.stream_index == video_stream) {ret = avcodec_send_packet(codec_ctx, &packet);if (ret < 0) {av_log(NULL, AV_LOG_ERROR, "packet send error: %s\n", av_err2str(ret));}while (!avcodec_receive_frame(codec_ctx, frame)) {struct Frame frame_node;AVFrame* cpy_frame = av_frame_alloc();cpy_frame->width = codec_ctx->width;cpy_frame->height = codec_ctx->height;cpy_frame->format = codec_ctx->pix_fmt;av_frame_get_buffer(cpy_frame, 0);ret = av_frame_copy_props(cpy_frame, frame);ret = av_frame_copy(cpy_frame, frame);if (ret < 0) {av_log(NULL, AV_LOG_ERROR, "frame copy error:%s\n", av_err2str(ret));}frame_node.frame = cpy_frame;frame_node.duration = frame->duration;frame_node.pts = frame->pts;frame_node.pict_type = frame->pict_type;frame_vector.push_back(frame_node);}}av_packet_unref(&packet);}// 1. 初始化SDLif (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) != 0) {SDL_Log("SDL Initialization Failed! %s", SDL_GetError());return -1;}// 2. 創建窗口SDL_Window* window = SDL_CreateWindow("ImGui + SDL2 Example",SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,WIDTH, HEIGHT,SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);if (!window) {SDL_Log("Window Creation Failed! %s", SDL_GetError());return -1;}// 3. 創建OpenGL上下文SDL_GLContext gl_context = SDL_GL_CreateContext(window);if (!gl_context) {SDL_Log("OpenGL Context Creation Failed! %s", SDL_GetError());return -1;}// 4. 初始化ImGuiIMGUI_CHECKVERSION();ImGui::CreateContext();ImGuiIO& io = ImGui::GetIO();io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;// 5. 設置ImGui風格和主題ImGui::StyleColorsDark();// 6. 初始化 ImGui的SDL和OpenGL后端ImGui_ImplSDL2_InitForOpenGL(window, gl_context);ImGui_ImplOpenGL3_Init("#version 120"); // 根據OpenGL版本調整// 初始化紋理glGenTextures(1, texture_ids);for (int i=0; i<2; i++) {glBindTexture(GL_TEXTURE_2D, texture_ids[i]);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);}// 計算每一幀的延遲delay =  1/av_q2d(format_ctx->streams[video_stream]->avg_frame_rate)*1000;SDL_CreateThread(play_thread, "play_thread", NULL);// 7. 主循環bool is_running = true;while (is_running) {SDL_Event event;while (SDL_PollEvent(&event)) {ImGui_ImplSDL2_ProcessEvent(&event);if (event.type == SDL_QUIT)is_running = false;if (event.type == SDL_KEYDOWN) {}}// 開始 ImGui幀ImGui_ImplOpenGL3_NewFrame();ImGui_ImplSDL2_NewFrame();ImGui::NewFrame();// ---------------// 在此處編寫UI邏輯:ImGui::Begin("Hello, World!");           // 開始窗口ImGui::BeginGroup();frame = frame_vector.at(current_index).frame;render_image(frame);ImGui::Image((ImTextureID)(intptr_t)texture_ids[0],ImVec2(codec_ctx->width, codec_ctx->height));// 獲取 Image 的矩形區域ImVec2 img_min = ImGui::GetItemRectMin(); // 左上角坐標(全局坐標)ImVec2 img_max = ImGui::GetItemRectMax(); // 右下角坐標(全局坐標)ImVec2 mouse_global = ImGui::GetMousePos();if (ImGui::IsItemHovered()) {// 計算局部坐標ImVec2 local_mouse = ImVec2(mouse_global.x - img_min.x,mouse_global.y - img_min.y);// 顯示坐標(歸一化到紋理比例)float normalized_x = local_mouse.x / codec_ctx->width;float normalized_y = local_mouse.y / codec_ctx->height;uint8_t* src[3];render_block(local_mouse.x, local_mouse.y, frame, src);// 打印YUV數據ImGui::SameLine();ImGui::BeginGroup();std::string y_str;for (int i=0; i<16; i++) {for (int j=0; j<16; j++) {char buffer[3];snprintf(buffer, sizeof(buffer), "%02X", *(src[0] + i*16+j));y_str += buffer;}y_str.append("\n");}ImGui::Text(y_str.c_str());std::string u_str;for (int i=0; i<8; i++) {for (int j=0; j<8; j++) {char buffer[3];snprintf(buffer, sizeof(buffer), "%02X", *(src[1] + i*8+j));u_str += buffer;}u_str.append("\n");}ImGui::Text(u_str.c_str());std::string v_str;for (int i=0; i<8; i++) {for (int j=0; j<8; j++) {char buffer[3];snprintf(buffer, sizeof(buffer), "%02X", *(src[2] + i*8+j));v_str += buffer;}v_str.append("\n");}ImGui::Text(v_str.c_str());for (int i=0; i<3; i++) {av_free(src[i]);}ImGui::EndGroup();ImGui::Text("Relative Coordinates: %.2f, %.2f", local_mouse.x, local_mouse.y);ImGui::Text("Normalized: %.2f, %.2f", normalized_x, normalized_y);ImGui::Image((ImTextureID)(intptr_t)texture_ids[1],ImVec2(16, 16));// 鼠標宏塊顯示int block_x = local_mouse.x / 16;int block_y = local_mouse.y / 16;ImVec2 rect_min(img_min.x + block_x * 16, img_min.y + block_y * 16);ImVec2 rect_max(rect_min.x + 16, rect_min.y + 16);ImGui::GetWindowDrawList()->AddRect(rect_min,rect_max,ImGui::GetColorU32(ImGuiCol_Header), // 紅色0.0f,0,4.0f // 線寬);}ImGui::BeginGroup();if (ImGui::Button("<<")) {delay*=2;}ImGui::SameLine();if (ImGui::Button("stop")) {is_pause = !is_pause;}ImGui::SameLine();if (ImGui::Button(">>")) {delay/=2;}ImGui::EndGroup();ImGui::BeginGroup();ImGui::Text("decoder&encoder");ImGui::Text("decoder: %s", codec->name);ImGui::Text("time_base: %f", av_q2d(format_ctx->streams[video_stream]->time_base));ImGui::Text("frame_rate: %.2f", av_q2d(format_ctx->streams[video_stream]->avg_frame_rate));ImGui::Text("frame_size: %lld", format_ctx->streams[video_stream]->nb_frames);ImGui::Text("bit_rate: %lld", codec_ctx->bit_rate);ImGui::Text("duration: %lld", format_ctx->duration);ImGui::EndGroup();ImGui::SameLine();ImGui::BeginGroup();ImGui::Text("SPS&PPS");ImGui::Text("profile_idc: %d", codec_ctx->profile);ImGui::Text("profile_name: %s", av_get_profile_name(codec, codec_ctx->profile));ImGui::Text("level_idc: %d", codec_ctx->level);ImGui::Text("frame_cropping_flag: %d", codec_ctx->apply_cropping);ImGui::Text("gop_size: %d", codec_ctx->gop_size);ImGui::EndGroup();ImGui::SameLine();ImGui::BeginGroup();ImGui::Text("frame detail");ImGui::Text("pts: %lld", frame->pts);ImGui::Text("duration: %lld", frame->duration);ImGui::Text("pict_type: %c", av_get_picture_type_char(frame->pict_type));ImGui::Text("format: %d", frame->format);ImGui::Text("pkt_size: %d", frame->pkt_size);ImGui::Text("pkt_pos: %d", frame->pkt_pos);ImGui::Text("pkt_dts: %lld", frame->pkt_dts);ImGui::Text("play_timestamp: %.2f", getCurrentTimeStamp());ImGui::EndGroup();ImGui::SameLine();ImGui::EndGroup();ImGui::SameLine();ImGui::BeginGroup();ImGui::BeginChild("ScrollArea", ImVec2(0, codec_ctx->height), true, ImGuiWindowFlags_HorizontalScrollbar);for(int i=0;i<frame_vector.size();i++) {if (frame_vector.at(i).frame->pict_type == AV_PICTURE_TYPE_I) {ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.5f, 0.0f, 0.0f, 1.0f));}else if (frame_vector.at(i).frame->pict_type == AV_PICTURE_TYPE_P) {ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.5f, 0.0f, 1.0f));}else {ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.0f, 0.5f, 1.0f));}if (ImGui::Button(get_frame_title(i))) {current_index = i;}// 恢復樣式ImGui::PopStyleColor();}ImGui::EndChild();ImGui::EndGroup();ImGui::End();// ---------------// 渲染ImGui::Render();glViewport(0, 0, WIDTH, HEIGHT);glClearColor(0.2f, 0.2f, 0.2f, 1.0f);glClear(GL_COLOR_BUFFER_BIT);ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());// 切換緩沖區SDL_GL_SwapWindow(window);}// 8. 清理和退出av_packet_unref(&packet);for(Frame f : frame_vector) {av_free(f.frame);}avcodec_free_context(&codec_ctx);avformat_free_context(format_ctx);ImGui_ImplOpenGL3_Shutdown();ImGui_ImplSDL2_Shutdown();ImGui::DestroyContext();SDL_GL_DeleteContext(gl_context);SDL_DestroyWindow(window);SDL_Quit();return 0;
}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/900950.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/900950.shtml
英文地址,請注明出處:http://en.pswp.cn/news/900950.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

ES6變量聲明:let、var、const全面解析

一、引言 ECMAScript 6&#xff08;簡稱 ES6&#xff09;的發布為 JavaScript 帶來了許多革命性的變化&#xff0c;其中變量聲明方式的更新尤為重要。let、var和const成為開發者日常編碼中頻繁使用的關鍵字。 本文將深入解析這三種聲明方式的核心特性、區別及最佳實踐&#xff…

Java基礎 - 反射(2)

文章目錄 示例5. 通過反射獲得類的private、 protected、 默認訪問修飾符的屬性值。6. 通過反射獲得類的private方法。7. 通過反射實現一個工具BeanUtils&#xff0c; 可以將一個對象屬性相同的值賦值給另一個對象 接上篇&#xff1a; 示例 5. 通過反射獲得類的private、 pro…

FCOS目標檢測

一、模型框架 FCOS采用的網絡架構和RetinaNet一樣&#xff0c;都是采用FPN架構&#xff0c;如圖2所示&#xff0c;每個特征圖后是檢測器&#xff0c;檢測器包含3個分支&#xff1a;classification&#xff0c;regression和center-ness。 對于特征圖Fi∈RHWC&#xff0c;其相對…

Java基礎 - 泛型(常見用法)

文章目錄 泛型類泛型方法泛型類派生子類示例 1&#xff1a;子類固定父類泛型類型&#xff08;StringBox 繼承自 Box<String>&#xff09;示例 2&#xff1a;子類保留父類泛型類型&#xff08;AdvancedBox<T> 繼承自 Box<T>)示例 3&#xff1a;添加子類自己的…

YOLO學習筆記 | YOLOv8環境搭建全流程指南(2025.4)

===================================================== github:https://github.com/MichaelBeechan CSDN:https://blog.csdn.net/u011344545 ===================================================== YOLOv8環境搭建 一、環境準備與工具配置1. Conda虛擬環境搭建2. CUDA與…

【 Beautiful Soup (bs4) 詳解】

引言 Beautiful Soup 是 Python 最流行的 HTML/XML 解析庫&#xff0c;能夠從復雜的網頁文檔中高效提取數據。以下是其核心知識點及示例代碼。 一、庫簡介 1. 核心模塊 BeautifulSoup&#xff1a;主類&#xff0c;用于構建文檔樹結構Tag&#xff1a;表示 HTML/XML 標簽的對象…

傅利葉發布首款開源人形機器人N1:開發者可實現完整復刻

2025年4月11日&#xff0c;上海——通用機器人公司傅利葉正式發布首款開源人形機器人 Fourier N1&#xff0c;并同步開放涵蓋物料清單、設計圖紙、裝配指南、基礎操作軟件在內的完整本體資源包。作為傅利葉 “Nexus 開源生態矩陣” 的首個落地項目&#xff08;“N1” 即 “Nexu…

視覺目標檢測大模型GAIA

中國科學院自動化研究所智能感知與計算研究中心攜手華為等領軍企業&#xff0c;共同推出面向產業應用的視覺目標檢測全流程解決方案——GAIA智能檢測平臺。該研究成果已獲CVPR 2021會議收錄&#xff08;論文鏈接&#xff1a; 論文地址&#xff1a;https://arxiv.org/pdf/2106.…

前端時間同步利器:React + useEffect 實現高性能動態時鐘

前言 在你奮筆疾敲代碼的瞬間&#xff0c;是不是突然一低頭&#xff0c;發現時間像偷偷跑路的變量&#xff0c;一眨眼就從上午飄到下午&#xff1f;飯沒吃、會沒開、工位也快被前端貓霸占了。仿佛你寫的不是代碼&#xff0c;而是“時間穿梭機”。別慌&#xff0c;咱們今天就來…

前端動畫性能優化

前端動畫性能優化全攻略&#xff1a;告別卡頓與高CPU占用 一、動畫性能問題現狀分析 1.1 性能問題現象 動畫幀率低于60FPS時出現明顯卡頓滾動/縮放操作時響應延遲CPU占用率長期超過70%移動端設備發熱嚴重 1.2 核心問題根源 瀏覽器渲染流程中的性能瓶頸主要出現在&#xff1…

springboot中如何處理跨域

什么是跨域 跨域&#xff08;Cross-Origin&#xff09;是瀏覽器出于安全考慮&#xff0c;對不同源的資源訪問施加的限制機制。其核心原因是同源策略&#xff08;Same-Origin Policy&#xff09;&#xff0c;即瀏覽器僅允許協議&#xff08;Protocol&#xff09;、域名&#xf…

js實現生肖宜忌展示

實現效果圖如下 實現邏輯&#xff1a; 1.錄入屬相列表&#xff08;列表順序不可調整&#xff09;&#xff1b; 2.錄入各屬相相宜、相忌屬相&#xff1b; 3.輸入年份后&#xff0c;根據屬相列表獲取到正確的屬相&#xff1b; 4.根據獲取的屬相去展示宜、忌屬相&#xff1b; 5.打…

3DMAX筆記-UV知識點和烘焙步驟

1. 在展UV時&#xff0c;如何點擊模型&#xff0c;就能選中所有這個模型的uv 2. 分多張UV時&#xff0c;不同的UV的可以設置為不同的顏色&#xff0c;然后可以通過顏色進行篩選。 3. 烘焙步驟 擺放完UV后&#xff0c;要另存為一份文件&#xff0c;留作備份 將模型部件全部分成…

AI 重構 Java 遺留系統:從靜態方法到 Spring Bean 注入的自動化升級

在當今快速發展的軟件行業中&#xff0c;許多企業都面臨著 Java 遺留系統的維護和升級難題。這些老舊系統往往采用了大量靜態方法&#xff0c;隨著業務的不斷發展&#xff0c;其局限性日益凸顯。而飛算 JavaAI 作為一款強大的 AI 工具&#xff0c;為 Java 遺留系統的重構提供了…

【從一個 TypeScript 報錯理解 ES6 模塊的三種導入方式】

從一個 TypeScript 報錯理解 ES6 模塊的三種導入方式 在日常開發中&#xff0c;我們經常遇到模塊導入導出的場景。最近在處理一個項目時&#xff0c;遇到了一個有趣的問題&#xff1a;對于只有默認導出的模塊&#xff0c;我們該使用哪種導入方式&#xff1f;這個問題引發了對 …

安徽京準:NTP網絡時鐘服務器功能及同步模式的介紹

安徽京準&#xff1a;NTP網絡時鐘服務器功能及同步模式的介紹 安徽京準&#xff1a;NTP網絡時鐘服務器功能及同步模式的介紹 1、NTP網絡時鐘服務器概念&#xff1a; NTP時鐘服務器&#xff0c;表面意思是時間計量工具的服務設備&#xff0c;其在現代工業中是用于對客戶端設備…

JMeter從入門到荒廢-常見問題匯總

啟動某個ThreadGroup的時候&#xff0c;啟動不了 現象 點擊start按鈕的時候&#xff0c;結果樹和匯總報告都沒有任何數據。 同時&#xff0c;點擊右上角的error log 發現有錯誤信息&#xff1a; 錯誤信息如下&#xff1a; 2025-04-09 10:03:48,009 ERROR o.a.j.g.a.ActionR…

Elasticsearch 學習規劃

Elasticsearch 學習規劃 明確學習目標與動機 場景化需求分析 - **S**&#xff1a;掌握Elasticsearch架構體系&#xff0c;熟練使用Elasticsearch 進行數據分析,Elasticsearch結合java 項目落地案例 - **M**&#xff1a;搜索和Elasticsearch相關GitHub項目 - **A**&#xff1a;每…

核心案例 | 湖南汽車工程職業大學無人機操控與編隊技術實驗室

核心案例 | 湖南汽車工程職業大學無人機操控與編隊技術實驗室 為滿足當今無人機行業應用需求&#xff0c;推動無人機技術的教育與實踐深度融合&#xff0c;北京卓翼智能科技有限公司旗下品牌飛思實驗室與湖南汽車工程職業大學強強聯手&#xff0c;共同建設無人機操控與編隊技術…

【Android】Android 獲取當前前臺應用包名與自動化控制全流程實踐筆記(適配 Android 10+)

一、前言 在 Android 系統中&#xff0c;獲取當前運行的前臺應用、返回桌面、跳轉權限設置、關閉其他應用等行為&#xff0c;往往受到系統的嚴格限制。隨著 Android 版本的提升&#xff08;特別是 Android 10 之后&#xff0c;即 API 29&#xff09;&#xff0c;很多傳統方法已…