From MP4 to Mapillary

@DickePeter

I am referring to
GSV2JPG - Google Drive
,
UL2GSV - Google Drive
and
VID2JPG - Google Drive

I expect that when you click the link Google Drive presents a dialogue to request access to the folder. If there is an option to include a message, then ask Dean an alternative for you to contact him.
The last one should be of your interest, but it may not be able to handle what comes from your specific camera.

Do share what you learn here on the forum. Success!

Thank you for your feedback, I made an access request once.

1 Like

Quick look showed that the NMEA sentences are embedded in the file. It’s not exactly same implementation as some others, but at least there isn’t any encryption in place.

EDIT: I added support for these video files here: https://github.com/taneljairus/random-mapillary-stuff/blob/master/ts_processor.py

I only tested it with that one video and it looked plausible.

1 Like

Oh that sounds good, I’ll test it tomorrow.
What exactly does the script do.
Thank you very much.

The script takes input video and extracts geotagged JPEG images. There are lot of options implemented, such as interpolation for missing coordinates, cropping, masking and so on.

It’s documentation is lacking, but the development process is described here: Page not found

Input parameters are as follows:

–bearing_modifier 180 if rear camera
–bearing_recalculate should bearing be recalculated from trajectory
–crop_bottom number of pixels to crop from bottom
–crop_left number of pixels to crop from left
–crop_right number of pixels to crop from right
–crop_top number of pixels to crop from top
–csv create csv from coordinates before and after interpolation.
–device_override force treatment as specific device, B for B4k, V for Viofo
–folder output folder, will be created if not exists
–input input file or folder
–make set camera make to be written in EXIF
–mask masking image, must be same dimensionally as video
–metric_distance distance between images, overrides sampling_interval.
–min_coverage percentage - how much video must have GPS data in order to interpolate missing
–min_points how many points to allow video extraction
–min_speed minimum speed in m/s to filter out stops
–model set camera model to be written in EXIF
–sampling_interval distance between images in seconds.
–suppress_cv2_warnings If disabled, will show lot of harmless warnings in console. Known to cause issues on Windows.
–timeshift time shift in seconds, if the gps and video seem out of sync
–timezone timezone difference in hours. Depends on video source, some provide GMT, others local
2 Likes

@jorrarro does the script work for GoPro too, or does it need some modifications first?

It does not. Quick googling revealed that GoPro stores it’s geodata differently than currently implemented sources. However, it’s probably not too difficult to add that support if necessary.

1 Like

Okay, I found the one with the CSV module. But he complains about the input.
used the following command.

python3 ts_processor.py --input /Space/Dashcam/Test --sampling_interval 0.5 --timeshift 0.5 --folder output

Namespace(input=‘/Space/Dashcam/Test’, sampling_interval=0.5, folder=‘output’, timeshift=0.5, timez one=0.0, min_speed=-1.0, bearing_modifier=0.0, bearing_recalculate=0.0, min_coverage=90, min_points =5, metric_distance=0, csv=0, suppress_cv2_warnings=0, device_override=‘’, mask=None, crop_left=0, crop_right=0, crop_top=0, crop_bottom=0, make=None, model=None)
Traceback (most recent call last):
File “/sharedfolders/Space/Dashcam/mapil-mp4-jpg/ts_processor.py”, line 651, in
for input_ts_file in inputfiles:
NameError: name ‘inputfiles’ is not defined

There is something wrong with folder as input, sometimes it works and other times not. There is a workaround like this:

for f in *.MP4; do python3 ts_processor.py --input $f --sampling_interval 0.5 --timeshift 0.5 --folder output; done

If I use the command from you, he always gets a different message out of me.

usage: ts_processor.py [-h] --input INPUT [–sampling_interval SAMPLING_INTERVAL] [–folder FOLDER] [–timeshift TIMESHIFT] [–timezone TIMEZONE] [–min_speed MIN_SPEED] [–bearing_modifier BEARING_MODIFIER]
[–bearing_recalculate BEARING_RECALCULATE] [–min_coverage MIN_COVERAGE] [–min_points MIN_POINTS] [–metric_distance METRIC_DISTANCE] [–csv CSV] [–suppress_cv2_warnings SUPPRESS_CV2_WARNINGS]
[–device_override DEVICE_OVERRIDE] [–mask MASK] [–crop_left CROP_LEFT] [–crop_right CROP_RIGHT] [–crop_top CROP_TOP] [–crop_bottom CROP_BOTTOM] [–make MAKE] [–model MODEL]
ts_processor.py: error: argument --input: expected one argument

Because with your command there is no indication of the input if the files are not in the same place.

Thank you, it worked.

I just fail that it processes all videos from a folder directly

And how can I automate that now?
So that I only have to store the files accordingly and the rest including the upload to Mapi and kartaview is automatic?

I would prefer the following sequence.
Connect the SD card from the camera with the adapter to the Raspberry and the rest will work automatically. Can something like that be realized?
I am not so fit with such automation and server technology.

Somehow weird on the Windows PC, the following error messages appear, but the first 4 videos worked.

Python 3.9.7

Traceback (most recent call last):
File “D:\Dashcam\software\ts_processor.py”, line 654, in
device,make,model = detect_file_type(input_ts_file)
File “D:\Dashcam\software\ts_processor.py”, line 287, in detect_file_type
inp = Box.parse(box.data[offset:])
File “C:\Python39\lib\site-packages\construct\core.py”, line 175, in parse
return self.parse_stream(BytesIO(data), context, **kw)
File “C:\Python39\lib\site-packages\construct\core.py”, line 186, in parse_stream
return self._parse(stream, context, “parsing”)
File “C:\Python39\lib\site-packages\pymp4\parser.py”, line 46, in _parse
obj = self.subcon._parse(stream2, context, path)
File “C:\Python39\lib\site-packages\construct\core.py”, line 855, in _parse
subobj = list(sc._parse(stream, context, path).items())
File “C:\Python39\lib\site-packages\construct\core.py”, line 297, in _parse
return self.subcon._parse(stream, context, path)
File “C:\Python39\lib\site-packages\construct\core.py”, line 1544, in _parse
obj = self.cases.get(key, self.default)._parse(stream, context, path)
File “C:\Python39\lib\site-packages\construct\core.py”, line 859, in _parse
subobj = sc._parse(stream, context, path)
File “C:\Python39\lib\site-packages\construct\core.py”, line 2696, in _parse
return self.subcon._parse(stream, context, path)
File “C:\Python39\lib\site-packages\construct\core.py”, line 297, in _parse
return self.subcon._parse(stream, context, path)
File “C:\Python39\lib\site-packages\construct\core.py”, line 427, in _parse
return stream.read()
File “C:\Python39\lib\site-packages\construct\lib\bitstream.py”, line 158, in read
raise IOError(“could only read %s bytes, requested %s” % (len(data),count))
OSError: could only read 105526 bytes, requested 2109090094

@DickePeter

Free disk space or a filesystem error perhaps?

1 Like

It looks like somewhat corrupted file, as MP4 parser tries to read bytes beyond end of the file. Or there is a bug in the script.

I’ve tried several files. There is also enough storage space. One file can no longer be broken down into the next. I want a solution that works and I am not an IT freak who likes to tinker with it

It may not work on the Linux system either. No idea what it is.