• Stars
    star
    114
  • Rank 299,398 (Top 7 %)
  • Language
    C++
  • License
    GNU Lesser Genera...
  • Created about 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

QuickTime file parameter editor for modifying transfer function, colour primary and matrix characteristics

BBC RD Logo

QuickTime File Format and ProRes Video Parameter Editing

Part of the HDR-TV series. Last updated April 2017.

Introduction

Several post-production tools and utilities are now aware of the colour and transfer function parameters specified in ITU-R BT.2100-0. However, some tools are unable to correctly signal the correct parameters, and may result in a file with the incorrect video parameters. Subsequent tools or displays may then look at these video parameters and render the image incorrectly, for instance, video that this signalled as ITU-R BT.709 colour primaries and in fact is ITU-R BT.2020 colour primary and then displayed on a monitor will look desaturated when the display is interpreting the signalling contained within the file. Incorrect signalling may also result in unnecessary and incorrect transcoding between colour spaces and transfer functions.

This document introduces a series of tools to allow editing of the colour primaries, colour matrix and transfer function characteristics in a QuickTime File Format (MOV) using a ProRes video codec.

QuickTime File Format (qtff)

The QuickTime File Format (qtff) is a container file supporting a wide range of video, audio and other data formats. The format itself is object-orientated, consisting of a collection of objects that can be parsed and expanded.

The basic data unit is known as an Atom. The Atom that defines the relevant information required to define the colour primaries, colour matrix and transfer function are found in the "colr" data Atom, which is located inside the Video Media Atom. The structure of the "colr" Atom is as follows:

Colour Atom Bytes
Atom Size 4
Type = "colr" 4
Colour Parameter type = "nclc" 4
Primary index = 1 2
Transfer Function index = 1 2
Colour Matrix index = 1 2

SMPTE RDD 36:2015 - Apple ProRes Bitstream Syntax and Decoding Process

SMPTE RDD 36 describes the syntax and decoding process for the Apple ProRes video compression scheme. It is an intra-frame codec, specifically designed for high-quality workflows and supports a variety of video formats, and is common usage.

In addition to the colour information carried within the Color Atom, information regarding the transfer function, colour matrix and primaries are also stored within the frame header information of the ProRes elementary stream, alongside other parameters, such as frame rate, spatial resolution and chroma format. This header is repeated throughout the bitstream. Full details of the header layout can be found in the SMPTE specification.

To avoid any ambiguity in any workflows, it is imperative that the the information in the header for the ProRes stream match that of the qtff colr Atom.

Video Characteristics

The colour primaries can be selected from the list:

No. Colour Primaries
0 Reserved
1 ITU-R BT.709
2 Unspecified
3 Reserved
4 ITU-R BT.470M
5 ITU-R BT.470BG
6 SMPTE 170M
7 SMPTE 240M
8 FILM
9 ITU-R BT.2020
10 SMPTE ST 428-1
11 DCI P3
12 P3 D65

The transfer function can be selected from the list:

No. Transfer Function
0 Reserved
1 ITU-R BT.709
2 Unspecified
3 Reserved
4 Gamma 2.2 curve
5 Gamma 2.8 curve
6 SMPTE 170M
7 SMPTE 240M
8 Linear
9 Log
10 Log Sqrt
11 IEC 61966-2-4
12 ITU-R BT.1361 Extended Colour Gamut
13 IEC 61966-2-1
14 ITU-R BT.2020 10 bit
15 ITU-R BT.2020 12 bit
16 SMPTE ST 2084 (PQ)
17 SMPTE ST 428-1
18 ARIB STD-B67 (HLG)

The colour matrix can be selected from the list:

No. Colour Matrix
0 GBR
1 BT709
2 Unspecified
3 Reserved
4 FCC
5 BT470BG
6 SMPTE 170M
7 SMPTE 240M
8 YCOCG
9 BT2020 Non-constant Luminance
10 BT2020 Constant Luminance

Tools

