Skip to content

Persistence layer

Leo Nikkilä edited this page Jan 9, 2015 · 8 revisions

Each video has a unique identifier — a dash-grouped lowercase UUID: 123e4567-e89b-12d3-a456-426655440000.

Videos are stored locally on the device in the DCIM/Ach so!/ folder. Usually there are three files.

  • 123e4567-e89b-12d3-a456-426655440000.mp4

    The raw video.

  • 123e4567-e89b-12d3-a456-426655440000.jpg

    A thumbnail of the raw video.

  • 123e4567-e89b-12d3-a456-426655440000.json

    A “manifest” file that contains metadata for the video.

Manifest

The manifest file is a plain ol’ JSON file. The format is pretty self-explanatory:

{
    "annotations": [
        {
            "author": {
                "name": "Unknown",
                "uri": "http://example.com"
            },
            "position": {
                "x": 0.49725273,
                "y": 0.49470899
            },
            "text": "x",
            "time": 754
        }
    ],
    "author": {
        "name": "Unknown",
        "uri": "http://example.com"
    },
    "date": "2014-12-15T11:38:18.559+02:00",
    "genre": "Good work",
    "id": "123e4567-e89b-12d3-a456-426655440000",
    "location": {
        "accuracy": 16.97,
        "latitude": 60.1783053,
        "longitude": 24.8287727
    },
    "tag": "a related tag string from a QR code for example",
    "thumbUri": "file:///storage/emulated/0/DCIM/Ach%20so!/123e4567-e89b-12d3-a456-426655440000.jpg",
    "title": "Miestentie 3, 15 Dec 2014 11:38:18",
    "videoUri": "file:///storage/emulated/0/DCIM/Ach%20so!/123e4567-e89b-12d3-a456-426655440000.mp4"
}

The URIs in the manifest can be either local or remote; it’s possible to load videos purely from a manifest file. The supported schemes are:

  • file
  • content (an Android-specific local scheme)
  • http
  • https

How videos are loaded

When Ach so! is first started, it scans its DCIM/Ach so! directory for any JSON files. It reads the JSON manifest files and deserialises a subset of the data into partial video objects that are then cached in memory.

When more data is needed, annotations for example, Ach so! parses a complete representation from the manifest file. This is not cached.

Exporting videos

Videos can be exported as .achso files that are just regular .zip files. They contain at least the manifest at the root of the archive.

It is recommended that the manifest is the only .json file at the root of the archive. If this is not the case, the parser should look for a .json file with the same base name as the archive itself.

If streaming is desired, the following requirements must be fulfilled:

  1. The manifest is the first entry in the archive.
  2. The archive is uncompressed, i.e. the compression method is STORE.
Clone this wiki locally