【问题标题】:Use list of dates to timestamp / label mp4 video in python在python中使用日期列表来时间戳/标记mp4视频
【发布时间】:2021-03-25 18:19:57
【问题描述】:

我有一个在 Google 地球引擎中创建的 MP4 视频文件 (Amundsen.mp4) - 延时摄影和每个图像的日期列表 (dates.txt) - 不是所有连续的日子。

我想使用这个日期列表在 python 中为视频中的每一帧添加时间戳。有人可以建议如何做,或者向我指出一个这样做的教程吗?我还没有找到有关如何以这种方式处理视频的资源。

【问题讨论】:

标签: python python-3.x video-processing timelapse


【解决方案1】:

感谢 cmets 我成功了。这是我成功的代码

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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-17
    • 1970-01-01
    • 1970-01-01
    • 2021-05-05
    • 1970-01-01
    • 1970-01-01
    • 2018-02-07
    • 1970-01-01
    相关资源
    最近更新 更多