This repository contains a number of tools that will aid in analysing a video file to obtain the video characteristics, and subsequently allow modification of the qttv container and ProRes bitstream to alter the characteristics

Getting Started

Prerequisites

ffprobe is required to find and extract the location of the frame headers from the ProRes bitstream. Downloads can be found here for your OS. Static builds for Linux are available if building from source is not an option. Static builds for Windows and OSX are available via third party websites. Once obtained, ffprobe must be put into the PATH.

MediaInfo is a convenient unified display of the most relevant technical and tag data for video and audio files. It is useful to check the accuracy of the tools provided within this repository.

Standard developer tools (gcc/g++, make, bash) will be required to build and run the code.

Building the code

A makefile has been provided to build the code.

cd src
make

The repository contains 3 main programs:

  • movdump - This tool creates a text dump of the header data at the qtff (mov) level.
  • rdd36dump - This tool creates a text dump of the header data at the ProRes level.
  • rdd36mod - This tool modifies the ProRes data to adjust the transfer function, colour primaries and matrix.

Running the code

The programs above can be run individually as follows:

movdump ipFile > movdump.txt

Where the output movdump.txt will look something like this:

mdat: s=          5884636816 (0x000000015ec06e90), o=         0 (0x00000000)
  ...skipped 5884636800 bytes
free: s=     24332 (0x00005f0c), o=          5884636816 (0x000000015ec06e90)
  ...skipped 24324 bytes
wide: s=         8 (0x00000008), o=          5884661148 (0x000000015ec0cd9c)
mdat: s=        12 (0x0000000c), o=          5884661156 (0x000000015ec0cda4)
  ...skipped 4 bytes
moov: s=     24938 (0x0000616a), o=          5884661168 (0x000000015ec0cdb0)
    mvhd: s=       108 (0x0000006c), o=          5884661176 (0x000000015ec0cdb8)
      version: 0
      flags: 0x000000
      ...
      ...

To run rdd36dump and rdd36mod, the location of the headers must first be located with ffprobe.

ffprobe -loglevel panic -show_packets -select_streams v:0 ipFile.mov | grep pos > header_offsets.txt

The header_offsets.txt can then be provided to rdddump

rdd36dump --offsets header_offsets.txt ipFile.mov > rdd36dump.txt

Where the output rdd36dump.txt will look something like this:

frame: num=0, pos=96256
     frame_size: 221808
     frame_identifier: 0x69637066 (icpf)
     frame_header:
         frame_header_size: 148
         reserved: 0x00
         bitstream_version: 0
         encoder_identifier: 0x61626d30 (abm0)
         horizontal_size: 3840
         vertical_size: 2160
         chroma_format: 2 (4:2:2)
         ...
         ...

Modifying the video characteristics

