我使用 python 库发送了此视频(首先使用热图,第二个使用 telethon,但我已将它们作为客户端发送),我得到了这个
(较小的视频可以正确发送)
我的朋友说他们也看不到(我可以在手机上观看和下载它们,虽然也说这个视频是0:00长)
我希望视频能够正确发送
我使用 MoviePy 库 提取视频信息(元数据)并在发送视频之前生成缩略图。效果很好。我是这样做的:
from moviepy.editor import VideoFileClip
import os
try:
video_clip = VideoFileClip(file_path)
# Extract video information
video_title = os.path.basename(file_path)
video_duration = int(video_clip.duration)
video_width = video_clip.w
video_height = video_clip.h
# Extract thumbnail (first frame)
thumbnail_path = f"./downloads/{video_title.split('.')[0]}_thumbnail.jpg"
# Save the first frame as a thumbnail
video_clip.save_frame(thumbnail_path, t=30)
video_clip.close() # Close the video after extracting information
except Exception as e:
# await message.reply_text(f"❌ Error extracting metadata: {e}")
video_title = "Unknown Title"
video_duration = 0
video_width = 0
video_height = 0
thumbnail_path = None
# Send video along with metadata and thumbnail
if thumbnail_path:
with open(thumbnail_path, 'rb') as thumb_file:
file_main = await message.reply_video(
video=file_path,
caption=video_title,
duration=video_duration,
width=video_width,
height=video_height,
thumb=thumb_file
)
if thumbnail_path and os.path.exists(thumbnail_path):
os.remove(thumbnail_path) # Delete thumbnail after sending
else:
file_main = await message.reply_video(
video=file_path,
caption=video_title,
duration=video_duration,
width=video_width,
height=video_height
)
它对我来说效果很好。