0

I have an MP4 video file (Amundsen.mp4) that I created in Google Earth Engine - a timelapse, and a list of dates of each image (dates.txt) - not all consecutive days.

I want to use this list of dates to timestamp each frame in the video in python. Could someone please suggest how, or point me towards a tutorial that does this? I have not found resources on how to work with a video in this way.

Beardsley
  • 151
  • 5
  • Are you pertaining to printing the list of dates from dates.txt to the frames of your video? – Ricco D Dec 15 '20 at 09:11
  • Yes, that's right. – Beardsley Dec 15 '20 at 15:56
  • Does this answer your question? [Annotating video frames with a label based on state](https://stackoverflow.com/questions/30028841/annotating-video-frames-with-a-label-based-on-state) – albert Dec 15 '20 at 15:58
  • You can try checking this [tutorial](https://www.geeksforgeeks.org/moviepy-inserting-text-in-the-video/?ref=lbp). Instead of hard coding the text, you can loop on your dates.txt. – Ricco D Dec 16 '20 at 01:04
  • Thank you - the tutorial alongside this thread https://stackoverflow.com/questions/28429005/create-a-series-of-text-clip-and-concatenate-them-into-a-video-using-moviepy helped – Beardsley Dec 17 '20 at 05:32

1 Answers1

0

Thanks to the comments I succeeded. This was my successful code

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)
Beardsley
  • 151
  • 5