提交 eea47c4a 编写于 作者: 三月三net's avatar 三月三net

Python超人-宇宙模拟器

上级 4f2d738c
import os
import subprocess
def get_exists_files(output_dir):
return [i[:-2] + "kv" for i in os.listdir(output_dir)]
def convert_mkv_to_mp4(input_dir, output_dir):
# 确保输出目录存在
os.makedirs(output_dir, exist_ok=True)
exists_files = get_exists_files(output_dir)
# 遍历输入目录中的所有文件
for filename in os.listdir(input_dir):
if filename in exists_files:
continue
if filename.endswith('.mkv'):
input_file = os.path.join(input_dir, filename)
output_file = os.path.join(output_dir, filename[:-4] + '.mp4')
# 使用 ffmpeg 进行转换
command = ['ffmpeg', '-i', input_file, output_file]
subprocess.run(command)
print(f'Converted: {input_file} to {output_file}')
# 使用示例
input_directory = r'E:\琅琊榜mkv' # 替换为你的输入目录
output_directory = r'D:\琅琊榜' # 替换为你的输出目录
convert_mkv_to_mp4(input_directory, output_directory)
......@@ -73,17 +73,36 @@ class 星球:
self.轨迹.pop(0)
# 创建星球列表
星球列表 = [
星球(质量=1e12, 位置=[0, 0], 速度=[0, 1], 颜色='red', 名称="太阳", 名称偏移=[2, 0]),
星球(质量=1e9, 位置=[10, 0], 速度=[0, 2], 颜色='blue', 名称="蓝星"),
星球(质量=1e9, 位置=[-10, 0], 速度=[0, -2], 颜色='green', 名称="绿星")
]
# 初始化图形
图形, 坐标轴 = plt.subplots()
坐标轴.set_xlim(-50, 50)
坐标轴.set_ylim(-20, 80)
星球列表 = []
def 场景1():
global 星球列表
# 创建星球列表
星球列表 = [
星球(质量=1e12, 位置=[0, 0], 速度=[0, 1], 颜色='red', 名称="太阳", 名称偏移=[2, 0]),
星球(质量=1e9, 位置=[10, 0], 速度=[0, 2], 颜色='blue', 名称="蓝星"),
星球(质量=1e9, 位置=[-10, 0], 速度=[0, -2], 颜色='green', 名称="绿星")
]
坐标轴.set_xlim(-50, 50)
坐标轴.set_ylim(-20, 80)
def 场景2():
global 星球列表
星球列表 = [
星球(质量=1e12, 位置=[10, 0], 速度=[0, 1], 颜色='blue', 名称="蓝星", 名称偏移=[2, 0]),
星球(质量=1e12, 位置=[-10, 0], 速度=[0, -1], 颜色='green', 名称="绿星", 名称偏移=[2, 0])
]
坐标轴.set_xlim(-50, 50)
坐标轴.set_ylim(-50, 50)
# 场景1()
场景2()
# 调整边距
plt.subplots_adjust(left=0.05, bottom=0.04, right=0.97, top=0.97, wspace=0.4, hspace=0.4)
点列表 = [坐标轴.plot([], [], 'o', color=星球.颜色, markersize=星球.大小)[0] for 星球 in 星球列表]
......@@ -129,4 +148,4 @@ def 更新(帧):
动画 = FuncAnimation(图形, 更新, frames=range(1000), init_func=初始化, blit=True, interval=2)
# 显示动画
plt.show()
\ No newline at end of file
plt.show()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册