-
Notifications
You must be signed in to change notification settings - Fork 200
Add common media file definitions for BEP044/BEP047 #2367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yarikoptic
wants to merge
21
commits into
bids-standard:master
Choose a base branch
from
yarikoptic:mediafiles
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e9500ed
Add common media file definitions (suffixes, extensions, metadata, si…
yarikoptic bd55318
Fix table separator padding for remark-lint compliance
yarikoptic 0a9addd
Reuse existing RecordingDuration instead of introducing Duration
yarikoptic 4faad34
Document AudioSampleRate vs SamplingFrequency distinction
yarikoptic 56be0f6
Include .tif alongside .tiff in image formats table
yarikoptic 8381389
Document relationship between media files and existing photo suffix
yarikoptic 311e335
Render media metadata tables from schema using macros
yarikoptic 4267efe
Render media suffix definitions from schema using macro
yarikoptic 96dca84
Add make_extension_table macro and use it for media format tables
yarikoptic 933b390
Add test for make_extension_table macro
yarikoptic be841b7
Remove overspecification for "photo" and clarify on variable rate
yarikoptic aba8721
Clarify Width/Height and add PixelFormat
yarikoptic a5b7aea
Add VideoFrameCount; prefix-align FrameRate, Width, Height
yarikoptic e576fea
Rename PixelFormat to ImagePixelFormat and move to MediaImageProperties
yarikoptic 399713d
Minor wording tune up on the choices
yarikoptic c29ed8b
Add ImageBitDepth (OPTIONAL) under MediaImageProperties
yarikoptic 6bf8f12
Merge branch 'master' into mediafiles
yarikoptic 71b33c9
Add flac extension and AudioBitDepth to common media definitions
bendichter 1330ad9
List flac in the media-files appendix audio formats table
bendichter 811b8fc
Merge pull request #3 from bendichter/media-extra-formats
yarikoptic f49c5d9
Merge branch 'master' into mediafiles
bendichter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| # Media Files | ||
|
|
||
| ## Introduction | ||
|
|
||
| Several BIDS datatypes make use of media files — audio recordings, video recordings, | ||
| combined audio-video recordings, and still images. | ||
| This appendix defines the common file formats, metadata conventions, | ||
| and codec identification schemes shared across all datatypes that use media files. | ||
|
|
||
| The following media suffixes are defined: | ||
|
|
||
| {{ MACROS___make_suffix_table(["audio", "video", "audiovideo", "image"]) }} | ||
|
|
||
| Datatypes that incorporate media files (for example, behavioral recordings or stimuli) | ||
| define their own file-naming rules, directory placement, and datatype-specific metadata. | ||
| The conventions described here apply uniformly to all such datatypes. | ||
|
|
||
| ### Relationship to the `photo` suffix | ||
|
|
||
| The media file definitions introduced here generalize the concept of all media in BIDS. | ||
| The existing `photo` suffix (used for photographs of anatomical landmarks, | ||
| head localization coils, and tissue samples) predates this framework and covers | ||
| a narrower use case — still images in specific electrophysiology and microscopy datatypes. | ||
|
|
||
| The media suffixes (`audio`, `video`, `audiovideo`, `image`) are intended as the | ||
| general-purpose mechanism for all media content in BIDS. | ||
| The media file framework should be generally adopted for new datatypes, | ||
| and a future proposal may deprecate the `photo` suffix in favor of the broader `image` | ||
| suffix with appropriate migration tooling | ||
| (see [bids-utils](https://github.com/bids-standard/bids-utils)). | ||
|
|
||
| ## Supported Formats | ||
|
|
||
| ### Audio formats | ||
|
|
||
| {{ MACROS___make_extension_table(["wav", "mp3", "aac", "ogg"]) }} | ||
|
|
||
| ### Video container formats | ||
|
|
||
| {{ MACROS___make_extension_table(["mp4", "avi", "mkv", "webm"]) }} | ||
|
|
||
| ### Image formats | ||
|
|
||
| {{ MACROS___make_extension_table(["jpg", "png", "svg", "webp", "tif", "tiff"]) }} | ||
|
|
||
| When choosing a format, consider the trade-off between file size and data fidelity. | ||
|
yarikoptic marked this conversation as resolved.
Outdated
|
||
| Uncompressed or lossless formats (WAV, PNG, TIFF) preserve full quality | ||
| but produce larger files. | ||
| Lossy formats (MP3, AAC, JPEG) significantly reduce file size | ||
| at the cost of some data loss. | ||
|
|
||
| ## Media Stream Metadata | ||
|
|
||
| Media files SHOULD be accompanied by a JSON sidecar file | ||
| containing technical metadata about the media streams. | ||
| The following metadata fields are defined for media files. | ||
|
|
||
| ### Duration | ||
|
|
||
| Applies to suffixes: `audio`, `video`, `audiovideo`. | ||
|
|
||
| {{ MACROS___make_sidecar_table("media.MediaDuration") }} | ||
|
|
||
| `RecordingDuration` reuses the existing BIDS metadata field already defined for | ||
| electrophysiology recordings (EEG, iEEG, MEG, and others). | ||
|
|
||
| ### Audio stream properties | ||
|
|
||
| Applies to suffixes: `audio`, `audiovideo`. | ||
|
|
||
| {{ MACROS___make_sidecar_table("media.MediaAudioProperties") }} | ||
|
|
||
| Note: `AudioSampleRate` is used instead of the existing `SamplingFrequency` field | ||
| because audio-video files require distinguishing the audio sampling rate from the | ||
| video frame rate. The `Audio` prefix makes this unambiguous in multi-stream containers. | ||
|
|
||
| ### Image properties | ||
|
|
||
| Applies to suffixes: `video`, `audiovideo`, `image`. | ||
|
|
||
| {{ MACROS___make_sidecar_table("media.MediaImageProperties") }} | ||
|
|
||
| ### Video stream properties | ||
|
yarikoptic marked this conversation as resolved.
|
||
|
|
||
|
yarikoptic marked this conversation as resolved.
|
||
| Applies to suffixes: `video`, `audiovideo`. | ||
|
|
||
| {{ MACROS___make_sidecar_table("media.MediaVideoProperties") }} | ||
|
|
||
|
yarikoptic marked this conversation as resolved.
|
||
| ## Codec Identification | ||
|
|
||
| Codec identification uses two complementary naming systems: | ||
|
|
||
| ### FFmpeg codec names (RECOMMENDED) | ||
|
|
||
| The `AudioCodec` and `VideoCodec` fields use | ||
| [FFmpeg codec names](https://www.ffmpeg.org/ffmpeg-codecs.html) as the RECOMMENDED | ||
| convention. These names are the de facto standard in scientific computing and can be | ||
| auto-extracted from media files using: | ||
|
|
||
| ```bash | ||
| ffprobe -v quiet -print_format json -show_streams <file> | ||
| ``` | ||
|
|
||
| ### RFC 6381 codec strings (OPTIONAL) | ||
|
|
||
| The `AudioCodecRFC6381` and `VideoCodecRFC6381` fields use | ||
| [RFC 6381](https://datatracker.ietf.org/doc/html/rfc6381) codec strings. | ||
| These provide precise codec profile and level information useful for | ||
| web and broadcast interoperability. | ||
|
|
||
| ### Common codec reference | ||
|
|
||
| | Codec | FFmpeg Name | RFC 6381 String | Notes | | ||
| | -------------- | ----------- | ------------------ | ----------------------- | | ||
| | H.264 / AVC | `h264` | `avc1.640028` | Most widely supported | | ||
| | H.265 / HEVC | `hevc` | `hev1.1.6.L93.B0` | High efficiency | | ||
| | VP9 | `vp9` | `vp09.00.10.08` | Open, royalty-free | | ||
| | AV1 | `av1` | `av01.0.01M.08` | Next-gen open codec | | ||
| | AAC-LC | `aac` | `mp4a.40.2` | Default audio for MP4 | | ||
| | MP3 | `mp3` | `mp4a.6B` | Legacy lossy audio | | ||
| | Opus | `opus` | `Opus` | Open, low-latency audio | | ||
| | FLAC | `flac` | `fLaC` | Open lossless audio | | ||
| | PCM 16-bit LE | `pcm_s16le` | — | Uncompressed (WAV) | | ||
|
|
||
| The FFmpeg name column shows the value to use for `VideoCodec` or `AudioCodec`. | ||
| The RFC 6381 column shows the value for `VideoCodecRFC6381` or `AudioCodecRFC6381`. | ||
| RFC 6381 strings vary by profile and level; | ||
| the values shown are representative examples. | ||
|
|
||
| ## Privacy Considerations | ||
|
|
||
| Media files — particularly audio and video recordings — may contain | ||
| personally identifiable information (PII), including but not limited to: | ||
|
|
||
| - Voices and speech content | ||
| - Facial features and other physical characteristics | ||
| - Background environments that could identify locations | ||
| - Metadata embedded in file headers (for example, GPS coordinates, device identifiers) | ||
|
|
||
| Researchers MUST ensure that sharing of media files complies with the | ||
| informed consent obtained from participants and with applicable privacy regulations. | ||
| De-identification techniques (for example, voice distortion, face blurring, | ||
| metadata stripping) SHOULD be applied where appropriate before data sharing. | ||
|
bendichter marked this conversation as resolved.
|
||
|
|
||
| ## Example | ||
|
|
||
| A complete sidecar JSON file for an audio-video recording: | ||
|
|
||
| ```json | ||
| { | ||
| "RecordingDuration": 312.5, | ||
| "VideoCodec": "h264", | ||
| "VideoCodecRFC6381": "avc1.640028", | ||
| "VideoFrameRate": 30, | ||
| "VideoFrameCount": 9375, | ||
| "ImageWidth": 1920, | ||
| "ImageHeight": 1080, | ||
| "ImagePixelFormat": "yuv420p", | ||
| "AudioCodec": "aac", | ||
| "AudioCodecRFC6381": "mp4a.40.2", | ||
| "AudioSampleRate": 48000, | ||
| "AudioChannelCount": 2 | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.