Display date and time in videos using OpenCV - Python Last Updated : 11 Aug, 2025 Comments Improve Suggest changes Like Article Like Report In video processing, adding a timestamp directly onto video frames is a useful feature for applications like surveillance, monitoring and logging. Using OpenCV in Python, we can capture each video frame and overlay the current date and time fetched from the datetime module, making the video feed more informative and time-aware.Prerequisites: Opencv moduledatetime moduleApproachTo display the current date and time on video frames:Capture the video using cv2.VideoCapture().Read video frames in a loop.Fetch the current system time using datetime.datetime.now().Use cv2.putText() to overlay the timestamp on each frame.Display the updated frames until the video ends or the user quits.Python Implementation Python import cv2 import datetime vid = cv2.VideoCapture('sample.mp4') while vid.isOpened(): ret, frame = vid.read() if not ret: break font = cv2.FONT_HERSHEY_SCRIPT_COMPLEX dt = str(datetime.datetime.now()) frame = cv2.putText(frame, dt, (10, 100), # Position (x, y) font, 1, # Font and scale (210, 155, 155), # Color (B, G, R) 2, # Thickness cv2.LINE_8) # Line type cv2.imshow('Video with Date & Time', frame) key = cv2.waitKey(1) if key == ord('q') or key == 27: # Quit on 'q' or ESC break vid.release() cv2.destroyAllWindows() OutputExplanation: Cv2.VideoCapture('sample.mp4') opens the video file and creates a capture object.vid.read() reads frames one by one; ret indicates success, and frame contains the image.datetime.datetime.now() gets the current system date and time.cv2.putText(frame, dt, ...) overlays the date & time text onto each video frame.cv2.imshow('Video with Date & Time', frame) displays the video with the timestamp in a window.cv2.waitKey(1) waits for a key press and pressing q or ESC exits, then vid.release() frees the video and cv2.destroyAllWindows() closes windows. Comment More infoAdvertise with us K KaranGupta5 Follow Improve Article Tags : Python OpenCV Python-OpenCV Practice Tags : python Explore Python FundamentalsPython Introduction 3 min read Input and Output in Python 4 min read Python Variables 5 min read Python Operators 5 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 7 min read Python Functions 8 min read Recursion in Python 6 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 5 min read Python Tuples 4 min read Dictionaries in Python 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 6 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 2 min read Python MySQL 9 min read Python Packages 12 min read Python Modules 7 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 11 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 6 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 15+ min read StatsModel Library- Tutorial 4 min read Learning Model Building in Scikit-learn 8 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 7 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 10 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 7 min read Python | Build a REST API using Flask 3 min read How to Create a basic API using Django Rest Framework ? 4 min read Python PracticePython Quiz 3 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like