使用日期列表为 python 中的 mp4 视频添加时间戳/标签
Use list of dates to timestamp / label mp4 video in python
我有一个在 Google Earth Engine 中创建的 MP4 视频文件 (Amundsen.mp4) - 延时摄影和每张图像的日期列表 (dates.txt) - 不是连续的天。
我想使用此日期列表为 python 中视频中的每一帧添加时间戳。有人可以建议怎么做,或者给我指一个教程吗?我还没有找到有关如何以这种方式处理视频的资源。
感谢评论,我成功了。这是我成功的代码
from moviepy.editor import *
clip = VideoFileClip("myvideo.mp4")
text_list = list3 # List of dates
clip_list = []
for text in text_list:
try:
txt_clip = TextClip(text, fontsize = 70, color = 'red').set_duration(1)
clip_list.append(txt_clip)
except UnicodeEncodeError: #Unsure if this part is necessary, took from elsewhere to address someone else's issue, but doesn't cause a problem
txt_clip = TextClip("Issue with text", fontsize = 70, color = 'red').set_duration(1)
clip_list.append(txt_clip)
datevideo = concatenate(clip_list, method = "compose")
video2 = CompositeVideoClip([clip, datevideo])
#Write video
video2.write_videofile("videotest.mp4", fps = 1, codec = 'mpeg4')
# show video here embdeedded
#video2.ipython_display(width = 280)
我有一个在 Google Earth Engine 中创建的 MP4 视频文件 (Amundsen.mp4) - 延时摄影和每张图像的日期列表 (dates.txt) - 不是连续的天。
我想使用此日期列表为 python 中视频中的每一帧添加时间戳。有人可以建议怎么做,或者给我指一个教程吗?我还没有找到有关如何以这种方式处理视频的资源。
感谢评论,我成功了。这是我成功的代码
from moviepy.editor import *
clip = VideoFileClip("myvideo.mp4")
text_list = list3 # List of dates
clip_list = []
for text in text_list:
try:
txt_clip = TextClip(text, fontsize = 70, color = 'red').set_duration(1)
clip_list.append(txt_clip)
except UnicodeEncodeError: #Unsure if this part is necessary, took from elsewhere to address someone else's issue, but doesn't cause a problem
txt_clip = TextClip("Issue with text", fontsize = 70, color = 'red').set_duration(1)
clip_list.append(txt_clip)
datevideo = concatenate(clip_list, method = "compose")
video2 = CompositeVideoClip([clip, datevideo])
#Write video
video2.write_videofile("videotest.mp4", fps = 1, codec = 'mpeg4')
# show video here embdeedded
#video2.ipython_display(width = 280)