import subprocess
def download_bilibili_video(video_url):
try:
# 使用you-get下载视频,-o指定输出目录(这里是当前目录)
subprocess.run([‘you-get’, ‘-o’, ‘.’, video_url], check=True)
print(“视频下载成功!”)
except subprocess.CalledProcessError as e:
print(“下载过程中出现错误:”, e)
if name == “main”:
video_url = “https://www.bilibili.com/video/BV13N4y1U76M/”
download_bilibili_video(video_url)
以上是使用爬虫爬取哔哩哔哩视频的页面链接的视频的程序
爬虫爬取视频的组件
pip install you-get
以下是音频视频合并的程序代码
import subprocess
def merge_video_audio(video_file, audio_file, output_file):
try:
subprocess.run([‘C:\ffmpeg-master-latest-win64-gpl-shared\bin\ffmpeg.exe’, ‘-i’, video_file, ‘-i’, audio_file, ‘-c:v’, ‘copy’, ‘-c:a’, ‘aac’, ‘-strict’, ‘experimental’, output_file], check=True)
print(“视频和音频合并成功!”)
except subprocess.CalledProcessError as e:
print(“合并过程中出现错误:”, e)
if name == “main”:
video_file = “程响《可能》:无损音质完整版[00].mp4”
audio_file = “程响《可能》:无损音质完整版[01].mp4”
output_file = “程响-可能.mp4”
merge_video_audio(video_file, audio_file, output_file)