Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8582759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:22:22+00:00 2026-06-11T21:22:22+00:00

The Project: Add a running date/time stamp on each and every frame of a

  • 0

The Project: Add a running date/time stamp on each and every frame of a video. (The result of digital video camera, and my father asked me how can he add the timestamp(to the milliseconds resolution) permanently to the video.

A friend pointed me to opencv (emgucv actually) , and because of my preferences I tried my luck with opencv in python.

The documentation is lame, and I had even hard time(took me like 5 hours or so) just to install the package.
Sources:

  • OpenCV 2.4 (willow garage): http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.2/
  • Numpy (I didn’t even understood what does it do or why needed): http://sourceforge.net/projects/numpy/files/NumPy/1.6.2/numpy-1.6.2-win32-superpack-python2.7.exe/download
  • Active Python 2.7: http://downloads.activestate.com/ActivePython/releases/2.7.2.5/ActivePython-2.7.2.5-win32-x86.msi

I am working on Windows 7 x64 , so I had to downgrade my python to work with numpy(no numpy version for win64)

Working with PyCharm IDE.

The resulting installation got me to have the file C:\Python27\Lib\site-packages\cv2.pyd

I am trying to find documentation to start working with, but I am very confused and have no clue where to start from, all the examples are confusing – ie:

  • The “official” documentation is for c/c++, no python references: http://docs.opencv.org/doc/user_guide/ug_mat.html
  • Example for python that seems reasonable but not close to what i need: Python OpenCV 2.4 writes half-complete PNG video frames
  • Example that is close to what I need, but doesn’t seem logical(cv and not cv2 ???): Writing video with OpenCV + Python + Mac

My Questions:

  1. Am i doing something wrong? Is this not the way to install opencv?
  2. Where can i find good documentation?
  3. Suppose i have my text ready(in a string) can somebody try to help me with a start to my application?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:22:24+00:00Added an answer on June 11, 2026 at 9:22 pm

    Your task should be relatively easy to accomplish using OpenCV and Python. It seems that you are new to OpenCV, so I will try and keep my explanation thorough, but feel free to ask if you need any clarity.

    I am not sure if you are getting your data from a live camera video feed, or are post-processing recorded footage. Either way…

    Get data.
    If using a live feed:

    capture = cv2.VideoCapture(0)
    

    If using recorded footage:

    capture = cv2.VideoCapture("your_reading_file.avi")
    

    Initialise video writer. Look at this question for help with codecs- finding a working codec is not trivial. I am also using Windows 7 x64, and the below-mentioned codec was the only one that worked for me. Also, set the variable fps as close to the actual incoming video framerate as possible- you can not change it once you have started writing frames.

    flag, frame = capture.read() # **EDIT:** to get frame size
    width = np.size(frame, 1) #here is why you need numpy!  (remember to "import numpy as np")
    height = np.size(frame, 0)
    writer = cv2.VideoWriter(filename="your_writing_file.avi", 
    fourcc=cv2.cv.CV_FOURCC('I', 'Y', 'U', 'V'), #this is the codec that works for me
    fps=15, #frames per second, I suggest 15 as a rough initial estimate
    frameSize=(width, height))
    

    Process this data and add your text. Lastly, write the edited frame to a video file.

    while True:
        flag, frame = capture.read() #Flag returns 1 for success, 0 for failure. Frame is the currently processed frame
    
        if flag == 0: #Something is wrong with your data, or the end of the video file was reached
            break 
        x = width/2
        y = height/2 #change to the desired coordinates
        text_color = (255,0,0) #color as (B,G,R)
        cv2.putText(frame, "your_string", (x,y), cv2.FONT_HERSHEY_PLAIN, 1.0, text_color, thickness=1, lineType=cv2.CV_AA)
    
        writer.write(frame) #write to the video file
    

    As simple as that! I use the above code to write text to video files almost daily, so it definitely works. The only potential problems I can foresee are with the codecs, which I unfortunately do not know a lot about. I hope that this may solve your problem, feel free to ask more questions.

    EDIT: Answers to your comment’s questions.

    1.) As far as I know, you can only use .avi because you have to use an uncompressed format with OpenCV. I am afraid I have no knowledge of using other (compressed) formats. Maybe you could use a third-party program to do pre/post-conversion? The reason for the frame exception was my mistake, I have edited the answer to include the missing line.

    2.) I’m afraid I have no idea how to read metadata. If I find out I will let you know. My own hackish solution for finding video framerate is to let OpenCV run through the video once, using the Time module to calculate the average framerate. This estimate can then be used when writing the video file.

    3.) I have found that the size of the resulting video may differ significantly from the original depending on several factors, the most important being how close the chosen fps was to the actual original framerate.

    4.) As for other fonts, there are several available. I can refer you to this question for a quick overview. Here is the relevant documentation:

    fontFace – Font type. One of FONT_HERSHEY_SIMPLEX, 
    FONT_HERSHEY_PLAIN, 
    FONT_HERSHEY_DUPLEX, 
    FONT_HERSHEY_COMPLEX, 
    FONT_HERSHEY_TRIPLEX, 
    FONT_HERSHEY_COMPLEX_SMALL, 
    FONT_HERSHEY_SCRIPT_SIMPLEX, or 
    FONT_HERSHEY_SCRIPT_COMPLEX, 
    where each of the font ID’s can be combined with FONT_HERSHEY_ITALIC to get the slanted letters.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a joomla project now currently running on.I need to add a separate
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
In my project I add reference on the WPFToolkit assembly, restart Visual Studio and
I'm creating a simple CMS using kohana3 in which user can add project to
i made a windows service & add project installer.in which only contain this code.
Im trying to create application from scratch. In new maven project i add a
I created a Word 2007 add-in project in C# that works fine on my
I am trying to add my project under source control. I am using Microsoft
My android app project need to add a new function of saving the click
I have made a new Excel 2010 Add-in project, with VS10. When I run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.