GoPro Timestamp

In this project we will set the internal clock on the GoPro and then use that to add a timestamp overlay onto our videos.


This is a GoPro camera that we attached a commercial trawl net.
GoPro camera attached to a commercial trawl net

I was working on a project this summer in which we placed multiple GoPro cameras on a commercial fishing trawl.  For this project I was looking for a way to synchronize the data collected from multiple cameras.  My first thought was to use the WiFi remote to turn on all the cameras at the same time.  This would synchronize the cameras but I didn't trust it and leaving the WiFi on would shorten the battery life.  Additionally, this process would link the cameras but I would then have to match them to a clock in the outside world to interpret the data.  I decided to use the internal clock of the GoPro to put a timestamp on the video files.  The camera clocks were synchronized to the clock on my computer.  This allowed for comparisons between cameras, with other instrumentation on the net and to real world events.  Overall the script worked for what was needed.  In addition to the basic timestamp I added a filewalker for batch processing and added data from a nearby depth sensor to the text overlay. In the future I would like to work on speeding the program up.  Additionally, due to limitations in the OpenCV libraries the audio is removed from the file and the file is converted from MP4 to AVI.


This script has been tested on GoPro Hero 2, 3 black and 3+ black models.

Software used:

Project Files

This python file adds a timestamp to any GoPro video. This website service saves the file as a text file, remove the .txt extension to use with python.
Text Document 3.6 KB
FFProbe file
Compressed Archive in ZIP Format 12.5 MB

How it works

Step 1: Set the clock time on the GoPro

If your only interested in relative time, for measuring the duration of an event for instance, then you can skip this step.  If your interested on having your videos stamped with the real-world time or having them synchronized with other cameras then you need to set the correct clock time.  Unfortunately, the settings menu within the GoPro only allows you to set the minutes and hours, not the seconds.  For more accuracy you can set the time using the GoPro app on your smartphone or tablet over WiFi or using the WiGo program for desktop computers (also uses WiFi).

Step 2: Take some video

Shoot away!

Checking the GoPro camera and the net before it goes overboard.
Checking the camera and the net before it goes overboard.

Step 3: Adding the timestamp (post-processing)

