Skip to content

Instantly share code, notes, and snippets.

@nuc
Created March 8, 2023 14:04
Show Gist options
  • Select an option

  • Save nuc/200c4a47fedd744a37e92b452f1237a6 to your computer and use it in GitHub Desktop.

Select an option

Save nuc/200c4a47fedd744a37e92b452f1237a6 to your computer and use it in GitHub Desktop.

Revisions

  1. nuc revised this gist Mar 8, 2023. 1 changed file with 0 additions and 0 deletions.
    Empty file modified attach-cube.sh
    100644 → 100755
    Empty file.
  2. nuc created this gist Mar 8, 2023.
    38 changes: 38 additions & 0 deletions attach-cube.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    #!/bin/bash

    # Check if both parameters have been provided
    if [ $# -ne 2 ]; then
    echo "Usage: $0 <video_file> <cube_file>"
    exit 1
    fi

    # Check if mkvmerge is available in PATH
    if ! command -v mkvmerge &> /dev/null; then
    echo "Error: mkvmerge is not available in PATH. Please add it to your PATH environment variable."
    echo "To add it, you can run:"
    echo " export PATH=\"\$PATH:/path/to/mkvmerge\""
    exit 1
    fi

    # Get the directory path and file name of the input video file
    input_dir=$(dirname "$1")
    input_file=$(basename "$1")

    # Get the base name of the video file
    output_file="${input_file%.*}.mkv"

    # Run the command
    mkvmerge -o "${input_dir}/${output_file}" \
    --colour-matrix 0:9 \
    --colour-range 0:1 \
    --colour-transfer-characteristics 0:16 \
    --colour-primaries 0:9 \
    --max-content-light 0:1000 \
    --max-frame-light 0:300 \
    --max-luminance 0:1000 \
    --min-luminance 0:0.01 \
    --chromaticity-coordinates 0:0.68,0.32,0.265,0.690,0.15,0.06 \
    --white-colour-coordinates 0:0.3127,0.3290 \
    --attachment-mime-type application/x-cube \
    --attach-file "$2" \
    "$1"