Using the tools above the transfer function, colour primaries and matrix can be edited using the binary offset information in the dump files. Alternatively, a script has been prepared that does it all for you. The help from the bash script describes its usage:


   qtff-parameter-editor.sh

   This script can be used to edit the primaries, transfer functions and matrix
   fields in a .mov file, it can be extended for further editting if required."

    Usage:
            qtff-parameter-editor.sh [--help] [-h] [-p priValue]
                                           [-t tfValue]
                                           [-m matValue]
                                           InputFile
                                           OutputFile
    or
            qtff-parameter-editor.sh InputFile

    Where:
      -h, --help :               Displays this help page
      -p --primaries priValue:   Where priValue is the required primaries value number
      -t --tf tfValue:           Where tfValue is the required transfer function value number
      -m --matrix matValue:      Where matValue is the required matrix function value number
      InputFile:                 Source mov file
      OutputFile:                Output mov file (Can be the same as the Input file)

   If only an Input file is provided (as in the second example, the script will return
   the information for the input file

   Example 1: ./qtff-parameter-editor.sh input.mov
              Return video parameter information for input.mov

   Example 2: ./qtff-parameter-editor.sh -p 1 -t 1 -m 1 input.mov output.mov
              Will create a copy with input.mov and modify the video parameters to bt709
              primaries, transfer function and matrix.

   Example 3: ./qtff-parameter-editor.sh --primaries 9 --tf 18 --matrix 9 input.mov input.mov
              Will modify the video parameters in situ to bt2020 primaries, HLG transfer
              function and bt2020 non constant luminance matrix


If a colr Atom is not present in the video file, the process will not attempt to insert one, and will quit the processing.

Resources

Please visit our project page for more information about High Dynamic Range (HDR) and Hybrid Log-Gamma (HLG).

Authors

This software was written by Philip de Nier (philip.denier at bbc.co.uk) and Manish Pindoria.

Contact and Legal Information

Copyright 2009-2017 British Broadcasting Corporation

The qtff-parameter-editor is free software; you can redistribute it and/or modify it under the terms of license agreement.

The qtff-parameter-editor is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

More Repositories

1

wraith

Wraith — A responsive screenshot comparison tool
Ruby
4,813
star
2

Imager.js

Responsive images while we wait for srcset to finish cooking
JavaScript
3,833
star
3

peaks.js

JavaScript UI component for interacting with audio waveforms
JavaScript
2,886
star
4

audiowaveform

C++ program to generate waveform data and render waveform images from audio files
C++
1,658
star
5

sqs-consumer

Build Amazon Simple Queue Service (SQS) based applications without the boilerplate
TypeScript
1,541
star
6

bbplot

R package that helps create and export ggplot2 charts in the style used by the BBC News data team
R
1,434
star
7

VideoContext

An experimental HTML5 & WebGL video composition and rendering API.
JavaScript
1,303
star
8

simorgh

The BBC's Open Source Web Application. Contributions welcome! Used on some of our biggest websites, e.g.
JavaScript
1,252
star
9

waveform-data.js

Audio Waveform Data Manipulation API – resample, offset and segment waveform data in JavaScript.
JavaScript
936
star
10

brave

Basic Real-time AV Editor - allowing you to preview, mix, and route live audio and video streams on the cloud
Python
646
star
11

tal

TV Application Layer
JavaScript
550
star
12

react-transcript-editor

A React component to make correcting automated transcriptions of audio and video easier and faster. By BBC News Labs. - Work in progress
JavaScript
494
star
13

psammead

React component library for BBC World Service and more
JavaScript
320
star
14

newslabs-datastringer

Monitor datasets, gets alerts when something happens
JavaScript
212
star
15

html5-video-compositor

This is the BBC Research & Development UX Team's experimental shader based video composition engine for the browser. For new projects please consider using or new VideoContext library https://github.com/bbc/videocontext .
JavaScript
207
star
16

REST-API-example

Simple REST API example in Sinatra
Ruby
193
star
17

grandstand

BBC Grandstand is a collection of common CSS abstractions and utility helper classes
SCSS
190
star
18

sqs-producer

Simple scaffolding for applications that produce SQS messages
TypeScript
181
star
19

r-audio

A library of React components for building Web Audio graphs.
JavaScript
168
star
20

chaos-lambda

Randomly terminate ASG instances during business hours
Python
163
star
21

turingcodec

Source code for the Turing codec, an HEVC software encoder optimised for fast encoding of large resolution video content
C++
153
star
22

bbc-vamp-plugins

A collection of audio feature extraction algorithms written in the Vamp plugin format.
C++
152
star
23

bbc-a11y

BBC Accessibility Guidelines Checker
Gherkin
134
star
24

rcookbook

Reference manual for creating BBC-style graphics using the BBC's bbplot package built on top of R's ggplot2 library
HTML
127
star
25

gel-grid

A flexible code implementation of the GEL Grid Guidelines
SCSS
126
star
26

audio-offset-finder

Find the offset of an audio file within another audio file
Python
124
star
27

datalab-ml-training

Machine Learning Training
Jupyter Notebook
117
star
28

Similarity

Calculate similarity between documents using TF-IDF weights
Ruby
115
star
29

flashheart

A fully-featured Node.js REST client built for ease-of-use and resilience
JavaScript
115
star
30

viewporter

In-browser responsive testing tool.
CSS
114
star
31

gel-typography

A flexible code implementation of the GEL Typography Guidelines
CSS
111
star
32

consumer-contracts

Consumer-driven contracts in JavaScript
JavaScript
105
star
33

color-contrast-checker

An accessibility checker tool for validating the color contrast based on WCAG 2.0 and WCAG 2.1 standards.
JavaScript
81
star
34

slayer

JavaScript time series spike detection for Node.js and the browser; like the Octave findpeaks function.
JavaScript
77
star
35

lrud

Left, Right, Up, Down. A spatial navigation library for devices with input via directional controls.
JavaScript
76
star
36

audio_waveform-ruby

Ruby gem that provides access to audio waveform data files generated by audiowaveform
Ruby
76
star
37

nghq

An implementation of Multicast QUIC https://tools.ietf.org/html/draft-pardue-quic-http-mcast-07
C
67
star
38

bigscreen-player

Simplified media playback for bigscreen devices
JavaScript
65
star
39

speculate

Automatically generates an RPM Spec file for your Node.js project
JavaScript
64
star
40

zeitgeist

Twitter Zeitgeist
Ruby
62
star
41

software-engineering-technical-assessments

Technical assessment for hiring
Kotlin
60
star
42

wally

Cucumber feature viewer and navigator
Ruby
57
star
43

theano-bpr

An implementation of Bayesian Personalised Ranking in Theano
Python
54
star
44

ShouldIT

A language agnostic BDD framework.
JavaScript
53
star
45

news-gem-cloudwatch-sender

Send metrics to InfluxDB from Cloudwatch
Ruby
53
star
46

unicode-bidirectional

A Javascript implementation of the Unicode 9.0.0 Bidirectional Algorithm
JavaScript
45
star
47

subtitles-generator

A node module to generate subtitles by segmenting a list of time-coded text - BBC News Labs
JavaScript
44
star
48

accessibility-news-and-you

We want to be the most accessible news website in the world. This is how.
HTML
44
star
49

codext

VS Code's editor shipped as a browser extension.
JavaScript
42
star
50

talexample

An example TV app written using TAL
JavaScript
40
star
51

rdfspace

RDFSpace constructs a vector space from any RDF dataset which can be used for computing similarities between resources in that dataset.
Python
39
star
52

digital-paper-edit-client

Work in progress - BBC News Labs digital paper edit project - React Client
JavaScript
39
star
53

clientside-recommender

A client-side recommender system implemented in Javascript.
Java
39
star
54

gel

JavaScript
39
star
55

childrens-games-starter-pack

This is the Starter Pack for Children's games, containing everything a games developer might need to start building an HTML5 game for Children's BBC. Every game should be forked into a new repository from this repo.
JavaScript
38
star
56

alephant

The Alephant framework is a collection of isolated Ruby gems, which interconnect to offer powerful message passing functionality built up around the "Broker" pattern.
Ruby
37
star
57

vc2-reference

A reference encoder and decoder for SMPTE ST 2042-1 "VC-2 Video Compression"
C++
34
star
58

ruby-lsh

Locality Sensitive Hashing in Ruby
Ruby
32
star
59

Strophejs-PubSub-Demo

A simple demo of Publish/Subscribe in the browser using Strophe.js
JavaScript
31
star
60

diarize-jruby

A simple toolkit for speaker segmentation and identification
Ruby
30
star
61

pydvbcss

Python library that implements DVB protocols for companion synchronisation
Python
28
star
62

gel-sass-tools

A collection of Sass Settings & Tools which align to key GEL values
SCSS
27
star
63

a11y-tests-web

Runs automated accessibility tests against configurable lists of webpages
JavaScript
27
star
64

RadioVisDemo

RadioDNS and RadioVIS Slideshow Protocol Demo
Python
27
star
65

device-discovery-pairing

Analysis and background research on discovery and pairing for the MediaScape project
26
star
66

node-canvas-lambda-deps

Node Canvas AWS Lambda dependencies i.e. compiled shared object files for Cairo, Pixman, libpng, libjpeg etc.
JavaScript
26
star
67

clever-thumbnailer

Audio thumbnail generator
C
25
star
68

spassky

Distributed web testing tool
JavaScript
25
star
69

genie

BBC Genie Games Framework
JavaScript
24
star
70

media-sequence

HTML5 media sequenced playback API: play one or multiple sequences of a same audio or video with plain JavaScript.
JavaScript
24
star
71

Chart.Bands.js

Chart.js plugin to allow banding on a chart
JavaScript
23
star
72

newslabs-Text_Analytics

A space for code and projects around analysing news content
Python
23
star
73

curriculum-data

BBC Curriculum Instance Data
23
star
74

bbc-speech-segmenter

A complete speech segmentation system using Kaldi and x-vectors for voice activity detection (VAD) and speaker diarisation.
Shell
22
star
75

videocontext-devtools

Chrome DevTools extension for easy VideoContext debugging.
JavaScript
22
star
76

bmx

Library and utilities to read and write broadcasting media files. Primarily supports the MXF file format
C++
22
star
77

adaptivepodcasting

A project exploring the potential of media which adapts based on sensors and data
JavaScript
21
star
78

UCMythTV

A full implementation of Universal Control 0.6.0 for use on a computer running Mythbuntu with a slightly modified version of MythTV (patches and configure script included).
Python
20
star
79

rdfsim

Large RDF hierarchies as vector spaces
Python
20
star
80

lrud-spatial

Left, Right, Up, Down. A spatial navigation library for devices with input via directional controls.
JavaScript
20
star
81

digital-paper-edit-electron

Work in progress - BBC News Labs digital paper edit project - Electron, Cross Platform Desktop app - Mac, Windows, Linux
C++
20
star
82

gst-ttml-subtitles

Library and elements that add support for TTML subtitles to GStreamer.
C
19
star
83

dvbcss-synctiming

Measuring synchronisation timing accuracy for DVB Compainion Screen Synchronisation TVs and Companions
Python
19
star
84

fcpx-xml-composer

Work in progress - Module to Convert a json sequence into an FCPX XML. For BBC News Labs digital paper edit project
JavaScript
18
star
85

bbcrd-brirs

An impulse response dataset for dynamic data-based auralisation of advanced sound systems
Common Lisp
18
star
86

bug

Started life at BBC News - BUG enables control and monitoring of broadcast kit from a single web interface.
JavaScript
17
star
87

MiD

Make it Digital: the BBC's Digital Creativity initiative
Arduino
17
star
88

device_api-android

DeviceAPI-Android
Ruby
17
star
89

cloudflare-queue-consumer

Build Cloudflare Queues based applications without the boilerplate (based on SQS Consumer)
TypeScript
17
star
90

gs-sass-tools

A collection of Sass variables, functions and mixins, part of BBC Grandstand
CSS
16
star
91

enzyme-adapter-inferno

Inferno enzyme adapter
JavaScript
16
star
92

get-title

Extract the best title value from within HTML head elements.
JavaScript
16
star
93

morty-docs

Generate a static website from markdown files
JavaScript
16
star
94

storyplayer

BBC Research & Development's Object Based Media Player
TypeScript
15
star
95

dialogger

Text-based media editing interface
JavaScript
15
star
96

bbcat-base

Base library for the BBC Audio Toolbox
C++
15
star
97

catflap-camera

Raspberry Pi based catflap-triggered camera. As seen on TV.
Python
15
star
98

citron

Citron is an experimental quote extraction system created by BBC R&D
Python
15
star
99

crimp

Creating an md5 hash of a number, string, array, or hash in Ruby
Ruby
15
star
100

automated-audio-tagging-evaluation

Evaluation dataset and script for automated DBpedia tagging of speech audio
Python
15
star