Add "side_data_list" metadata to video stream of 3D 180º video file

Started by drmillerkc, May 08, 2024, 10:36:46 AM

Previous topic - Next topic

drmillerkc

After rendering from a 3D 180º camera application, the resulting mp4 has the metadata, "side_data_list" added to the video stream (there are three streams - video, audio, and general). This is necessary for display in YouTube and 3D headsets. Unfortunately using Apple's Final Cut Pro to edit, combine, etc. using these videos, that metadata is removed. In order to add that metadata back in Google's VR180 Creator app CAN add that metadata (and more specific to YouTube) back to the video file without reprocessing the entire (large) video file.

The original metadata structure (JSON) is:

"side_data_list": [
                {
                    "side_data_type": "Stereo 3D",
                    "type": "side by side",
                    "inverted": 0
                },
                {
                    "side_data_type": "Spherical Mapping",
                    "projection": "equirectangular",
                    "yaw": 0,
                    "pitch": 0,
                    "roll": 0
                }

It seems like there is a way to add this back as another array (TAG:{}) to the specific stream with exiftool using the JSON file command but I am stumped how to select the video stream (the first item of Streams [ {index:0 or 1 or ???... as sometimes the video metadata is the first item in Streams and sometimes it is the second.

I'm hoping to using exiftool in an Apple Automator application to gather the filenames and then just drop a video file into it and add this ?simple? metadata back in.

Can exiftool add this metadata to a video stream (one of three) and how? Thanks.

Phil Harvey

ExifTool does not have the ability to add metadata to individual streams in a video file.  It can add only top-level metadata.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

drmillerkc

Thanks! It will save me some time as ChatGPT 3.5 sent me an authoritative hallucination LOL (below):

"By following these steps and using ExifTool with the -json option, you can add JSON-formatted metadata to specific streams of a video file. Adjust the command based on your specific metadata structure and requirements."



Phil Harvey

Nice.  I would like to see the incantation that you summoned.  :)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

drmillerkc

I've tried both Gemini and ChatGPT 3.5 and I don't remember the exact incantation or which one I used (I usually see the entire thread of questions), although these things generally repeat back what you ask. So, it started with "Is there also a command to write meta data to a video using exifTool and the second was something like "How can you add JSON-formatted metadata to a specific stream of a video file using ExifTool?" It did use the metadata I used as an example in this answer.

Here's the entire response:

To add JSON-formatted metadata to a specific stream of a video file using ExifTool, you can use the `-json` option along with specific tag names to specify the metadata you want to add. ExifTool allows you to manipulate metadata in various file formats, including video files.

Here's a step-by-step guide on how to add JSON-formatted metadata to a specific stream of a video using ExifTool:

### Step 1: Install ExifTool
Make sure you have ExifTool installed on your system. You can download and install it from the official website: https://exiftool.org/

### Step 2: Prepare your JSON Metadata
Create a JSON file containing the metadata you want to add. For example, let's say you have the following metadata in `metadata.json`:

```json
{
  "streams": [
    {
      "side_data_type": "Stereo 3D",
      "type": "side by side",
      "inverted": 0
    },
    {
      "side_data_type": "Spherical Mapping",
      "projection": "equirectangular",
      "yaw": 0,
      "pitch": 0,
      "roll": 0
    }
  ]
}
```

### Step 3: Use ExifTool to Add Metadata
Run ExifTool with the `-json` option to add the JSON metadata to your video file:

```bash
exiftool -json=metadata.json video.mp4
```

In this command:
- `-json=metadata.json`: Specifies the JSON file containing the metadata to be added.
- `video.mp4`: Specifies the video file to which the metadata will be added.

ExifTool will read the JSON metadata from `metadata.json` and apply it to `video.mp4`. The metadata will be added at the top level of the video file, affecting all streams.

### Step 4: Add Metadata to a Specific Stream
If you want to add metadata to a specific stream (e.g., video or audio stream), you'll need to specify the stream using ExifTool's tag naming convention. You can use `"-TAG:StreamNumber"` to target a specific stream.

For example, to add metadata to the video stream of `video.mp4`, you might use:

```bash
exiftool -json=metadata.json -VideoStream:all video.mp4
```

Replace `VideoStream` with the appropriate tag for the stream you want to target (`VideoStream` for video, `AudioStream` for audio, etc.). The `:all` suffix applies the metadata to all instances of the specified stream type.

### Additional Considerations
- Check the ExifTool documentation for more information on tag naming and options: https://exiftool.org/exiftool_pod.html
- Ensure that the JSON metadata file (`metadata.json`) is properly formatted and contains valid JSON syntax.
- ExifTool supports a wide range of metadata formats and file types. Refer to the documentation for advanced usage and customization.

By following these steps and using ExifTool with the `-json` option, you can add JSON-formatted metadata to specific streams of a video file. Adjust the command based on your specific metadata structure and requirements.

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).