Posts

Design Patterns

Creational: Factory Method (class) Abstract Factory (object) Builder  (object) Prototype  (object) Singleton  (object) Structral: Adapter (class/object) Bridge (object) Composite (object) Decorator  (object) Facade  (object) Flyweight  (object) Proxy  (object) Behavioral: Interpreter (class) Template Method (class) Chain of Responsibility (object) Command (object) Iterator (object) Mediator (object) Memento (object) Observer (object) State (object) Strategy (object) Visitor (object)

Adding Chinese watermarks to images using ffmpeg on Windows 10

Code: ffmpeg -i i1.jpg -vf "drawtext=text='仅为开户使用':fontfile='C\:/Windows/Fonts/msyh.ttc':fontsize=168:fontcolor=white@0.5:x=(w-text_w)/2:y=(h-text_h)/2" output.jpg Multi Line Version: ffmpeg -i i1.jpg -vf "drawtext=text='仅为开户使用':fontfile='C\:/Windows/Fonts/msyh.ttc':fontsize=w*0.03:fontcolor=white@0.7:x=w*0.1:y=h*0.2,drawtext=text='仅为开户使用':fontfile='C\:/Windows/Fonts/msyh.ttc':fontsize=w*0.03:fontcolor=white@0.7:x=w*0.4:y=h*0.2,drawtext=text='仅为开户使用':fontfile='C\:/Windows/Fonts/msyh.ttc':fontsize=w*0.03:fontcolor=white@0.7:x=w*0.7:y=h*0.2,drawtext=text='仅为开户使用':fontfile='C\:/Windows/Fonts/msyh.ttc':fontsize=w*0.03:fontcolor=white@0.7:x=w*0.1:y=h*0.5,drawtext=text='仅为开户使用':fontfile='C\:/Windows/Fonts/msyh.ttc':fontsize=w*0.03:fontcolor=white@0.7:x=w*0.4:y=h*0.5,drawtext=text='仅为开户使用':fontfile='C\:/Windows/Fonts/msyh.ttc':fontsize=w*0.03:fontcolor=white@0.7:x...

Using spdlog in a C++ project

Image
Tree structure of the project. The code of main.cc. #include <iostream> #include "spdlog/spdlog.h" #include "spdlog/sinks/basic_file_sink.h" #include "spdlog/sinks/rotating_file_sink.h" void do_work_in_another_file(); void rotating_example() { try { // Create a file rotating logger with 5 MB size max and 3 rotated files auto max_size = 1048576 * 5; auto max_files = 3; // Set output time pattern // %f: Time accurate to microseconds // %n: Output mode "some_logger_name" // %l: Prints the severity level of the log message. Example include info, warn, error, debug or critical. // %v: Prints the actual text or payload of the log message that you passed to the function. spdlog::set_pattern("[%Y-%m-%d %H:%M:%S.%f] [%n] [%l] %v"); // Set it as default so you can spdlog::info() directly. auto logger = spdlog::rotating_logger_mt("som...

vim的智能配置

" 显示行号 set number " 将Tab键自动转换为空格 set expandtab " 设置Tab键本身的宽度为4个空格 set tabstop=4 " 设置按退格键(BackSpace)时一次删除4个空格 set softtabstop=4 " 设置使用>或<进行缩进时的宽度为4个空格 set shiftwidth=4 " 开启自动缩进(新行继承上一行的缩进) set autoindent " 开启C/C++语言智能缩进 set cindent " 搜索优化 set incsearch set ignorecase " 语法高亮 syntax on " 开启256色支持(在终端使用时非常重要) set t_Co=256

Installing vim via msys2 and config vim on windows10

1. Installing vim Open msys2 ucrt64 terminal and enter command as follows: ``` pacman -S vim ``` 2. Configure vim Open msys2 ucrt64 terminal and enter command as follows: ``` cd ~ touch .vimrc ``` Adding the content into .vimrc which you want to. For example: ``` set number ```

Constructing C++ Projects via CMake on Windows in git bash

Image
1. Installing CMake CMake Download 2. Building Source Code Files hello.cc #include <iostream> #include "spdlog/spdlog.h" int main(void) { spdlog::info("Welcome to spdlog!"); std::cout << "Hello World!" << std::endl; return 0; } 3. Building CMakeLists.txt File # 指定CMake最低版本 cmake_minimum_required(VERSION 3.10) # 必须在项目名称前指定C++编译器 set (CMAKE_CXX_COMPILER "g++.exe") # 指定项目名称和使用的编程语言 project(MyProject LANGUAGES CXX) # 添加spdlog目录,让spdlog可用 add_subdirectory(third_party/spdlog) # 指定C++标准 set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) # 指定生成的可执行文件及对应的源文件 add_executable(my_app main.cc) # 使用spdlog头文件模式 target_link_libraries(my_app PRIVATE spdlog::spdlog_header_only) 4. Building Project # 1. 配置项目(生成 Makefile 或 Ninja 文件) # -G "MinGW Makefiles" 指定使用MinGW而不是Windows默认的nmake, # 当然要提前安装MinGW到C:/MinGW安装路径不要有空格否则可能报错 # 且C:/MinGW/bin要放到Windows的环境路径上 # -G Ninja 指定使用Ninja,同样Ninja也需要提前准备好 #...

FFmpeg

FFmpeg extract audio mp3 from mp4 video ffmpeg -i video.mp4 -b:a 192K -vn music.mp3 How to merge audio and video file in ffmpeg ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a aac output.mp4