基于开源项目VidMuse,针对Ascend NPU做亲和适配。VidMuse是一个用于生成与视频输入相匹配音乐的框架。其突出之处在于能够生成与视频在声学和语义上高度一致的高保真音乐。VidMuse利用长短期模型(LST)生成与视频内容始终匹配的连贯音轨。大量实验表明,VidMuse在音频质量、多样性和视听匹配度方面均优于现有模型。
git clone https://atomgit.com/Ascend-SACT/VidMuse.git cd VidMuse pip3 install -r requirements.txt
yum install ffmpeg-devel
git clone --recursive https://gh-proxy.org/https://github.com/dmlc/decord.git
cd decord && mkdir build && cd build
cmake .. -DUSE_CUDA=OFF
make -j4
ffmpeg -version | grep "version"
如果ffmpeg版本高于5.1,需要修改decord源码,随后重新编译make -j4:
——————————————————————————————————————————————————————————————————————————————
--- a/src/video/ffmpeg/ffmpeg_common.h
+++ b/src/video/ffmpeg/ffmpeg_common.h
@@ -20,6 +20,7 @@
extern "C" {
#endif
#include <libavcodec/avcodec.h>
+#include <libavcodec/bsf.h>
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
#include <libavfilter/avfilter.h>
——————————————————————————————————————————————————————————————————————————————
--- a/src/video/video_reader.cc
+++ b/src/video/video_reader.cc
@@ -147,8 +147,8 @@
void VideoReader::SetVideoStream(int stream_nb) {
if (!fmt_ctx_) return;
- AVCodec *dec;
- int st_nb = av_find_best_stream(fmt_ctx_.get(), AVMEDIA_TYPE_VIDEO, stream_nb, -1, &dec, 0);
+ const AVCodec *dec;
+ int st_nb = av_find_best_stream(fmt_ctx_.get(), AVMEDIA_TYPE_VIDEO, stream_nb, -1, &dec, 0);
// LOG(INFO) << "find best stream: " << st_nb;
CHECK_GE(st_nb, 0) << "ERROR cannot find video stream with wanted index: " << stream_nb;
// initialize the mem for codec context
——————————————————————————————————————————————————————————————————————————————
cd ../python && pip install .
尝试导入python -c "import decord"
如果存在库相关报错,动态导入:
export LD_PRELOAD="/usr/lib64/libavformat.so.60:/usr/lib64/libavfilter.so:/usr/lib64/libavcodec.so.60"1、将 model_config.py 中的 vidmuse_ckpt_path 替换为用户本地的权重路径
2、指定 test_pipeline.py 中的 video_path 和 output_dir(若不想保存生成的音频及合成的新视频,将 save_audio 和 save_video 设置为 False 即可)
3、运行 test_pipeline.py