解决Trae在MacOS下开发C/C++的问题

VSCode下 C/C++插件是微软自己开发的,根据VSCode扩展商店政策,第三方Fork的VSCode项目是不允许使用的。

Trae下如果打开C/C++项目,默认会推荐安装ccls插件来支持。

Mac下使用还需要一点小改动。

首先通过brew安装ccls命令行

brew install ccls

自动安装ccls和它的依赖比如llvm

再次通过Trae打开项目,发现仍然找不到标准头文件。

打开终端,输入命令

clang++ -xc++ -fsyntax-only -v /dev/null

打印:

InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1"
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple arm64-apple-macosx15.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -fsyntax-only -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name null -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -fno-strict-return -ffp-contract=on -fno-rounding-math -funwind-tables=1 -fobjc-msgsend-selector-stubs -target-sdk-version=15.4 -fvisibility-inlines-hidden-static-local-var -fdefine-target-os-macros -fno-assume-unique-vtables -fno-modulemap-allow-subdirectory-search -target-cpu apple-m1 -target-feature +zcm -target-feature +zcz -target-feature +v8.5a -target-feature +aes -target-feature +altnzcv -target-feature +ccdp -target-feature +complxnum -target-feature +crc -target-feature +dotprod -target-feature +fp-armv8 -target-feature +fp16fml -target-feature +fptoint -target-feature +fullfp16 -target-feature +jsconv -target-feature +lse -target-feature +neon -target-feature +pauth -target-feature +perfmon -target-feature +predres -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +sb -target-feature +sha2 -target-feature +sha3 -target-feature +specrestrict -target-feature +ssbs -target-abi darwinpcs -debugger-tuning=lldb -fdebug-compilation-dir=/Users/aliang -target-linker-version 1167.4.1 -v -fcoverage-compilation-dir=/Users/aliang -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -fdeprecated-macro -ferror-limit 19 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-cxx-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcommon -fcolor-diagnostics -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -clang-vendor-feature=+disableAtImportPrivateFrameworkInImplementationError -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c++ /dev/null
clang -cc1 version 17.0.0 (clang-1700.0.13.3) default target arm64-apple-darwin24.4.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/SubFrameworks"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.

打开Trae,切换到扩展,点ccls的配置,点ccls.clang.extraArgs

根据前一个打印,修改这个值为:

  "ccls.clang.extraArgs": [
    "-isystem/usr/local/include",
    "-isystem/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1",
    "-isystem/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include",
    "-isystem/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include",
    "-isystem/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
    "-isystem/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
  ],

重启Trae后,再点头文件,正常跳转

原创文章,转载请注明: 转载自贝壳博客

本文链接地址: 解决Trae在MacOS下开发C/C++的问题

MacOS 从配置PHP开发环境到VSCode调试

来让我看看还有谁2024年了还在用PHP 🙂

Homebrew是必须的,没有的话先安装 Homebrew — The Missing Package Manager for macOS (or Linux)

由于我们需要用到redis xdebug等扩展,brew默认的php是不够的。配置以下两个tap

brew tap shivammathur/php
brew tap shivammathur/extensions

通过brew安装php@8.3 xdebug@8.3 redis@8.3

brew install shivammathur/php/php@8.3 shivammathur/extensions/xdebug@8.3 shivammathur/extensions/redis@8.3

Apple Silicon修改xdebug配置

/opt/homebrew/etc/php/8.3/conf.d/20-xdebug.ini

Intel 修改xdebug配置

/usr/local/etc/php/8.3/conf.d/20-xdebug.ini

添加内容

xdebug.mode = debug
xdebug.start_with_request = yes

此时运行 php artisan serve ,有以下打印则配置完成

Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port).

接下来配置vscode

搜索并安装扩展 PHP Debug,开发者为Xdebug的。

打开PHP项目,切换到“运行与调试标签”,点创建launch.json文件,选 “PHP(Xdebug)”。
切换运行方式为 “Listen for Xdebug”,点运行。注意一定要先点调试运行后再启动项目。

这时候再执行php artisan serve,没有错误打印了,现在应该就能在源码中断点调试了。

没有最好的语言,只有最适合的,适合自己适合需求。

原创文章,转载请注明: 转载自贝壳博客

本文链接地址: MacOS 从配置PHP开发环境到VSCode调试

解决apple silicon vscode远程到一个amd64容器里无法安装扩展到问题

