Nb
Study
.com
🔍 请输入搜索关键字

Windows 子系统中配置 Rust国内镜像以解决cargo run太慢的问题

Cargo则是Rust的官方包管理工具。在进行Rust项目开发时,由于网络原因,从Crates.io下载依赖可能会很慢。为此可以配置Cargo使用国内的镜像源。

在 Windows 子系统的 Linux 发行版中,打开终端,在用户主目录下找到.cargo文件夹,若不存在可新建。在该文件夹中创建或编辑config文件,添加国内镜像源配置内容:

配置国内镜像源

bash 复制代码
[source.crates-io]
replace-with = 'aliyun'
[source.aliyun]
registry = "sparse+https://mirrors.aliyun.com/crates.io-index/"
[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index/"
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
[source.rustcc]
registry = "https://code.aliyun.com/rustcc/crates.io-index.git"                                                             

清理 Cargo 缓存

删除.cargo目录下的.package-cache文件:

bash 复制代码
rm $HOME/.cargo/.package-cache

使用config.toml

如果是rust 1.38 及以后的版本,推荐 使用config.toml 代替 config
否则会有一下警告。

即:

toml 复制代码
[source]
[source.crates-io]
replace-with = "aliyun"

[source.aliyun]
registry = "sparse+https://mirrors.aliyun.com/crates.io-index/"

[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"

[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index/"

[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

[source.rustcc]
registry = "https://code.aliyun.com/rrustcc/crates.io-index.git"

注意,toml 配置的写法稍有不同。

如何在线查看mp4视频的编码格式,是否为iOS兼容的h264格式

记录一下,可以在线查询mp4编码格式的网站:

https://gpac.github.io/mp4box.js/test/filereader.html

通常H264的格式的文件编码信息如下:

Movie Info

File Size / Bitrate: 0 bytes / 0 kbps
Duration / Timescale: 220845/1000 (0:03:40.845)
Brands (major/compatible): isom,isom,iso2,avc1,mp41
MIME: video/mp4; codecs="avc1.42c01f,mp4a.40.2"; profiles="isom,iso2,avc1,mp41"
Progressive: false
Fragmented: false
MPEG-4 IOD: false

重点查看MIME类型是否为video/mp4,是否包含avc信息。且 Progressive/Fragmented/MPEG-4 IOD 三个参数为false。

另外iOS支持的编码格式可以通过官方查看:
https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/FrequentlyAskedQuestions/FrequentlyAskedQuestions.html

What are the specifics of the video and audio formats supported?
Although the protocol specification does not limit the video and audio formats, the current Apple implementation supports the following formats:

  • Video:
    H.264 Baseline Level 3.0, Baseline Level 3.1, Main Level 3.1, and High Profile Level 4.1.

  • Audio:
    HE-AAC or AAC-LC up to 48 kHz, stereo audio
    MP3 (MPEG-1 Audio Layer 3) 8 kHz to 48 kHz, stereo audio
    AC-3 (for Apple TV, in pass-through mode only)

npm报错:request to https://registry.npm.taobao.org failed, reason certificate has expired

最新一个老项目,在使用 npm install 时, 总是报错:

npm报错:request to https://registry.npm.taobao.org failed, reason certificate has expired

很明显原因是淘宝镜像过期了!

通过npm config get registry 查询本地的npm镜像:

bash 复制代码
apple@AppledeMacBook-Pro h5 % npm config get registry                                              
https://registry.npmmirror.com/

发现明明已经切换到新的镜像了啊,为什么还是报错呢?

原因是项目本地的package-lock.json 文件导致的,删除即可。