Encoding of VCO export files

A number of ways you can support LapTimer development
dbbarron
20 or more Posts ★★★
20 or more Posts ★★★
Posts: 29
Joined: Fri Aug 26, 2016 1:44 pm

Encoding of VCO export files

Postby dbbarron » Fri Sep 16, 2016 3:28 pm

I am writing a python script (v.3) to read in a VBO export and add in the AVI information to support video.
It works great on a PC, but the identical script on a Mac produces unicode errors in reading the VBO file.
Does anyone know the encoding of the .vbo export or otherwise is aware of potential issues in reading this file.
The trouble character appears to be 0xac. I have tried ASCII, UTF-8 encoding to no avail.

db


User avatar
Harry
Site Admin
Site Admin
Posts: 8370
Joined: Sun Sep 12, 2010 10:32 am
Location: Cologne, Germany
Has thanked: 97 times
Been thanked: 349 times
Contact:

Re: Encoding of VCO export files

Postby Harry » Sun Sep 18, 2016 8:53 am

It is a Windows format, so most probably Windows-1252. I haven't checked it in the code but it is worth a try.

- Harry


Image Image Image Image
dbbarron
20 or more Posts ★★★
20 or more Posts ★★★
Posts: 29
Joined: Fri Aug 26, 2016 1:44 pm

Re: Encoding of VCO export files

Postby dbbarron » Mon Sep 26, 2016 6:52 pm

Harry wrote:It is a Windows format, so most probably Windows-1252. I haven't checked it in the code but it is worth a try.

- Harry

That worked! Thanks, I now have a working script I can use to quickly add in the needful information to link a video to Circuit Tools using VBO data exported from HLT.

1)Enter pits, email or dropbox VBO file from session out of HLT - download onto laptop from email or dbox.
2)download video from GoPro onto laptop, rename to 8 char compatible with Circuit Tools. Concatenate GoPro chapters if needed. Trim a bit if needed.
3)Run python script against VBO file to add in video information;
4)Start up circuit tools and analyze data

I'm sure it won't be as easy in the field!

db


User avatar
Harry
Site Admin
Site Admin
Posts: 8370
Joined: Sun Sep 12, 2010 10:32 am
Location: Cologne, Germany
Has thanked: 97 times
Been thanked: 349 times
Contact:

Re: Encoding of VCO export files

Postby Harry » Mon Sep 26, 2016 6:54 pm

Please share your code here!

- Harry


Image Image Image Image
dbbarron
20 or more Posts ★★★
20 or more Posts ★★★
Posts: 29
Joined: Fri Aug 26, 2016 1:44 pm

Re: Encoding of VCO export files

Postby dbbarron » Mon Sep 26, 2016 7:02 pm

Code: Select all

# This program will read a VBOX formatted file (.vbo)
# exported from Harry's Lap Timer (HLT) and will amend the
# file to include all that is necessary to link a video to it.
#
#

# Get the tkinter library functions
from tkinter import *
root=Tk()


# 4 character video file extension for linked video - e.g., vid_0001.mp4

# video file characteristic
video_file_format = "MP4"

#Use Tkinter to get video_filename
root.filename = filedialog.askopenfilename(title="Input MP4 Video File", filetypes=(("MP4 files","*.mp4"),("all files","*.*")))
video_filename=root.filename

video_file_prefix=video_filename[-12:-8]
video_file_suffix=video_filename[-8:-4]

print("Video filename is:" + video_filename)
print("Video Prefix is:" + video_file_prefix)
print("Video Suffix is:" + video_file_suffix)


# Get input filename using a tkinter GUI
root.filename = filedialog.askopenfilename(title="Input VBO Data File", filetypes=(("VBO files","*.vbo"),("all files","*.*")))
input_filename=root.filename
print("input filename is:" + input_filename)

# Create output filename from input filename with _VID added
output_filename = (input_filename.rstrip(".vbo")+"_VID.vbo")
print("output_filename is:" + output_filename)


# Open the input and output files
input_file = open(input_filename, 'r', encoding='cp1252')
output_file= open(output_filename, 'w', encoding='cp1252', newline='\r\n')

# Parse to '[data]' field  - parse the file reading each line and sending it unchanged
# to the output file.

#data_flag is a flag variable to indicate that the [data] header has been passed
# and we should start outputting time synch data

data_flag=0

millisecond_counter=int(input("Enter video offset in milliseconds: "))

for line in input_file:
        if data_flag==0:                # if not in data output line as read
                print (line);
                output_file.write(line)
        if data_flag==1 and line != "\n":  # once in data output ms and file
 #               print (line + video_file_extension + str(millisecond_counter));
                millisecond_counter += 100
                millisecond_string=str('{:09}'.format(millisecond_counter))
                if millisecond_counter < 0:
                        millisecond_string='000000000'
                output_file.write(line.rstrip() + " " + video_file_suffix + " " + millisecond_string +"\n")
        if line == "[data]\n":           #if [data] found set data flag
                data_flag=1
                print("Data flag set to 1")
        if line == "EngineSpeed\n":   # add avi fields to header
                output_file.write("avifileindex\n")
                output_file.write("avisynctime\n")
                # then add AVI block to file after header block
                output_file.write("\n")
                output_file.write("[avi]\n")
                output_file.write(video_file_prefix + "\n")
                output_file.write(video_file_format + "\n")
        if line == "[column names]\n":   # add avi fields at end of column names   
                line = input_file.readline()  # read the next line of column names
                output_file.write(line.rstrip() + " avifileindex avisynctime\n") # output column names with AVI columns

# Close the files
input_file.close()
output_file.close()


habeb00
Fewer than 10 Posts
Fewer than 10 Posts
Posts: 9
Joined: Mon Dec 12, 2016 1:26 pm
Has thanked: 1 time

Re: Encoding of VCO export files

Postby habeb00 » Mon Dec 19, 2016 9:30 am

HI dbbarron,

Thank you for providing the python script for us non-coders. Quick question regarding renaming the video file for 8 char compatible with Circuit Tools. Can the string be anything as long as it's characters long? Do you have an example string?



Return to “Support LapTimer Development”

Who is online

Users browsing this forum: No registered users and 1 guest