在M1/M2/M3的MacOS上运行amd64的容器,采用命令行

docker run -it --name ubuntu --platform linux/amd64 ubuntu:22.04 bash

进入容器后可以看到所有命令都是通过/run/rosetta/rosetta转译运行

如果需要通过vscode直接远程到容器内进行开发,目前版本1.88.1在容器内安装开发插件会失败,一直卡在扩展签名处,解决办法是:

修改remote的settings.json, 添加

"extensions.verifySignature": false

原创文章,转载请注明: 转载自贝壳博客

本文链接地址: 解决apple silicon vscode远程到一个amd64容器里无法安装扩展到问题

2021年IE可用直播插件,替代Flash

NodeMediaClient-WinPlugin 用于Windows系统下,ie浏览器和360浏览器极速模式下的直播插件。最新的EDGE,Chrome,Firefox浏览器均移除了NPAPI插件的支持。只有国内部分浏览器如:360(安全、极速)浏览器,搜狗浏览器保留了NPAPI的支持。由于使用率较低,NodeMediaClient-WinPlugin曾一度停止开发。2020年12月flash停止支持并强制从windows系统下移除,导致不少项目无法正常使用。NodeMediaClient-WinPlugin在RTMP直播播放场景下完全可以替代flash,并且拥有更好的性能与播放体验。

本次更新重构了播放核心,使用了NodePlayer.js的延迟消除算法,延迟更低、体验更好。并且支持主流的Intel\Nvidia\AMD显卡硬件加速。4k60帧也流畅播放无压力。

测试环境

ffmpeg -re -i bbb_sunflower_2160p_60fps_normal.mp4 -c copy -f flv rtmp://192.168.0.2/live/s

下载

最新测试版安装包下载

https://cdn.nodemedia.cn/NodeMediaClient-WinPlugin/0.5.0/NodeMediaClient_v0.5.0.msi

插件开发用例下载

https://cdn.nodemedia.cn/NodeMediaClient-WinPlugin/0.2.9/NodeMediaClient_v0.2.9.0-trial.zip

推荐浏览器下载

https://down.360safe.com/cse/360cse_13.0.2206.0.exe

文档

https://www.nodemedia.cn/doc/web/#/6?page_id=38

原创文章,转载请注明: 转载自贝壳博客

本文链接地址: 2021年IE可用直播插件,替代Flash

YUV420P与NV12的图像格式描述差异

YUV420

NV12:

可以看出,就图像格式描述而言,它们都是3组数据,不同在于:
YUV420P的
U分量是plane:1、step:1、offset:0
V分量是plane:2,step:1、offset:0

NV12的
U分量plane:1、step:2、offset:0
V分量plane:1、step:2、offset:1

原创文章,转载请注明: 转载自贝壳博客

本文链接地址: YUV420P与NV12的图像格式描述差异

WebCodecs in Chrome M86: Limitations

Supported

  • AudioDecoder can decode AAC, FLAC, MP3, Opus, and Vorbis.
  • VideoDecoder can decode VP8, VP9, H.264 and AV1 (AV1 not available on Android).
  • VideoEncoder can encode VP8 and VP9.
  • VideoTrackReader.
  • ImageDecoder can decode BMP, GIF, JPG, PNG, ICO, AVIF, and WebP.

Unsupported

  • AudioEncoder is not yet implemented.
  • VideoEncoder can encode H.264, but it is limited:
    • H.264 encoding is not available on all platforms.
    • The output format is Annex B. We expect the format to be AVC in the future.
  • new VideoFrame(pixelFormat, planes, frameInit) is not available.
  • ImageDecoder  can’t decode SVG. We don’t expect SVG to ever be supported.

Caveats

  • AudioDecoder and VideoDecoder call error(undefined) to report an error. We expect the value to be a DOMException in the future.
  • VideoDecoder, VideoEncoder, and EncodedVideoChunk are not available in Worker contexts. Worker support will be added in the future.
  • VideoEncoder does not emit VideoDecoderConfig objects to describe its output. We expect configs to be emitted in the future.
  • Constructing a VideoFrame from an ImageBitmap produces an I420 frame. We expect this to change to RGBA or an opaque format in the future.
  • In some cases a valid VideoFrame has format === null and planes === null. VideoFrame.createImageBitmap() is available. We expect to add explicit conversion APIs to address these cases in the future.
  • ImageFrame  does not provide YUV access. We expect that ImageDecoder will output VideoFrame objects in the future.
  • H.264 extradata and payload must be provided in AVC format.

