高清下载视频网站视频到本地

本方法验明适用网站:油管、哔站

下载工具并安装:

yt-dlp官网地址:

GitHub - yt-dlp/yt-dlp: A feature-rich command-line audio/video downloader

ffmpeg官网地址: 

Download FFmpeg

注:记住为其添加环境变量

操作命令:

该指令表示以720p码率下载VIDEO_URL所包含的视频
yt-dlp.exe -f "bestvideo[height=720]+bestaudio/best[height=720]" "VIDEO_URL"

该下载方式为音视频分开下载,之后yt-dlp可能将其合并为webm格式的视频,如果想得到mp4格式的视频,需要再转一道码

命令一:
ffmpeg -i "video.webm" -c:v copy -c:a aac "video.mp4"

命令二:
ffmpeg -i "video.webm" -c:v libx264 -c:a aac "video.mp4"

命令二转换时会稍慢,但兼容性更好。

HEVC转AVC

HEVC(H.265)转AVC(H.264)命令:

下载时指定编码:
yt-dlp -f "bestvideo[ext=mp4][vcodec^=avc1]+bestaudio" [视频URL]

转码命令:
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset fast -c:a copy output.mp4

### Best-First Search算法实例 #### 实例一:迷宫求解 假设有一个简单的迷宫,由网格组成,其中某些格子不可通行。目标是从起点找到到达终点的最短路径。 ```plaintext S代表起始位置,G代表目标位置,#表示障碍物,.为空白区域可以行走。 ``` 给定如下迷宫: ``` S . . # . . # . . . . . . # G # . . . # . . # . . ``` 为了应用Best-First Search算法来解决这个问题,需要定义一个启发式函数h(n),用于估计节点n到目标的距离。这里可以选择曼哈顿距离作为启发式的度量标准[^1]。 对于每一个可能移动的方向(上下左右),计算新位置对应的h值,并选取最小的那个方向前进直到遇到新的分支点或是达到目的地为止。 #### Python实现示例 ```python from heapq import heappop, heappush def manhattan_distance(point_a, point_b): """Calculate Manhattan Distance between two points.""" return abs(point_a[0]-point_b[0]) + abs(point_a[1]-point_b[1]) def best_first_search(maze, start, end): open_list = [] closed_set = set() # Push initial state onto heap with priority based on heuristic cost estimate. heappush(open_list, (manhattan_distance(start, end), start)) while open_list: _, current_position = heappop(open_list) if current_position == end: break if current_position in closed_set: continue neighbors = get_neighbors(current_position, maze) for neighbor in neighbors: if neighbor not in closed_set: heappush(open_list, (manhattan_distance(neighbor, end), neighbor)) closed_set.add(current_position) return "Path found!" if end in closed_set else "No path exists." def get_neighbors(position, maze): directions = [(0,-1),(0,1),(-1,0),(1,0)] # Left Right Up Down valid_moves = [] for direction in directions: new_x = position[0]+direction[0] new_y = position[1]+direction[1] if 0<=new_x<len(maze) and 0<=new_y<len(maze[new_x]): if maze[new_x][new_y]!='#': valid_moves.append((new_x,new_y)) return valid_moves ``` 此代码片段展示了如何利用Python编写基于优先队列的数据结构来进行Best-First Search搜索过程中的状态管理以及通过启发式评估指导探索顺序的方法。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值