FFmpeg+javacpp中仿ffplay播放

FFmpeg+javacpp中仿ffplay播放

  • 1、[ffplay 基于 SDL 和 FFmpeg 库的简单媒体播放器](https://ffmpeg.org/ffplay.html)
  • 2、FFmpeg帧捕获器 : FFmpegFrameGrabber
    • 2.1 grabSamples()
    • 2.2 grabImage()
    • 2.3 grab() 获取音视频帧

FFmpeg+javacpp+javacv使用
ffmpeg-6.0\fftools\ffplay.c

1、ffplay 基于 SDL 和 FFmpeg 库的简单媒体播放器

ffmpeg-6.0\fftools\ffplay.cFFplay是一款使用FFmpeg库SDL库的非常简单便携的媒体播放器。它主要用作各种FFmpeg API的测试平台。

parse_options(NULL, argc, argv, options, opt_input_file);
is = stream_open(input_filename, file_iformat);
event_loop(is);
实质刷新每一帧流refresh_loop_wait_event(cur_stream, &event);video_refresh获取,对应到 FFmpeg帧捕获器 : FFmpegFrameGrabber

ffplay -i “G:\视频\动漫\长安三万里2023.mp4” -hide_banner -x 800 -y 600

/* Called from the main */
int main(int argc, char **argv)
{int flags;VideoState *is;init_dynload();av_log_set_flags(AV_LOG_SKIP_REPEATED);parse_loglevel(argc, argv, options);/* register all codecs, demux and protocols */
#if CONFIG_AVDEVICEavdevice_register_all();
#endifavformat_network_init();signal(SIGINT , sigterm_handler); /* Interrupt (ANSI).    */signal(SIGTERM, sigterm_handler); /* Termination (ANSI).  */show_banner(argc, argv, options);parse_options(NULL, argc, argv, options, opt_input_file);if (!input_filename) {show_usage();av_log(NULL, AV_LOG_FATAL, "An input file must be specified\n");av_log(NULL, AV_LOG_FATAL,"Use -h to get full help or, even better, run 'man %s'\n", program_name);exit(1);}if (display_disable) {video_disable = 1;}flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;if (audio_disable)flags &= ~SDL_INIT_AUDIO;else {/* Try to work around an occasional ALSA buffer underflow issue when the* period size is NPOT due to ALSA resampling by forcing the buffer size. */if (!SDL_getenv("SDL_AUDIO_ALSA_SET_BUFFER_SIZE"))SDL_setenv("SDL_AUDIO_ALSA_SET_BUFFER_SIZE","1", 1);}if (display_disable)flags &= ~SDL_INIT_VIDEO;if (SDL_Init (flags)) {av_log(NULL, AV_LOG_FATAL, "Could not initialize SDL - %s\n", SDL_GetError());av_log(NULL, AV_LOG_FATAL, "(Did you set the DISPLAY variable?)\n");exit(1);}SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);SDL_EventState(SDL_USEREVENT, SDL_IGNORE);if (!display_disable) {int flags = SDL_WINDOW_HIDDEN;if (alwaysontop)
#if SDL_VERSION_ATLEAST(2,0,5)flags |= SDL_WINDOW_ALWAYS_ON_TOP;
#elseav_log(NULL, AV_LOG_WARNING, "Your SDL version doesn't support SDL_WINDOW_ALWAYS_ON_TOP. Feature will be inactive.\n");
#endifif (borderless)flags |= SDL_WINDOW_BORDERLESS;elseflags |= SDL_WINDOW_RESIZABLE;#ifdef SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITORSDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
#endifwindow = SDL_CreateWindow(program_name, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, default_width, default_height, flags);SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");if (window) {renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);if (!renderer) {av_log(NULL, AV_LOG_WARNING, "Failed to initialize a hardware accelerated renderer: %s\n", SDL_GetError());renderer = SDL_CreateRenderer(window, -1, 0);}if (renderer) {if (!SDL_GetRendererInfo(renderer, &renderer_info))av_log(NULL, AV_LOG_VERBOSE, "Initialized %s renderer.\n", renderer_info.name);}}if (!window || !renderer || !renderer_info.num_texture_formats) {av_log(NULL, AV_LOG_FATAL, "Failed to create window or renderer: %s", SDL_GetError());do_exit(NULL);}}is = stream_open(input_filename, file_iformat);if (!is) {av_log(NULL, AV_LOG_FATAL, "Failed to initialize VideoState!\n");do_exit(NULL);}event_loop(is);/* never returns */return 0;
}
static void video_refresh(void *opaque, double *remaining_time)
{VideoState *is = opaque;double time;Frame *sp, *sp2;if (!is->paused && get_master_sync_type(is) == AV_SYNC_EXTERNAL_CLOCK && is->realtime)check_external_clock_speed(is);if (!display_disable && is->show_mode != SHOW_MODE_VIDEO && is->audio_st) {time = av_gettime_relative() / 1000000.0;if (is->force_refresh || is->last_vis_time + rdftspeed < time) {video_display(is);is->last_vis_time = time;}*remaining_time = FFMIN(*remaining_time, is->last_vis_time + rdftspeed - time);}if (is->video_st) {
retry:if (frame_queue_nb_remaining(&is->pictq) == 0) {// nothing to do, no picture to display in the queue} else {double last_duration, duration, delay;Frame *vp, *lastvp;/* dequeue the picture */lastvp = frame_queue_peek_last(&is->pictq);vp = frame_queue_peek(&is->pictq);if (vp->serial != is->videoq.serial) {frame_queue_next(&is->pictq);goto retry;}if (lastvp->serial != vp->serial)is->frame_timer = av_gettime_relative() / 1000000.0;if (is->paused)goto display;/* compute nominal last_duration */last_duration = vp_duration(is, lastvp, vp);delay = compute_target_delay(last_duration, is);time= av_gettime_relative()/1000000.0;if (time < is->frame_timer + delay) {*remaining_time = FFMIN(is->frame_timer + delay - time, *remaining_time);goto display;}is->frame_timer += delay;if (delay > 0 && time - is->frame_timer > AV_SYNC_THRESHOLD_MAX)is->frame_timer = time;SDL_LockMutex(is->pictq.mutex);if (!isnan(vp->pts))update_video_pts(is, vp->pts, vp->pos, vp->serial);SDL_UnlockMutex(is->pictq.mutex);if (frame_queue_nb_remaining(&is->pictq) > 1) {Frame *nextvp = frame_queue_peek_next(&is->pictq);duration = vp_duration(is, vp, nextvp);if(!is->step && (framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) && time > is->frame_timer + duration){is->frame_drops_late++;frame_queue_next(&is->pictq);goto retry;}}if (is->subtitle_st) {while (frame_queue_nb_remaining(&is->subpq) > 0) {sp = frame_queue_peek(&is->subpq);if (frame_queue_nb_remaining(&is->subpq) > 1)sp2 = frame_queue_peek_next(&is->subpq);elsesp2 = NULL;if (sp->serial != is->subtitleq.serial|| (is->vidclk.pts > (sp->pts + ((float) sp->sub.end_display_time / 1000)))|| (sp2 && is->vidclk.pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000)))){if (sp->uploaded) {int i;for (i = 0; i < sp->sub.num_rects; i++) {AVSubtitleRect *sub_rect = sp->sub.rects[i];uint8_t *pixels;int pitch, j;if (!SDL_LockTexture(is->sub_texture, (SDL_Rect *)sub_rect, (void **)&pixels, &pitch)) {for (j = 0; j < sub_rect->h; j++, pixels += pitch)memset(pixels, 0, sub_rect->w << 2);SDL_UnlockTexture(is->sub_texture);}}}frame_queue_next(&is->subpq);} else {break;}}}frame_queue_next(&is->pictq);is->force_refresh = 1;if (is->step && !is->paused)stream_toggle_pause(is);}
display:/* display picture */if (!display_disable && is->force_refresh && is->show_mode == SHOW_MODE_VIDEO && is->pictq.rindex_shown)video_display(is);}is->force_refresh = 0;if (show_status) {AVBPrint buf;static int64_t last_time;int64_t cur_time;int aqsize, vqsize, sqsize;double av_diff;cur_time = av_gettime_relative();if (!last_time || (cur_time - last_time) >= 30000) {aqsize = 0;vqsize = 0;sqsize = 0;if (is->audio_st)aqsize = is->audioq.size;if (is->video_st)vqsize = is->videoq.size;if (is->subtitle_st)sqsize = is->subtitleq.size;av_diff = 0;if (is->audio_st && is->video_st)av_diff = get_clock(&is->audclk) - get_clock(&is->vidclk);else if (is->video_st)av_diff = get_master_clock(is) - get_clock(&is->vidclk);else if (is->audio_st)av_diff = get_master_clock(is) - get_clock(&is->audclk);av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC);av_bprintf(&buf,"%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64"/%"PRId64"   \r",get_master_clock(is),(is->audio_st && is->video_st) ? "A-V" : (is->video_st ? "M-V" : (is->audio_st ? "M-A" : "   ")),av_diff,is->frame_drops_early + is->frame_drops_late,aqsize / 1024,vqsize / 1024,sqsize,is->video_st ? is->viddec.avctx->pts_correction_num_faulty_dts : 0,is->video_st ? is->viddec.avctx->pts_correction_num_faulty_pts : 0);if (show_status == 1 && AV_LOG_INFO > av_log_get_level())fprintf(stderr, "%s", buf.str);elseav_log(NULL, AV_LOG_INFO, "%s", buf.str);fflush(stderr);av_bprint_finalize(&buf, NULL);last_time = cur_time;}}
}

2、FFmpeg帧捕获器 : FFmpegFrameGrabber

JavaCV 1.5.12 API
JavaCPP Presets for FFmpeg 7.1.1-1.5.12 API

在这里插入图片描述

2.1 grabSamples()

grabber.grabSamples() 获取音频信息
javax.sound.sampled.AudioFormat 设置PCM编码的AudioFormat参数,注意每个样本中的位数,无法获取,一般默认设置16位深。

package org.xhbruce.test;import org.bytedeco.ffmpeg.avcodec.AVCodecParameters;
import org.bytedeco.ffmpeg.avformat.AVFormatContext;
import org.bytedeco.ffmpeg.avformat.AVStream;
import org.bytedeco.ffmpeg.global.avutil;
import org.bytedeco.javacv.FFmpegFrameGrabber;
import org.bytedeco.javacv.Frame;
import org.xhbruce.Log.XLog;import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.SourceDataLine;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ShortBuffer;public class AudioPlayer implements Runnable {private String filePath;public AudioPlayer(String filePath) {this.filePath = filePath;}public void playAudio() throws Exception {FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(filePath);grabber.start();int sampleRate = grabber.getSampleRate();int audioChannels = grabber.getAudioChannels();int audioBitsPerSample = getAudioBitsPerSample(grabber);XLog.d("audioBitsPerSample=" + audioBitsPerSample);if (audioBitsPerSample <= 0) {audioBitsPerSample = 16; // 默认使用16位深度}AudioFormat audioFormat = new AudioFormat((float) sampleRate,audioBitsPerSample,audioChannels,true,false);DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);line.open(audioFormat);line.start();Frame frame;while ((frame = grabber.grabSamples()) != null) {if (frame.samples == null || frame.samples.length == 0) continue;Buffer buffer = frame.samples[0];byte[] audioBytes;if (buffer instanceof ShortBuffer) {ShortBuffer shortBuffer = (ShortBuffer) buffer;audioBytes = new byte[shortBuffer.remaining() * 2]; // Each short is 2 bytesfor (int i = 0; i < shortBuffer.remaining(); i++) {short value = shortBuffer.get(i);audioBytes[i * 2] = (byte) (value & 0xFF);audioBytes[i * 2 + 1] = (byte) ((value >> 8) & 0xFF);}} else if (buffer instanceof ByteBuffer) {ByteBuffer byteBuffer = (ByteBuffer) buffer;audioBytes = new byte[byteBuffer.remaining()];byteBuffer.get(audioBytes);} else {throw new IllegalArgumentException("Unsupported buffer type: " + buffer.getClass());}line.write(audioBytes, 0, audioBytes.length);}line.drain();line.stop();line.close();grabber.stop();}private int getAudioBitsPerSample(FFmpegFrameGrabber grabber) {AVFormatContext formatContext = grabber.getFormatContext();if (formatContext == null) {return -1;}int nbStreams = formatContext.nb_streams();for (int i = 0; i < nbStreams; i++) {AVStream stream = formatContext.streams(i);if (stream.codecpar().codec_type() == avutil.AVMEDIA_TYPE_AUDIO) {AVCodecParameters codecParams = stream.codecpar();return codecParams.bits_per_raw_sample();}}return -1;}@Overridepublic void run() {try {playAudio();} catch (Exception e) {throw new RuntimeException(e);}}public static void main(String[] args) {
//        new Thread(new AudioPlayer("G:\\视频\\动漫\\长安三万里2023.mp4")).start();new Thread(new AudioPlayer("F:\\Music\\Let Me Down Slowly.mp3")).start();}
}

2.2 grabImage()

grabImage() 获取视频信息
JFrame、JLabel图片显示

package org.xhbruce.test;import org.bytedeco.javacv.FFmpegFrameGrabber;
import org.bytedeco.javacv.Frame;
import org.bytedeco.javacv.Java2DFrameConverter;import javax.swing.*;
import java.awt.*;public class VideoPlayer extends JFrame implements Runnable {private String filePath;private JLabel videoLabel;public VideoPlayer(String title, String filePath) {super(title);this.filePath = filePath;setSize(800, 600);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setLocationRelativeTo(null);videoLabel = new JLabel();getContentPane().add(videoLabel, BorderLayout.CENTER);}public void playVideo() throws Exception {FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(filePath);grabber.start();int width = grabber.getImageWidth();int height = grabber.getImageHeight();Java2DFrameConverter converter = new Java2DFrameConverter();Frame frame;while ((frame = grabber.grabImage()) != null) {if (frame.image == null) continue;Image image = converter.convert(frame);int windowWidth = getWidth();int windowHeight = getHeight();float scaleX = (float) width / windowWidth;float scaleY = (float) height / windowHeight;float maxScale = Math.max(scaleX, scaleY);ImageIcon icon = new ImageIcon(image.getScaledInstance((int) (width / maxScale), (int) (height / maxScale), Image.SCALE_SMOOTH));SwingUtilities.invokeLater(() -> videoLabel.setIcon(icon));Thread.sleep(40); // 控制帧率}grabber.stop();}@Overridepublic void run() {try {setVisible(true);playVideo();} catch (Exception e) {throw new RuntimeException(e);}}public static void main(String[] args) {String mp4Url = "G:\\视频\\动漫\\长安三万里2023.mp4";new Thread(new VideoPlayer("JavaCV Video Player", mp4Url)).start();}
}

2.3 grab() 获取音视频帧

将上面组合处理,但存在同步卡顿问题,音频尤其严重,建议音视频不同线程处理。

package org.xhbruce.test;import org.bytedeco.ffmpeg.avcodec.AVCodecParameters;
import org.bytedeco.ffmpeg.avformat.AVFormatContext;
import org.bytedeco.ffmpeg.avformat.AVStream;
import org.bytedeco.ffmpeg.global.avutil;
import org.bytedeco.javacv.FFmpegFrameGrabber;
import org.bytedeco.javacv.Frame;
import org.bytedeco.javacv.Java2DFrameConverter;
import org.xhbruce.Log.XLog;import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.SourceDataLine;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ShortBuffer;public class SimpleFFPlay extends JFrame implements Runnable {private String filePath;private JLabel videoLabel;public SimpleFFPlay(String filePath) {this.filePath = filePath;setTitle("Simple FFPlay - JavaCV");setSize(800, 600);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setLocationRelativeTo(null);videoLabel = new JLabel();getContentPane().add(videoLabel, BorderLayout.CENTER);setVisible(true);}@Overridepublic void run() {FFmpegFrameGrabber grabber = null;try {grabber = FFmpegFrameGrabber.createDefault(filePath);} catch (FFmpegFrameGrabber.Exception e) {throw new RuntimeException(e);}Java2DFrameConverter converter = new Java2DFrameConverter();try {grabber.start();//grabber.setFrameRate(30);// 音频播放初始化int sampleRate = grabber.getSampleRate();int audioChannels = grabber.getAudioChannels();int audioBitsPerSample = getAudioBitsPerSample(grabber);XLog.d("sampleRate="+sampleRate+", audioChannels="+audioChannels+", audioBitsPerSample=" + audioBitsPerSample+"; getAudioBitrate="+grabber.getAudioBitrate());if (audioBitsPerSample <= 0) {audioBitsPerSample = 16; // 默认使用16位深度}AudioFormat audioFormat = new AudioFormat((float) sampleRate,audioBitsPerSample/*grabber.getAudioBitsPerSample()*/,audioChannels,true,false);DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat, 4096);SourceDataLine audioLine = (SourceDataLine) AudioSystem.getLine(info);//SourceDataLine audioLine = AudioSystem.getSourceDataLine(audioFormat);audioLine.open(audioFormat);audioLine.start();// 主循环读取帧Frame frame;while ((frame = grabber.grab()) != null) {if (frame.image != null) {// 视频帧BufferedImage image = converter.getBufferedImage(frame);int width = grabber.getImageWidth();int height = grabber.getImageHeight();paintFrame(image, width, height);}if (frame.samples != null && frame.samples.length > 0) {Buffer buffer = frame.samples[0];byte[] audioBytes;if (buffer instanceof ShortBuffer) {ShortBuffer shortBuffer = (ShortBuffer) buffer;audioBytes = new byte[shortBuffer.remaining() * 2]; // Each short is 2 bytesfor (int i = 0; i < shortBuffer.remaining(); i++) {short value = shortBuffer.get(i);audioBytes[i * 2] = (byte) (value & 0xFF);audioBytes[i * 2 + 1] = (byte) ((value >> 8) & 0xFF);}} else if (buffer instanceof ByteBuffer) {ByteBuffer byteBuffer = (ByteBuffer) buffer;audioBytes = new byte[byteBuffer.remaining()];byteBuffer.get(audioBytes);} else {throw new IllegalArgumentException("Unsupported buffer type: " + buffer.getClass());}audioLine.write(audioBytes, 0, audioBytes.length);}Thread.sleep(40); // 控制帧率}audioLine.drain();audioLine.stop();audioLine.close();grabber.stop();} catch (Exception e) {e.printStackTrace();}}private int getAudioBitsPerSample(FFmpegFrameGrabber grabber) {AVFormatContext formatContext = grabber.getFormatContext();if (formatContext == null) {return -1;}int nbStreams = formatContext.nb_streams();for (int i = 0; i < nbStreams; i++) {AVStream stream = formatContext.streams(i);if (stream.codecpar().codec_type() == avutil.AVMEDIA_TYPE_AUDIO) {AVCodecParameters codecParams = stream.codecpar();return codecParams.bits_per_raw_sample();}}return -1;}private void paintFrame(BufferedImage image, int width, int height) {int windowWidth = getWidth();int windowHeight = getHeight();float scaleX = (float) width / windowWidth;float scaleY = (float) height / windowHeight;float maxScale = Math.max(scaleX, scaleY);//XLog.d("width="+width+", height="+height+"; windowWidth="+windowWidth+", windowHeight="+windowHeight+"; scaleX="+scaleX+", "+scaleY);ImageIcon icon = new ImageIcon(image.getScaledInstance((int) (width/maxScale), (int) (height/maxScale), Image.SCALE_SMOOTH));SwingUtilities.invokeLater(() -> {
//            setSize(800, 600);videoLabel.setIcon(icon);});}public static void main(String[] args) {if (args.length < 1) {System.out.println("Usage: java SimpleFFPlay <video_file>");return;}new Thread(new SimpleFFPlay(args[0])).start();}
}

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【后端】 FastAPI

&#x1f680; FastAPI 是什么&#xff1f;FastAPI 是一个用于构建 Web API 的 Python 框架。可以理解成&#xff1a;&#x1f9f0; “一个工具箱&#xff0c;让你用 Python 写出能被浏览器、App、小程序调用的接口&#xff08;API&#xff09;。”&#x1f527; 那什么是 API&…

不画一张架构图讲透架构思维

&#x1f449;目录1 架构的定义2 架构是为了解无解的问题-分工3 抱残守缺的好架构应该是怎样的4 适可而止的设计、恰如其分的架构与成败论英雄本文深入探讨软件架构的本质与设计方法论&#xff0c;从架构定义演变到现代架构实践挑战&#xff0c;系统分析架构设计面临的业务复杂…

SpringCloudGateWay 使用nacos网关自动负载均衡

安装好nacos后&#xff08;参考以前文章SpringCloud 使用nacos注册服务&#xff0c;使用openFeign调用服务-CSDN博客&#xff09; 新建一个项目&#xff0c;添加 spring-cloud-starter-gateway-server-webmvc spring-cloud-loadbalancer spring-cloud-starter-alibaba-nacos-d…

Hiredis 构建 Redis 命令实战指南

一、同步命令构造 1.1 redisCommand(fmt, …) 最常用的同步接口即 redisCommand&#xff0c;其原型如下&#xff1a; void *redisCommand(redisContext *c, const char *format, ...);参数 c&#xff1a;已连接的 redisContext*format&#xff1a;与 printf 类似的格式字符串//…

【数据库】国产数据库的新机遇:电科金仓以融合技术同步全球竞争

7月15日&#xff0c;国产数据库厂商中电科金仓&#xff08;北京&#xff09;科技股份有限公司&#xff08;以下简称“电科金仓”&#xff09;在北京举行了一场技术发布会&#xff0c;集中发布四款核心产品&#xff1a;AI时代的融合数据库KES V9 2025、企业级统一管控平台KEMCC、…

大模型 Function Call 的实现步骤及示例详解

大模型 Function Call 的实现步骤及示例详解一、Function Call的核心流程拆解二、结合代码详解Function Call实现步骤1&#xff1a;定义工具&#xff08;对应代码中的tools列表&#xff09;步骤2&#xff1a;实现工具函数&#xff08;对应代码中的get_current_weather和get_cur…

Linux运维新手的修炼手扎之第24天

mysql服务1 mysql命令客户端(mysql.cnf)命令 \c--ctrl c \s--显示当前状态 \r--客户端重新连接 \h--查看帮助信息 exit退出客户端 \G--垂直格式显示查询结果连接MySQL服务器--[rootrocky9 ~]# mysql(mysql -u用户名 - p密码 -h服务端ip -P服务端port -S服务端sock -e "my…

面向对象分析与设计40讲(7)设计原则之合成复用原则

文章目录 一、概念 二、示例(C++ 实现) 1. 违反合成复用原则的示例(过度使用继承) 2. 遵循合成复用原则的示例(使用组合) 三、总结 1. 继承是“强绑定”,组合是“弱关联” 2. 继承固化“静态结构”,组合支持“动态变化” 3. 继承放大“设计缺陷”,组合隔离“局部问题”…

Git 完全手册:从入门到团队协作实战(4)

Hello大家好&#xff01;很高兴我们又见面啦&#xff01;给生活添点passion&#xff0c;开始今天的编程之路&#xff01; 我的博客&#xff1a;<但凡. 我的专栏&#xff1a;《编程之路》、《数据结构与算法之美》、《C修炼之路》、《Linux修炼&#xff1a;终端之内 洞悉真理…

解决Spring事务中RPC调用无法回滚的问题

文章目录问题分析解决方案实现原理解析执行流程说明运行实例正常流程执行执行异常流程关键优势在分布式系统开发中&#xff0c;我们经常会遇到本地事务与远程服务调用结合的场景。当本地事务包含RPC调用时&#xff0c;如果事务回滚&#xff0c;RPC调用已经执行就会导致数据不一…

sqli-labs通关笔记-第13关 POST报错型注入(单引号括号闭合 手工注入+脚本注入两种方法)

目录 一、字符型注入 二、limit函数 三、GET方法与POST方法 四、源码分析 1、代码审计 2、SQL注入安全分析 3、报错型注入与联合注入 五、渗透实战 1、进入靶场 2、注入点分析 &#xff08;1&#xff09;SQL语句 &#xff08;2&#xff09;admin) #注入探测 &…

康复器材动静态性能测试台:精准检测,为康复器械安全保驾护航

在康复医疗领域&#xff0c;无论是轮椅、拐杖、假肢还是康复床&#xff0c;每一件器械的强度与稳定性都直接关系到使用者的安全与康复效果。如何确保这些器械在实际使用中经得起反复考验&#xff1f;Delta德尔塔仪器推出的康复器材动静态性能测试台&#xff0c;凭借其高精度、智…

vue3中el-table表头筛选

效果如下&#xff0c;可以勾选表头进行隐藏&#xff0c;也可以对表头进行拖动排序index主界面 <script> let tempHead []; const showFilter ref<boolean>(false); let tableHeadList ref<TableHeadItem[]>([{ prop: "displayId", label: "…

数据结构 之 【排序】(直接选择排序、堆排序、冒泡排序)

目录 1.直接选择排序 1.1直接选择排序的思想 1.2直接选择排序的代码逻辑 1.3完整排序代码 1.3.1一次只选一个最值 1.3.2一次筛选出两个最值 1.4直接选择排序的时间复杂度与空间复杂度 2.堆排序 2.1堆排序的思想 2.2堆排序的具体步骤 2.3堆排序图解 2.4完整排序代码…

用手机当外挂-图文并茂做报告纪要

前阵参加一个峰会,看到演讲嘉宾每翻一页PPT,下面的观察就举起手机一顿拍。实话说这种拍下来的,难说还会拿出来看,而且再看的时候也未必能对应到当时主讲人的一些解释 。 如果现场将图片保存到笔记本电脑,并快速记录关键信息,这样听完一个报告可能就直接输出一篇报道了。 有…

Vue的ubus emit/on使用

这段代码是 Vue.js 组件中的 mounted 生命周期钩子函数&#xff0c;主要作用是监听一个名为 “macSelectData” 的全局事件。具体行为如下&#xff1a;分步解释&#xff1a;mounted() 生命周期钩子 当组件被挂载到 DOM 后&#xff0c;Vue 会自动调用 mounted() 方法。这里常用于…

rsync报错解决

问题说明 [rootlocalhost shyn]# rsync -avz --checksum "root192.168.159.133:/tmp/shyn" "/tmp /shyn"WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! …

ArKTS: DAL,Model,BLL,Interface,Factory using SQLite

HarmonyOS 用ohos.data.rdb 用DBHelper.ets 共用调用SQLite 库&#xff0c;进行DAL,Model,BLL,Interface,Factory 框架模式&#xff0c;表为CREATE TABLE IF NOT EXISTS signInRecord ( id INTEGER PRIMARY KEY AUTOINCREMENT, employeeId TEXT NOT NULL, employeeName TEXT NO…

MySQL JSON 数据类型用法及与传统JSON字符串的对比 JSON数据类型简介

文章目录前言1. 基本用法JSON数据类型 vs 传统JSON字符串1. 存储方式2. 查询方式对比3. 索引支持JSON存储对象和数组的性能考虑1. 存储对象2. 存储数组性能对比总结最佳实践建议前言 MySQL从 5.7 版本开始引入了 JSON 数据类型&#xff0c;专门用于存储 JSON 格式的数据。与传…

C++:list(1)list的使用

list的使用一.list基本的结构1.环状双向链表2.哨兵节点3.迭代器4.节点结构5.链表遍历6.迭代器失效二.list的基本使用1.test01函数&#xff1a;主要测试std::list的初始化方式及遍历2.test02函数&#xff1a;主要测试std::list的常用成员函数操作3.测试结果如下三.list的其他操作…