Known Issues

AudioDecoder, VideoDecoder, and VideoEncoder may produce outputs or errors after calling reset().

有被爽到

原创文章,转载请注明: 转载自贝壳博客

本文链接地址: WebCodecs in Chrome M86: Limitations

VSCode 在Windows下安装cmake tools插件使用msys2开发环境

clang在Windows下可以很方便的引用msys2的开发环境。

vscode在linux,mac下安装cmake tools插件也差不多能达到相同功能。

但该插件在windows下,想要引用msys2还是遇到问题了。

ctrl+p,>CMake:Edit User-Local CMake Kits 需要如下设置:

  {
    "name": "GCC 10.1.0",
    "compilers": {
      "C": "D:\\msys64\\mingw32\\bin\\gcc.exe",
      "CXX": "D:\\msys64\\mingw32\\bin\\g++.exe"
    },
    "environmentVariables": {
      "PATH": "${env:PATH};d:\\msys64\\mingw32\\bin"
    }
  },

添加environmentVariables是关键

原创文章,转载请注明: 转载自贝壳博客

本文链接地址: VSCode 在Windows下安装cmake tools插件使用msys2开发环境

如何使用NodePlayer.js播放RTMP协议

简述

NodePlayer.js设计之初只是为了播放http-flv协议,但经常有客户想要知道能否播放RTMP协议,甚至RTSP协议,以往我们的回答都是不能。web浏览器没有开放TCP/UDP协议,当然无法实现RTMP、RTSP播放了。

但从 NodePlayer.js-v0.7版本开始,我们已经实现RTMP协议的播放了!
当然,不是TCP协议的RTMP, 没有这个基础条件。我们实现的方式,是通过WebSocket协议来和一个 websocket 2 tcp 服务交换协议,最终和RTMP服务器建立连接。

本播放器无需flash插件,和video.js等播放RTMP的方式完全不同。

目的

如果您正在构建新的直播项目,其实无需使用本技术。如今的流媒体服务端或者云服务,基本上都支持HTTP-FLV甚至WebSocket-FLV。
本功能是为以往使用Flash-Media-Server, Adobe-Media-Server, Nginx-RTMP, Red5,Wowza等服务端构建项目的用户,在不改变现有架构的条件下,无痛迁移到HTML5播放器。

部署方法

实际上无需过多要求,只需要一个 websocket to tcp的桥接服务。
这里,我们以一个非常轻量级,且开放源代码的ws-tcp-relay项目为例。
项目地址:https://github.com/isobit/ws-tcp-relay

进入https://github.com/isobit/ws-tcp-relay/releases ,根据服务端系统选择并下载应用程序

下载后,linux系统下添加可执行权限,然后执行

 ./ws-tcp-relay -b  -p 8080 192.168.0.3:1935

参数说明:
-b 使用binary格式传输
-p 绑定本机8080端口监听websocket连接
192.168.0.3:1935 需要桥接的远端或者本地 rtmp服务,本机可以填 127.0.0.1:1935

播放方法

使用NodePlayer.js-v0.7版播放器,播放地址

rtmp://运行ws-tcp-relay服务的ip:8080/live/stream

即可

如果要去掉端口号, ws-tcp-relay改为监听80端口,但可能会和webserver冲突
这里不清楚nginx反向代理是否有能力转websocket to tcp,如果能的话那就更方便。

播放器演示地址

http://www.nodemedia.cn/uploads/nodeplayer_rtmp.html

使用前请先运行ws-tcp-relay服务

RTSP流?

理论上,也是可以的,敬请期待。

原创文章,转载请注明: 转载自贝壳博客

本文链接地址: 如何使用NodePlayer.js播放RTMP协议

WordPress 在国内机房安装插件主题总是出现429 Too Many Requests错误的解决办法

这种情况不管是本地运行WordPress还是阿里云ecs上,安装更新、插件、主题,都会出现。估计是woredpress的cdn对国内ip做了限流。

更新失败:下载失败。 Too Many Requests

我解决的办法是给添加一个http proxy来解决,注意一定要是http_proxy,socks5请加一层代理转换,比如privoxy。

非常简单,打开wp-config.php,在合适的位置添加:

define('WP_PROXY_HOST', '127.0.0.1');
define('WP_PROXY_PORT', '8118');
define('WP_PROXY_BYPASS_HOSTS', 'localhost');