For this script to work place the script file ( and FFProbe into the folder with your GoPro video.  Open the script in your python editor of choice.  Change the line of the script with the filename you wish you timestamp, then run the script.

A python script for adding a timelapse overlay onto our GoPro video.

This script works by creating a call to FFProbe which returns the metadata from the MP4 file of interest.  When the GoPro camera creates a video file the creation time is embedded into the files metadata.  FFProbe returns all the metadata which is then parsed down to the creation time.  This value is then used to initiate a counter.  OpenCV then loops through each frame adds the timestamp, exports it to the return file and then adds the frame duration to the counter.  This script takes some time to run, depending on the length of the file.  You can press the 'esc' button to cancel out at anytime.


I have added an updated script.  This uses OpenCV 3.  Additioanlly, this one uses the full FFmpeg pipeline to encode and save the video frames.  This results in a faster, better compression with a bit more flexibility for different codecs, if people feel like venturing down that path.  The only requirement is to place the ffmpeg.exe file in the same folder as the script.  Everything else works the same.  To get the latest copy of FFmpeg follow this link.  Download the latest static library.  Unzip it.  The appropriate files should be located in the bin folder.

Updated script with FFmpeg and OpenCV 3.0
Compressed Archive in ZIP Format 1.8 KB



Adding a filewalking function will go through a folder and timestamp any and all MP4 files.  This is great for loading up a queue and batch processing a group of files.  Set them up and go home for the night.  The file attached below works the same as the base script except that it uses the os.walk() function in Python which creates a list of every file in the directory.  Each file is iterated through.  If it contains a '.MP4' file extension then the timestamp script is executed.  Currently the filewalker is set-up to only go through the folder listed in the script.  It can be set-up to run through sub-folders in needed.


To execute this script, place it and FFProbe in the folder containing your videos.  Tell the script the directory to start its search by changing the indir line.  Then let her rip.

A python script for batch processing the videos to add a timestamp overlay.
GoPro Timestamp with filewalker
This is the base timestamp file with a filewalker added.
Text Document 4.1 KB

Data Overlay

An underwater video still frame shown the timestamp and data overlay.
An video still frame showing the timestamp and data overlay.

The last modification that I made was to add data from a nearby depth sensor to the video.  Any data with a timestamp can be overlaid onto the video creating a HUD (heads up display) like system.  This can be a powerful tool to correspond observations in the video to external events.


For this project we used an RBR depth sensor programmed to record depth and pressure every second.  The data was exported to a text file and the headers were stripped from the file, a sample file is attached below.  Having the depth sensor capture data every second allowed me to match the time (hh:mm:ss) of the videos timestamp with the time of the depth data.  Matching the time was done by stripping the video time of the milliseconds value and then searching for a corresponding time value in the depth data.  The Python dictionary data structure provided a novel way to store and search the data file.


To execute this script, place all the files (video, ffprobe, script and external data file) in the same folder.  Change the data_name and video_filename, within the script, to the files of interest and run the script.  I have additionally add another file which combines both the filewalker feature and the data overlay.  This script uses a single external data file but can process a batch of video files.  As such the user must make sure all the applicable external data is placed in the file for the span of video files being processed. 

GoPro Timestamp with External Data
Text Document 4.5 KB
Sample external data
Text Document 2.9 MB
GoPro Timestamp with a Filewalker and External Data Overlay
Text Document 4.4 KB
Basic GoPro timestamp with a image/watermark overlay
Text Document 3.7 KB

Write a comment

Comments: 89
  • #1

    TF (Tuesday, 13 January 2015 18:01)

    I get this error message after running :

    >>> ================================ RESTART ================================

    Traceback (most recent call last):
    File "C:\Users\friertnf\Desktop\test timestamp\", line 47, in <module>
    frame_lapse = (1/FPS)*1000
    ZeroDivisionError: float division by zero

  • #2

    CR (Wednesday, 14 January 2015 09:29)

    Hello TF,

    It looks like the video file is not being loaded. Here is script is trying to figure out the time between frames but it looks like the FPS variable is 0 (i.e. something isn't correct with the import). Check that the filename within the script is correct. If the file is placed in the same folder as the script then it can look like this:
    filename = 'Test_video.MP4'
    If the file is located outside the script folder then you need to add the directory information.
    filename = 'C:\Some_folder\Test_video.MP4'
    If that looks OK, you can test the video playback with the following script:
    import cv2

    filename = 'Tow2_T45CE_DMFH3_1.MP4'
    video = cv2.VideoCapture(filename)
    total_frames = video.get(
    current_frame = 0

    while current_frame < total_frames:
    success, image =
    current_frame = video.get(
    cv2.imshow('Video', image)

    k = cv2.waitKey(33)
    if k == 27:


    I hope this helped.

  • #3

    theeminentcodfish (Wednesday, 14 January 2015 11:53)

    If it is a codec problem. Check out this page:

    Try the second answer. I think that this is what worked for me a while ago.

  • #4

    TF (Wednesday, 14 January 2015 12:07)

    OK cool, I fixed the indentation, and NO error messages using a Python shell 2.7.8, but no success at playback. This error using Spyder (Python 2.7): ... video.release()
    File "<stdin>", line 11
    SyntaxError: invalid syntax

    I will try the codec fix.

  • #5

    theeminentcodfish (Thursday, 15 January 2015 08:28)

    Did you try the following response on the previous website:
    I have the same issue before, solved by this step :

    Check your OpenCV python version

    >>> from cv2 import __version__
    >>> __version__

    Then Copy your opencv_ffmpeg.dll to C:\Python27\ and rename it to relevant your OpenCV Python Version. in my case I should rename it to opencv_ffmpeg240.dll

    I found this file in the OpenCV directory under opencv/build/x86/vc12/bin.

  • #6

    TF (Thursday, 15 January 2015 11:02)

    Yes, I did copy that .dll over to \Python27. The version I have is ffmpeg2410 however. Still getting the error about ZeroDivisionError: float division by zero. Even when I change the video filename to a nonexistant video, same error. The mp4 files are labeled to only open with VLC media player. I won't give up on this, will be so awesome to get it working!

  • #7

    theeminentcodfish (Thursday, 15 January 2015 11:40)

    Out of curiosity are you running a 32 or 64-bit version of python? Windows or Mac?

    I am sorry for all the frustration. It definitely sounds like a codec issue. I vaguely remember having this issue when I started with OpenCV and GoPro but that was years ago. At this point we just need to get the video to load. I have attached another script below the comments section which is just a simple playback script, but it will tell you when the video fails to load.

    I think it is a matter of getting the correct ffmpeg driver into the correct Python folder. In the OpenCV folder go to: opencv\sources\3rdparty\ffmpeg. Copy the ffmpeg.dll file into the Python27 folder, you shouldn't need the opencv_ffmpeg_64.dll unless you are running a 64-bit version of python. Rename it as listed above but only use three digits (i.e. ffmpeg241.dll). Hopefully this works!

  • #8

    TF (Tuesday, 20 January 2015 12:12)

    SUCCESS!!! I needed to change the opencv version # to 2410, apparently needed the ending 0. So renaming the opencv_ffmpeg_64.dll to opencv_ffmpeg2410_64.dll and moving it to the Python27 folder was the trick.

    Thanks for the support, codfish!

    Now my next question: How can I change the color of the timestamp text? It's common to have very dark margins in the underwater video and the black text may not show clearly at times.

  • #9

    TF (Tuesday, 20 January 2015 17:12)

    I figured out how to change the text color, very easy.

    This color slider is helpful:

  • #10

    theeminentcodfish (Wednesday, 21 January 2015 08:38)

    I am happy that you go everything working. Within that same line of code you can also change the position, size, style and thickness of the font. You can see the variables at:

  • #11

    TF (Friday, 30 January 2015 13:28)

    Hi again.

    Regarding external data overlay, can you show me how to add a fourth column of data (ie. Lat [3] & Long [4] coordinates) ? Your example overlays depth but not the pressure data column.

  • #12

    theeminentcodfish (Friday, 30 January 2015 14:13)

    First you have to parse the data and put it in an appropriate format. For this script I used a python dictionary. I set the dictionary up so that each entry consisted of the time as the dictionary key and the depth measurement as the corresponding value. See the code below:

    #Importing and parsing of the external data file
    import_file = open(data_name, 'r')
    time_rec = []
    pressure = []
    depth = []
    time_depth = {}

    for lines in
    if lines != '':
    data = lines.split()
    time_rec.append(dt.datetime.strptime((data[0] + ' ' + data[1] + '000'), "%d-%b-%Y %H:%M:%S.%f"))

    dt_dic = dict(zip(time_rec, depth))

    This allowed me to looked up the depth value at the relevant time during the main logic loop of the program. Once you have the additional data into a dictionary it is simply a matter of looking up the data value at each time step. See below:

    timestamp = initial + dt.timedelta(microseconds = elapsed_time*1000)
    t = timestamp + dt.timedelta(microseconds = -timestamp.microsecond)
    depth_value = dt_dic[t]

    The second line is used to strip out the microseconds value in the timestamp so that it matches identically to the time value in the data file. The third line searches the dictionary for the depth value from the time entry. Then you simply add it to the screen.

    cv2.putText(image, 'Depth: '+ str(depth_value)[0:-3], (50,int(height-50)),cv2.FONT_HERSHEY_COMPLEX_SMALL, 2, (255, 255, 255), 3)

    If you want to add a forth line, then just add another one of these lines. Change the second parameter to reference the data you want overlaid (i.e. lat/long). Then change the third parameter to place the text in an appropriate place.

  • #13

    Paralegal Josh (Saturday, 04 April 2015 11:49)


    I may be closer to accomplishing this, but am still not there (shucks).

    When I download the FFprobe, it comes as a .tar.gz file (WinRAR). I extract to my desktop into a folder (ffprobe 53). I have placed that folder into the folder contained on an sdcard which has the gopro mp4 video on which I hope to implement the timestamp.

    I have removed the .txt extension as instructed; and I have opened it in IDLE and edited it. But, when I attempt to run via run>run module (or by pressing F5), I am receiving a "Subprocess Startup Error," which says, "IDLE's subprocess didn't make a connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection. When I double-click, I see the command module open up briefly, but still no timestamp when I watch the video.

    I am assuming that I ought to extract the FFprobe (WinRAR) download, else it would not be usable. Is that correct?

  • #14

    theeminentcodfish (Monday, 06 April 2015 12:50)

    Hey Josh. The problem that you are having is that python is not recognizing the openCV package that you have on your computer. To make python aware of it's exisitence then you need to go into the following OpenCV folder, \opencv\build\python\2.7\. Then you will find two folders (x64 and x86). If you are running a 32-bit version of python (it will tell you this when you start IDLE) then copy the cv2.pyd file from the x86 folder, if you are running a 64 bit version then copy the same file from the x64 folder. Copy that file into your python folder \Python2.7\Lib\. That should get it to work. I hope you are running a 32-bit version because you may have issues with another package called Numpy which OpenCV relies on and is typically not installed as a 64-bit version. If you have that problem then I can walk you through that.

  • #15

    Paralegal Josh (Monday, 13 April 2015 06:34)


    So, I have followed your previous instructions ("\opencv\build\python\2.7\...find two folders (x64 and x86)...then copy the cv2.pyd file from the x86 folder). Now as I run>run module in IDLE, I get this--"ImportError: numpy.core.multiarray failed to import"

    However, I am running a 32 bit version of windows (windows xp pro service pack 3). Maybe I accidentally installed an incorrect version of python or open cv?

    It seems like the numpy package issue you foresaw. But what confuses me is that I am indeed running a 32bit version of windows.

  • #16

    theeminentcodfish (Monday, 13 April 2015 10:24)

    Josh, Sorry for all the hassle. It makes me think that there should be a better way. I'll work on it, but until then it looks like a numpy issue. If you are running a 32-bit version then you may not have numpy (depending on what python package you downloaded) or have an older version. You can try downloading the most current version at this website:
    Hopefully this will work.


  • #17

    Paralegal Josh (Sunday, 19 April 2015 19:52)

    Hey Chris,

    So I have uninstalled the previous version of Python (2.7.2). And I installed the NumPy version-1.9.2 from the website you gave me. However, I am not able to locate IDLE within this version of Python for the purpose of running the script. So, I downloaded Anaconda; and I am not sure how to initiate it (Anaconda) in order to run the (gopro timestamp) script. I have the (gopro timestamp) script saved in the folder (as .py) with the .mp4 file that I desire to implement a timestamp upon. Can I run this script using anaconda? What do you think?

    By the way, don't worry about the hassle here, I am just hoping I can get this done. I am looking forward to accomplishing this, and hoping that I will be able to implement the filewalker and process multiple batches of files, which I am thinking will really help me with a project I am working on.


  • #18

    Andrew (Thursday, 14 May 2015 11:39)

    This site has been a great help!

    I have modified your data overlay script to display 5 different parameters and it works great. I'm showing date, time, altitude, latitude and longitude.

    However, Is there are quick and dirty way to pump in a image as well? To watermark the video in a different corner?

  • #19

    theeminentcodfish (Friday, 15 May 2015 11:07)

    Hello Andrew.

    An image overlay is relatively simple. I added another file above the comments section which will work. You can adopt the code into your version. Just make sure that the watermark doesn't go outside the bounds of the video frame or it will throw an error message.

  • #20

    kfinchie (Wednesday, 17 June 2015 14:12)

    Great tutorial! I am having an issue, when I run the script I am getting an error: Error: Could not load video. I have the script in my video folder, any idea on how to fix?

  • #21

    nick (Friday, 19 June 2015 12:53)

    Hey Chris,

    I've been trying to get this code to work and I've been running into some issues. When I run the file I get Error: Could not load video. When I run the file I get the following statement.

    File ".\", line 5, in <module>
    total_frames = video.get(
    AttributeError: 'module' object has no atribute 'cv'

    Do you have any idea of what the problem is, or how to fix it? Thank you for this site, and your help.

    ~ Nick

  • #22

    theeminentcodfish (Friday, 19 June 2015 14:40)


    This sounds like it could be a codec issue. OpenCV is not great at this.

    I think it is a matter of getting the correct ffmpeg driver into the correct Python folder. First, check which version of OpenCV you are using by typing the following into your python prompt.

    >>> from cv2 import __version__
    >>> __version__

    In the OpenCV folder go to: opencv\sources\3rdparty\ffmpeg. Copy the ffmpeg.dll file into the Python27 folder, you shouldn't need the opencv_ffmpeg_64.dll unless you are running a 64-bit version of python. Rename based on the version number above. One my system I only used three digits (i.e. opencv_ffmpeg240.dll) but another user need four digits. Hopefully this works!

  • #23

    theeminentcodfish (Friday, 19 June 2015 14:43)

    Hey Nick,

    What version of OpenCV are you using? To check you can type the following into the python prompt.

    >>> from cv2 import __version__
    >>> __version__


  • #24

    Cinthia (Monday, 22 June 2015 11:00)

    Hi Chris,

    In having trouble with your first timestamp code. I'm getting a syntax error that says " 'break' outside loop".(I'm very new to programing and python.)

    Any advice on this? It would be greatly appreciated!

  • #25

    theeminentcodfish (Monday, 22 June 2015 11:43)


    It looks like the python compiler that you are using is interpreting the program slightly differently then mine. Either way, it looks like it doesn't like the 'break' statement in line 85. I updated the code on the website. I think it should work now. If you are using any of the other scripts, you can simply comment out the break statement by placing a # in front of it. Python will ignore that line (which isn't essential) and you shouldn't get an error.

  • #26

    Cinthia (Monday, 22 June 2015 11:52)

    Thanks Chris, I'll have to wait to try the updated code. My company doesn't download it here. I'll update you tomorrow. Thank you for the very quick response!

  • #27

    theeminentcodfish (Monday, 22 June 2015 11:59)


    If you already have the old code you can simply put a # in front of the break statement in line 85. That should solve the problem.

  • #28

    Cinthia (Monday, 22 June 2015 12:31)

    Any tips?
    Traceback (most recent call last):
      File "C:\Users\J36836\Desktop\3Video\", line 59, in <module>
        t = creation_time(filename)
      File "C:\Users\J36836\Desktop\3Video\", line 28, in creation_time
        p = subprocess.Popen(cmnd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      File "C:\Python27\lib\", line 679, in __init__
        errread, errwrite)
      File "C:\Python27\lib\", line 893, in _execute_child
    WindowsError: [Error 2] The system cannot find the file specified

  • #29

    theeminentcodfish (Monday, 22 June 2015 12:35)

    It looks like it cannot find the ffprobe file. Did you download, unzip and place the ffprobe software in the file containing the GoPro video and this script? The link to the software is listed above.

  • #30

    Cinthia (Monday, 22 June 2015 12:52)

    In the folder, I have the unzipped (ffprobe-53) folder, (opencv) folder, the file with the script, the video file in mp4 format and opencv-3.0.0.exe

  • #31

    theeminentcodfish (Monday, 22 June 2015 13:00)

    Make sure the ffprobe.exe file is located in the same folder as the script. Did you install opencv on your system or just place the file in the folder. Make sure that it is installed. Additionally, I have only tested this program with OpenCV 2.4.8. OpenCV 3 is new and I haven't tested it yet. I can't say for sure whether it will work. You can try and find out.

  • #32

    kfinchie (Monday, 22 June 2015 16:25)

    Thank you for your help! I have done the steps you provided but now I am getting the same error as Cinthia:
    Traceback (most recent call last):
    File "C:\Video\", line 59, in <module>
    t = creation_time(filename)
    File "C:\Video\", line 28, in creation_time
    p = subprocess.Popen(cmnd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    File "C:\Python27\lib\", line 710, in __init__
    errread, errwrite)
    File "C:\Python27\lib\", line 958, in _execute_child
    WindowsError: [Error 2] The system cannot find the file specified

    Also a new file is being created in GoPro video directory with the same name as the file changed to .avi that I am trying to timestamp, I feel like i'm close, any suggestions? I have the ffprobe folder that I downloaded from the link provided. I have also tired to rename the folder ffprobe and ffprobe-53, neither of those got me going.

  • #33

    kfinchie (Monday, 22 June 2015 17:05)

    I was able to get past this by downloading FFmpeg and got the ffprobe from that, now I am running into this issue:


    Traceback (most recent call last):
    File "C:\Video\", line 59, in <module>
    t = creation_time(filename)
    File "C:\Video\", line 37, in creation_time
    time = str(t[14][18:37])
    IndexError: list index out of range

    Again thanks for this article!

  • #34

    nick (Tuesday, 23 June 2015 13:52)


    Sorry it took me a while to respond.
    I typed in these lines because the line: from cv2 import__version__ wasn't working for me so I did it this way.

    >>> import cv2
    >>> print cv2.__version__

  • #35

    Cinthia (Tuesday, 23 June 2015 14:31)

    Hey Chris! So I downloaded an older version, and it AAALMOST works. It uploads the video, and processes it. (I know because I ask it to spit it out) and the time stamp is on there! Wooo! Unfortunately, it's not saving properly.

    This is the error I get:OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in unknown function, file ..\..\..\OpenCV-2.3.1\modules\core\src\array.cpp, line 2482
    Traceback (most recent call last):
      File "C:\Users\J36836\Desktop\3Video\", line 83, in <module>
        cv2.imshow('Video', image)
    cv2.error: ..\..\..\OpenCV-2.3.1\modules\core\src\array.cpp:2482: error: (-206) Unrecognized or unsupported array type

    Thanks in advance!

  • #36

    theeminentcodfish (Tuesday, 23 June 2015 20:53)


    It looks like you are using the OpenCV 3. This is a new version which I have not tested yet. This may be the issue. I have only tested this program on OpenCV 2.4.8.


  • #37

    Cinthia (Thursday, 25 June 2015 09:11)

    Hey Chris, I was able to get the code to work!

    Thanks for the help.

    Any chance you can update the filewalker code?

    P.S. if you're ever in SoCal,drinks are on me!

  • #38

    theeminentcodfish (Thursday, 25 June 2015 20:18)

    Hey Cinthia,

    I am glad that it finally worked. I apologize that the software is a bit buggy. It is something I definitely need to work on. It's part of my learning curve.

    I updated the filewalker script, so it should work.

    How did you end of fixing the last issue that you had? Out of curiosity.


  • #39

    theeminentcodfish (Thursday, 25 June 2015 20:21)


    It looks like the program is not talking to ffprobe and getting the correct information back. Can you check that the ffprobe.exe file is in the same file with the script?

  • #40

    Cinthia (Friday, 26 June 2015 08:36)

    Hey Chris,

    I re-ran OpenCV and then copied and pasted your code again and voila!

    Also, for your filewalker code, I keep getting 'import sitecustomize' failed. Any ideas?

  • #41

    theeminentcodfish (Friday, 26 June 2015 09:24)


    What software are you using to run python? A quick google search showed that this happens with Spyder. Are you using this python interpreter?


  • #42

    Cinthia (Friday, 26 June 2015 09:50)

    Yes, I am. That might be the problem. Which one are you using?

    (Sorry, I'm a Matlab person)

  • #43

    Zimmer (Wednesday, 08 July 2015 21:13)

    So, I have followed your previous instructions ("\opencv\build\python\2.7\...find two folders (x64 and x86)...then copy the cv2.pyd file from the x86 folder). Now as I run>run module in IDLE, I get this--"ImportError: numpy.core.multiarray failed to import"

    I have downloaded the most current version at this website:
    (Version 1.9.2)

    Can you please walk me through the next steps.

  • #44

    Srini (Monday, 20 July 2015 17:57)

    Is there a ffprobe for Ubuntu? I don't work in Windows, I work in Ubuntu 14.04.

  • #45

    Anthony (Wednesday, 19 August 2015 12:35)

    Hello Chris, thanks for such a great post. I am unable to get this working and was hoping you could help. I am getting the "Could not load video" error.

    I am on Windows 7 64bit, running Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32, OpenCV version 2.4.9 (64bit). I saw that someone ran a "" file to help troubleshoot, but I am not familiar with Python or where to find that file (My Google-Fu is not strong today).

    What other information do you need in order to assist me?

  • #46

    Anthony (Wednesday, 19 August 2015 12:48)

    Please disregard my last post. I was able to fix my issue: "On my system I only used three digits (i.e. opencv_ffmpeg240.dll) but another user need four digits."

    I also had to use three digits.

    Now I am getting a different error:





    format_long_name=QuickTime / MOV



    size=118.055408 Mibyte

    bit_rate=9.070198 Mbit/s







    Traceback (most recent call last):
    File "C:\Users\ajm\Desktop\Python\", line 60, in <module>
    initial = dt.datetime.strptime(t, "%Y-%m-%d %H:%M:%S")
    File "C:\Python27\lib\", line 325, in _strptime
    (data_string, format))
    ValueError: time data '.33.100' does not match format '%Y-%m-%d %H:%M:%S'

  • #47

    Anthony (Wednesday, 19 August 2015 13:38)

    It seems as though this is not going to work with my videos. I use the TimeLapse feature and take one picture every 60 seconds; then I compile those pictures into a video using the GoPro Studio. The final file type is .MP4, but this script doesn't like the time stamp structure and I'm not sure what I can do about it...
    Traceback (most recent call last):
    File "C:\Users\ajm\Desktop\Python\", line 60, in <module>
    initial = dt.datetime.strptime(t, "%Y-%m-%d %H:%M:%S")
    File "C:\Python27\lib\", line 325, in _strptime
    (data_string, format))
    ValueError: time data '.33.100' does not match format '%Y-%m-%d %H:%M:%S'

  • #48

    Veronica (Sunday, 20 December 2015 22:19)

    I understand that this script simply produces a timestamp based on the initial time stored in the video meta-data and an assumption on a fixed frame rate. But how do you know if this assumption hold? That is, there could be fluctuations in the frame rate (25fps, 24.9fps, etc...) which could result in a drift overtime. Did you test this by any chance?


  • #49

    Kyle (Wednesday, 06 January 2016 12:23)

    Very helpful, thanks. One common use for GoPros where timestamp overlay is helpful is for timelapse videos. In this case the video time elapsed does not equate to the time of day, so the "elapsed_time = video.get(" line needs to be modified to adjust for the timelapse factor. Presumably anyone technical enough to use this script can figure it out for themselves and adjust this line manually, but just thought I'd point it out if you are continuing to update and improve this helpful script.

  • #50

    Nate (Tuesday, 19 January 2016 17:16)

    Tried running everything but get the following error:

    " SyntaxError: Missing parentheses in call to 'print' "

    Can you let me know any additional advice?


  • #51

    Chris (Wednesday, 20 January 2016 13:38)


    You make a good point. If you were using this for timelapse, and you know the time between frames then you could simply alter the script. I can think of two ways to do this. First you could just increment the timestamp variable every frame. Here is an example for a frame rate of 1/5 sec.

    #line 76 in the main script
    timestamp = timestamp + dt.timedelta(seconds = 5)

    Or you could look at the number of elapsed frames (obtained in line 75) and extrapolate. Like so:

    timestamp = current_frame + dt.timedelta(seconds = 5)

    Both should work. I'm not sure if one method is better then the other.

  • #52

    Chris (Wednesday, 20 January 2016 13:45)

    Hey Nate,

    Can you give me a little more information? Which script are you using? Does is give any more info in the error message? I'd be looking for a line number where it through the error.

    The error message is saying that there was an error in a print statement. Typically when you tell python to print something you usually need to put it in quotes, this tells python that it is a text string. I don't see anything that has an open quote but not a closing quote. Double check you filename statement.

    filename = 'Your_GoPro_Video_Here.MP4'


  • #53

    Chris (Wednesday, 20 January 2016 13:56)

    Hello Veronica,

    Sorry for the delay in my feedback. To the best of my knowledge OpenCV is taking the frame rate into consideration when calculating the elapsed time. For instance, you can investigate the frame rate with the following line:

    FPS = video.get(

    So varying frame rates shouldn't affect it, assuming that OpenCV can derive the correct frame rate. I haven't tried different frame rates. I have looked into the issue of drift. Based on some very basic analysis it doesn't look like there is that much drift (i.e. error) in the timestamp within a video file (less then 1 second, which was good enough for what I needed). I did notice that there was some drift when doing sequential videos (i.e. the gopro saved a long video every ~30 minutes). It looks like there is some error imparted when jumping from one video to another (~a couple seconds). If you have a long string of videos this could add up.


  • #54

    Nate (Thursday, 11 February 2016 16:44)


    File "c: \ temp\" , line 29
    print filename
    SyntaxError: Missing parentheses in call to 'print'

    Any help would be appreciated.


  • #55

    Chris (Friday, 19 February 2016 07:59)

    Hey Nate,

    What version of python are you using? My guess is that you are using python 3.0. This script was written in 2.7.

  • #56

    Davis (Wednesday, 24 February 2016 15:12)

    Would this also work for timelapse?

  • #57

    Francisco (Tuesday, 22 March 2016 04:01)

    Thanks a lot for the programs !!!

    I had the error: "Cannot open video" but finally was able to use it following :

  • #58

    Blair (Tuesday, 17 May 2016 22:12)

    This may be a big ask, but I am really not a programmer, is there any chance of very step by step guide e.g. including how to open the files in python etc?


  • #59

    Blair (Tuesday, 17 May 2016 23:07)

    Cancel above entry (I think). I am getting an erroer "Could not load video", and while I tried to follow another solution you have posted, the file in my ffmpeg folder is ffmpeg.cmake not ffmpeg.dll


  • #60

    Ritchi (Friday, 20 May 2016 02:40)

    I would like to know if your script works on Mac OS X ?

  • #61

    MG (Tuesday, 09 August 2016 07:49)

    Hi there,
    I notice you mention this is tested on GoPro 2/3/3+; has it been modified to work on GoPro 4?

  • #62

    CharlesM (Wednesday, 23 November 2016 18:27)

    I have spent hours getting Python and Numpy and opencv to finally allow execution of the GoPro timestamp script. I have an error in the formatting of either the information provided in the metadata of the mp4, the formatting of the script line 60 dt.datetime.strptime or the formatting of the python library module, line 332. The actual error follows:

    format_long_name=QuickTime / MOV
    size=89.961450 Mibyte
    bit_rate=22.632297 Mbit/s

    Traceback (most recent call last):
    File "C:\GoPro_TS\", line 60, in <module>
    initial = dt.datetime.strptime(t, "%Y-%m-%d %H:%M:%S")
    File "C:\Python27\lib\", line 332, in _strptime
    (data_string, format))
    ValueError: time data '' does not match format '%Y-%m-%d %H:%M:%S'

    Any idea on what I should do to fix this. I am so close and excited to get this to work. Thanks in advance for any help.

  • #63

    Bill (Monday, 20 March 2017 17:42)

    Is anyone still actively working on this script project? I'm working with the timestamp script, and it's producing an AVI file bit it is only 116 bytes compared to the original 1.3GB GoPro video, and the AVI file will not open. There are a number of specific errors in the execution related to ParseTrackAtom & FigAssetWriterCreateWithURL. So far unable to find much helpful information. As much time as it may take to get this worked out, it may be easier to buy a device that has a time stamp function built into it. Still going to give it some effort though.

  • #64

    Bill (Tuesday, 21 March 2017 09:29)

    UPDATE: For anyone who may be looking into this, I successfully used this process to extract timestamp data from an MP4 file created on a GoPro Hero5 Session, and burn it onto the generated AVI file. I used a Windows 7 Pro 64 bit system running Python 2.7, OpenCV 2.4.11 & Numpy 1.7.1.

    The generated AVI file, without audio, was 75% larger in size than the original MP4 file with audio (1.75GB vs 1GB).

    Not a very practical process, however I'm $400 into the GoPro ( incl. $100 128GB SD Card) and have video made with it for which I need the time stamp. I was unaware when I bought it that GoPro products do not possess this basic feature. I will be migrating to another manufacturer asap.

  • #65

    Conor (Wednesday, 22 March 2017 10:08)

    Hi Bill,

    I am trying to get the original code to work for the GoPro Hero 5 Session as well, but am running into errors. Did you modify the code at all to fit the GoPro 5?



  • #66

    Chris (Monday, 27 March 2017 13:54)


    Thank you for the post. I agree that it is not a great process. I assumed that the GoPro's would have this functionality. I had to create this work around as a post-hoc method for timestamping using the equipment that I had. I have recently uploaded a newer script which will reduce the file size and maintain the MP4 codec.


  • #67

    Chris (Monday, 27 March 2017 13:54)


    Can you be more specific as to the errors that you are getting?


  • #68

    Conor (Thursday, 06 April 2017 15:33)

    Hi Chris,

    Thank you for putting this code together. Unfortunately, I'm a newcomer to programming in python, so i'm already at a disadvantage with trying to get the code to work for a GoPro 5 I have.

    After fixing a series of syntax errors python called, I run into the error
    "No module named cv2"

    Any help would be greatly appreciated! Thanks! Conor

  • #69

    Chris (Monday, 10 April 2017 11:57)

    Hey Conor,

    The error message that you are getting indicates that python is now recognizing the opencv module. If you downloaded opencv and have it on your computer then you need to copy the cv2.pyd file, usually found in the following directory C:\OpenCV_3.0.0\opencv\build\python\2.7\x64\ to your python Lib folder, found at C:\Python_2.7\Lib. The exact location may be slightly different depending on your system. Additionally, make sure you take the appropriate pyd file (either x86 or x64) depending on your system (32 vs 64-bit). Hopefully this helps.


  • #70

    Conor (Monday, 22 May 2017 10:58)

    Thanks Chris,

    I'm using Python 2.7, Open CV 3.0, and Numpy 1.8. I have a 64 bit system and grabbed the corresponding CV file and placed in in the Lib folder.

    Using your updated Script, I am now running into the error of:
    Traceback (most recent call last):
    File "C:\Users\conor.egan\AppData\Local\Temp\Temp1_GoPro_timestamp_FFMPEG_3.0 (2).zip\", line 12, in <module>
    import cv2, sys, time
    ImportError: numpy.core.multiarray failed to import

    Going to play around a bit with different versions of Open CV and Numpy.

  • #71

    Conor (Monday, 22 May 2017 11:30)

    added import numpy.core.multiarray before import cv2 and ran into
    AttributeError: 'module' object has no attribute 'may_share_memory'

  • #72

    Antoine (Thursday, 01 June 2017 14:32)

    Regarding external data overlay, I have data sampled at a rate of 20 kHz that I'd like to overlay and if I strip the decimals (5 decimals) off the seconds I end up with an awful lot of measurements taken at the same time. What should I change in the code to make it work (without losing data)?

  • #73

    Antoine (Friday, 09 June 2017 14:08)

    I'm getting this error:

    Traceback (most recent call last):
    File "U:\GoPro Timestamp\Python\", line 92, in <module>
    AttributeError: 'NoneType' object has no attribute 'tostring'

  • #74

    Jess (Tuesday, 28 November 2017 23:27)

    Hi Chris,

    Nice bit of code! I'm getting the same error as Cynthia:
    Traceback (most recent call last):
    File "/Users/jessflicker/Documents/GoPro Timestamp/", line 65, in <module>
    t = creation_time(filename)
    File "/Users/jessflicker/Documents/GoPro Timestamp/", line 34, in creation_time
    p = subprocess.Popen(cmnd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/", line 707, in __init__
    restore_signals, start_new_session)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/", line 1333, in _execute_child
    raise child_exception_type(errno_num, err_msg)
    FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe'

    What are the steps to remediate this?

  • #75

    Jess (Tuesday, 28 November 2017 23:29)

    *Cinthia, sorry. I should mention that I'm using MAC OS X

  • #76

    Chris (Wednesday, 29 November 2017 09:24)

    Hello Jess,

    Based on the error code, it looks as if the script cannot find ffprobe. Ensure that you have downloaded ffprobe file, either from the link above or from the ffmpeg website. If you download it above, unzip the file. It should be an executable (*.exe). Then put that file in the same folder as the script.

    Hopefully that works.

  • #77

    Jess (Thursday, 30 November 2017 00:07)

    Thanks for your quick reply, Chris. I'm fairly new to programming. I have the ffprobe file in there with the script and the .mp4 video file. While the ffprobe doesn't have a .exe extension, it does have a black icon with green 'exec' and opens in Terminal so I think it is the right file. When I run the script I get a zero byte copy of the video file with a .avi extension. Has anybody else had a similar experience on Mac?

  • #78

    Jess (Thursday, 30 November 2017 00:48)

    So I tried something else and now I'm getting this error code:

    Traceback (most recent call last):
    File "/Users/****/Documents/GoProTimestamp/", line 82, in <module>
    t = creation_time(video_filename)
    File "/Users/****/Documents/GoProTimestamp/", line 22, in creation_time
    p = subprocess.Popen(cmnd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/", line 707, in __init__
    restore_signals, start_new_session)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/", line 1333, in _execute_child
    raise child_exception_type(errno_num, err_msg)
    PermissionError: [Errno 13] Permission denied

    I don't really understand what's going on here. What do I need to give permission to and how can I do it on a Mac?

  • #79

    Chris (Friday, 01 December 2017 13:47)

    Hey Jess,
    Try the solution on this website.

    I hope this works.

  • #80

    Jess (Sunday, 03 December 2017 00:38)

    Brilliant, Chris.
    Another step closer! However, now I'm getting the same error as kfinchie.
    Traceback (most recent call last):
    File "/Users/****/", line 65, in <module>
    t = creation_time(filename)
    File "/Users/****/", line 43, in creation_time
    time = str(t[14][18:37])
    IndexError: list index out of range
    You said this might be because there's something wrong with the communication with ffprobe. Any ideas on how to fix this?

  • #81

    Chris (Monday, 04 December 2017 10:07)

    Hey Jess,

    What version of python are you using? Which GoPro camera are you using? It looks as if there is an problem with FFprobe reading the video meta-data. Let's see what FFprobe is spitting out. Within the script, place the following lines of code in the creation_time function just after t = out.splitlines():


    This will show us the raw FFprobe metadata. Your error is python having problems parsing information which is either not there or not in the format which it expects. Try this and see what it says.


  • #82

    Jess (Friday, 22 December 2017 19:18)

    Hey Chris,
    I'm using a Hero 4 Silver and python 2.7 I believe. This is what is being printed to the console:
    ========= error ========
    b"/****/ line 5: \r: command not found\n/****/ line 11: \r: command not found\n/****/ line 12: import: command not found\n/****/ line 13: import: command not found\nfrom: can't read /var/mail/subprocess\n/****/ line 15: \r: command not found\n/****/ line 17: filename: command not found\n/****/ line 18: \r: command not found\n/****p/ line 20: syntax error near unexpected token `('\n/****/ line 20: `watermark = cv2.imread('watermark.jpg')\r'\n"

    Cheers, Jess

  • #83

    Raghavendra (Tuesday, 01 May 2018 15:36)

    Any idea why I am getting FPS: 90000

  • #84

    Masroor (Monday, 10 September 2018 12:16)

    I get the following error:

    b'[FORMAT]\r\nfilename=101.mp4\r\nnb_streams=2\r\nnb_programs=0\r\nformat_name=mov,mp4,m4a,3gp,3g2,mj2\r\nformat_long_name=QuickTime / MOV\r\nstart_time=0:00:00.000000\r\nduration=0:02:40.237000\r\nsize=17.237003 Mibyte\r\nbit_rate=902.378000 Kbit/s\r\nprobe_score=100\r\nTAG:major_brand=isom\r\nTAG:minor_version=512\r\nTAG:compatible_brands=isomiso2avc1mp41\r\nTAG:track=0\r\nTAG:artist=\r\nTAG:album=\r\nTAG:date=0\r\nTAG:genre=\r\nTAG:lyrics=\r\nTAG:title=\r\nTAG:encoder=Lavf56.36.100\r\n[/FORMAT]\r\n'

    time data "b''" does not match format '%Y-%m-%d %H:%M:%S'

    why is the creation_time() function returning an empty value? What is the solution?

  • #85

    Brianna (Tuesday, 09 October 2018 16:51)

    Hi Chris -

    I am a graduate student in fisheries science in Alaska , and I also used Gopros attached to trawl nets for my thesis work!

    A timestamp on my data would be AMAZING.

    I am getting the following error:

    Error: Could not load video

    I copied the ffmpeg.dll file in to the Python folder (and tried subdirectories too) and it doesn't seem to work.

    I am using python 2.7.14, and opencv-2.4.13. I have the python script, the ffprobe file, and the Gopro file in the same folder.

    Any ideas? Would love any help you could provide.

  • #86

    Brianna King (Wednesday, 10 October 2018 13:09)

    Nevermind! I just got it to work. Sometimes stepping away from the computer for a day and coming back to it is the best solution.

    Thanks for providing this code! It'll make my data analysis SO much easier. Dr. Brad Harris (my adviser) says hello, by the way!

  • #87

    Vandana (Monday, 09 March 2020 12:45)

    Hi Chris,

    First of all, thanks for the code.

    I have some long videos (each approx 8 min long with 60 fps). The problem is that after reading around 18k frames, Python gets stuck at 'pipe.stdin.write(image.tostring())'. Any idea on how to solve this issue?


  • #88

    Jody P (Friday, 16 October 2020 19:29)

    Thank you so much for the code!! With some tweaks to the "GoPro Timestamp with filewalker" code I am able to use this code for videos from my Hero 4 silver with Python 3.8, OpenCV 4.4.0 and a current version (N-99519) of ffprobe (from I also made mine output to M4V which is just an extension rename back to MP4 (I could have just made a file name change to keep it mp4 but went this route). I also rearrange the date format and added a 12 hour clock instead of the 24 hour. I hit a few bumps along the way but your code got me a good 98% or more to my end goal and I truly appreciate you for it!!!

  • #89

    Jody P (Tuesday, 20 October 2020 23:24)

    I tweaked on your code some more and managed to adapter it to work with my sister’s Sony camcorder as well! I made a short YouTube video explaining how to set up everything, some of the changes I made and how to run everything so that maybe it can help someone else out in the future. Thanks again for sharing!

Compressed Archive in ZIP Format 486 Bytes