📚 我的文章

Linux收录UDP视频花屏总结

最近在Linux下使用ffmpeg收录UDP流花屏问题,发现机器有双网卡,添加路由指定网卡收录导致无法收录了。另附一些解决花屏的优化方法。

优化内核参数 #

cat /etc/sysctl.conf
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.all.rp_filter = 0
# 修改默认网络的缓存大小 这个很重要不然
net.core.rmem_max = 50000000
net.core.rmem_default = 50000000

sysctl -p

# 添加以上配置后需要重启系统
reboot

# 不重启的话一定要执行以下命令
for i in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 0 > "$i";   done

吐槽 #

由于博主只修改了上面的 sysctl.conf 并且只执行了 sysctl -p 所以悲剧了,添加路由之后一直无法收录。

...

CentOS添加静态路由之route

route命令参数详细说明及常用命令

原文地址 docs.lvrui.io

> route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         localhost       0.0.0.0         UG    100    0        0 eno16780032
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.10.0    0.0.0.0         255.255.255.0   U     100    0        0 eno16780032

macOS 中使用 netstat -nr 命令来查看当前路由表

...

macos Lauchpad(启动台) 重置

重置macos的Lauchpad(启动台),及设置Lauchpad(启动台)的行数和列数。

打开终端程序,按需求执行以下命令即可。

重置 Lauchpad #

defaults write com.apple.dock ResetLaunchPad -bool TRUE;

重启 Dock #

killall Dock

设置 Lauchpad 图标的列数 #

defaults write com.apple.dock springboard-columns -int 7

设置 Lauchpad 图标的行数 #

defaults write com.apple.dock springboard-rows -int 7

nginx及php-fpm优化

简单的讲讲nginx+php的一些常用优化,以及相关的内核参数优化。

Nginx 优化 #

1. TCP 与 UNIX 套接字

UNIX 域套接字提供的性能略高于 TCP 套接字在回送接口上的性能(较少的数据复制,较少的上下文切换)。如果每个服务器需要支持超过 1000 个连接,请使用 TCP 套接字 - 它们可以更好地扩展。

...

ffmpeg在特定的时间混合一个或多个音频

使用FFmpeg中的adelay和amix滤镜给音频做混音

在30秒后混合1个音频

ffmpeg -i 1-1.mp3 -i 2.mp3 -filter_complex "[1]adelay=delays=30s:all=1[aud1];[0][aud1]amix=inputs=2" -vsync 2 -y 3.mp3

在30秒后混合2个音频

ffmpeg -i 1-1.mp3 -i 2.mp3 -i 3.mp3 -filter_complex "[1]adelay=delays=30s:all=1[aud1];[2]adelay=delays=30s:all=1[aud2];[0][aud1][aud2]amix=inputs=3" -vsync 2 -y 4.mp3

混合多个参照混合2个的命令修改下即可

...

[supervisord]填坑之最大连接数

修改supervisord配置突破1024最大连接数

问题描述 #

最近在使用supervisord服务时发现,无论如何修改系统的最大连接数,由supervisord管理的程序都无法突破1024的限制。

...

FFmpeg 水印

图片水印、文字水印、画中画

图片水印 #

ffmpeg -i input.mp4 -vf "movie=wenzi.png[watermark];[in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10[out] " output.mp4

-i :一般表示输入

input.mp4:这里表示要处理的视频源

-vf:滤镜相关,视频裁剪,水印等等操作都需要它完成

...

supervisor 常见坑及解决办法

Too many open files、获取不到$HOME等

Too many open files #

vim /etc/supervisord.conf
[supervisord]
minfds=81920
minprocs=81920

# systemctl restart supervisord

获取不到$HOME #

[program:apache2]
command=/home/chrism/bin/httpd -c "ErrorLog /dev/stdout" -DFOREGROUND
user=chrism
environment=HOME="/home/chrism",USER="chrism"

supervisorctl update

linux nvidia 获取显卡信息

使用deviceQuery获取显卡信息

环境 #

Linux、nvidia、cuda

命令 #

/usr/local/cuda/extras/demo_suite/deviceQuery

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 2 CUDA Capable device(s)

Device 0: "GeForce RTX 2080 Ti"
  CUDA Driver Version / Runtime Version          10.1 / 10.1
  CUDA Capability Major/Minor version number:    7.5
  Total amount of global memory:                 11019 MBytes (11554717696 bytes)
  (68) Multiprocessors, ( 64) CUDA Cores/MP:     4352 CUDA Cores
  GPU Max Clock rate:                            1545 MHz (1.54 GHz)
  Memory Clock rate:                             7000 Mhz
  Memory Bus Width:                              352-bit
  L2 Cache Size:                                 5767168 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
  Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  1024
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 3 copy engine(s)
  Run time limit on kernels:                     No
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device supports Compute Preemption:            Yes
  Supports Cooperative Kernel Launch:            Yes
  Supports MultiDevice Co-op Kernel Launch:      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

Device 1: "GeForce RTX 2080 Ti"
  CUDA Driver Version / Runtime Version          10.1 / 10.1
  CUDA Capability Major/Minor version number:    7.5
  Total amount of global memory:                 11019 MBytes (11554717696 bytes)
  (68) Multiprocessors, ( 64) CUDA Cores/MP:     4352 CUDA Cores
  GPU Max Clock rate:                            1545 MHz (1.54 GHz)
  Memory Clock rate:                             7000 Mhz
  Memory Bus Width:                              352-bit
  L2 Cache Size:                                 5767168 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
  Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  1024
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 3 copy engine(s)
  Run time limit on kernels:                     No
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device supports Compute Preemption:            Yes
  Supports Cooperative Kernel Launch:            Yes
  Supports MultiDevice Co-op Kernel Launch:      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 2 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
> Peer access from GeForce RTX 2080 Ti (GPU0) -> GeForce RTX 2080 Ti (GPU1) : Yes
> Peer access from GeForce RTX 2080 Ti (GPU1) -> GeForce RTX 2080 Ti (GPU0) : Yes

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 10.1, CUDA Runtime Version = 10.1, NumDevs = 2

源码 #

https://github.com/NVIDIA/cuda-samples/tree/master/Samples/deviceQuery

...

ffprobe详解

ffprobe是ffmpeg提供的三大工具之一,用来查看音视频文件的各种信息,比如:封装格式、音频/视频流信息、数据包信息等。

ffprobe的源码是ffprobe.c,开发过程中如果想获取ffprobe查看的信息,可以通过分析源码,获得对应字段。

...