Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

feat(hdr): each timeline has a colour - SDR, HLG or PQ - and turns HLG on its first HDR clip

Jareer40b97eb3262f
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index 57fd4e56..9bdae3a5 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -322,6 +322,11 @@ flowchart LR
merge by re-anchoring the fractions in those commands, so the document
stays version 1.
- Selecting or moving a timeline is view state and does not enter undo.
+- Each timeline has a colour it is output in (`VideoSettings::color_space`:
+ SDR, HLG or PQ; left out of the document for SDR), and each media item the
+ one its probe read from the file's tags. `Editor::follow_first_hdr` turns
+ an SDR timeline HLG when a command puts its first HDR clip on it, in that
+ command's undo step; the Modify sheet sets it back or to PQ.
## 7. The API and the three doors
diff --git a/src/crates/concat-api/src/lib.rs b/src/crates/concat-api/src/lib.rs
index 6785a430..65fd7b3c 100644
--- a/src/crates/concat-api/src/lib.rs
+++ b/src/crates/concat-api/src/lib.rs
@@ -1031,6 +1031,7 @@ mod tests {
has_audio: false,
audio_tracks: Vec::new(),
origin: None,
+ color_space: Default::default(),
}
}
@@ -1116,6 +1117,7 @@ mod tests {
height: 1920,
rate_num: 60,
rate_den: 1,
+ color_space: Default::default(),
}),
})));
assert_eq!(created.settings.width, 1080);
diff --git a/src/crates/concat-export/src/flatten.rs b/src/crates/concat-export/src/flatten.rs
index f08ac5b8..74e64d00 100644
--- a/src/crates/concat-export/src/flatten.rs
+++ b/src/crates/concat-export/src/flatten.rs
@@ -232,6 +232,7 @@ mod tests {
has_audio: true,
audio_tracks: Vec::new(),
origin: None,
+ color_space: Default::default(),
},
})
.expect("adds media")
diff --git a/src/crates/concat-host/src/media.rs b/src/crates/concat-host/src/media.rs
index 18007a34..217a9d6f 100644
--- a/src/crates/concat-host/src/media.rs
+++ b/src/crates/concat-host/src/media.rs
@@ -7,9 +7,10 @@
use std::path::{Path, PathBuf};
-use concat_core::frame::Frame;
+use concat_core::frame::{Frame, Signal};
use concat_core::time::Rational;
use concat_media::{DecodeOptions, Decoder, FrameSource, SeekableSource};
+use concat_project::model::ColorSpace;
use serde::Serialize;
use crate::projects;
@@ -35,6 +36,9 @@ pub struct VideoStreamInfo {
/// for limited.
#[serde(skip_serializing_if = "Option::is_none")]
pub color_range: Option<String>,
+ /// What the picture was recorded in: HLG or PQ for HDR, absent for SDR.
+ #[serde(skip_serializing_if = "ColorSpace::is_sdr")]
+ pub color_space: ColorSpace,
}
/// An audio stream, as the UI sees it.
@@ -125,6 +129,11 @@ impl MediaSummary {
.map(AudioStreamInfo::to_track)
.collect(),
origin: None,
+ color_space: self
+ .video
+ .as_ref()
+ .map(|video| video.color_space)
+ .unwrap_or_default(),
}
}
}
@@ -194,6 +203,11 @@ impl From<concat_media::MediaInfo> for MediaSummary {
video.frame_rate.fps().denominator()
),
color_range: video.color_range.map(|range| range.name().to_owned()),
+ color_space: match video.signal {
+ Signal::Hlg => ColorSpace::Hlg,
+ Signal::Pq => ColorSpace::Pq,
+ Signal::Sdr | Signal::SdrWide => ColorSpace::Sdr,
+ },
}),
audio: info.audio.map(AudioStreamInfo::from_stream),
audio_tracks: info
@@ -843,6 +857,7 @@ mod tests {
height: 1080,
frame_rate: concat_core::time::FrameRate::from_int(25),
color_range: None,
+ signal: Signal::Sdr,
}),
audio: None,
audio_streams: Vec::new(),
@@ -1029,6 +1044,7 @@ mod tests {
has_audio: false,
audio_tracks: Vec::new(),
origin: None,
+ color_space: Default::default(),
},
})
.expect("adds")
diff --git a/src/crates/concat-host/src/session.rs b/src/crates/concat-host/src/session.rs
index 2256d2d9..1c7b179c 100644
--- a/src/crates/concat-host/src/session.rs
+++ b/src/crates/concat-host/src/session.rs
@@ -307,6 +307,7 @@ mod tests {
height: 720,
rate_num: 25,
rate_den: 1,
+ color_space: Default::default(),
})
.expect("sets the frame");
session.save(Some("Renamed")).expect("saves");
diff --git a/src/crates/concat-host/src/templates.rs b/src/crates/concat-host/src/templates.rs
index 6052c1df..f9014c90 100644
--- a/src/crates/concat-host/src/templates.rs
+++ b/src/crates/concat-host/src/templates.rs
@@ -445,6 +445,7 @@ mod tests {
has_audio: false,
audio_tracks: Vec::new(),
origin: None,
+ color_space: Default::default(),
},
}
}
diff --git a/src/crates/concat-host/tests/export.rs b/src/crates/concat-host/tests/export.rs
index aa4d105f..1823f124 100644
--- a/src/crates/concat-host/tests/export.rs
+++ b/src/crates/concat-host/tests/export.rs
@@ -646,6 +646,7 @@ fn video(width: u32, height: u32, rate_num: i64, rate_den: i64) -> VideoSettings
height,
rate_num,
rate_den,
+ color_space: Default::default(),
}
}
diff --git a/src/crates/concat-media/src/probe.rs b/src/crates/concat-media/src/probe.rs
index 54a38492..c680872f 100644
--- a/src/crates/concat-media/src/probe.rs
+++ b/src/crates/concat-media/src/probe.rs
@@ -5,6 +5,7 @@
use std::path::{Path, PathBuf};
+use concat_core::frame::Signal;
use concat_core::time::{FrameRate, Rational};
use ffmpeg_the_third as ffmpeg;
@@ -30,6 +31,9 @@ pub struct VideoStream {
/// says nothing - which a player then takes for video range. What a
/// person compares the picture against when it looks washed out.
pub color_range: Option<ColorRange>,
+ /// What the stream's tags say its picture is: HLG or PQ by its
+ /// transfer, a wide SDR by its primaries, SDR where they say nothing.
+ pub signal: Signal,
}
/// What an audio stream looks like.
@@ -174,8 +178,21 @@ fn video_stream(stream: &ffmpeg::format::stream::Stream<'_>, path: &Path) -> Res
})?;
// SAFETY: the parameters are live for as long as `stream` is, and the
- // range is a plain field libavformat filled from the container.
- let range = unsafe { (*parameters.as_ptr()).color_range };
+ // range, the transfer and the primaries are plain fields libavformat
+ // filled from the container.
+ let (range, transfer, primaries) = unsafe {
+ let raw = &*parameters.as_ptr();
+ (raw.color_range, raw.color_trc, raw.color_primaries)
+ };
+ let signal = {
+ use ffmpeg::color::{Primaries, TransferCharacteristic as Transfer};
+ match (Transfer::from(transfer), Primaries::from(primaries)) {
+ (Transfer::ARIB_STD_B67, _) => Signal::Hlg,
+ (Transfer::SMPTE2084, _) => Signal::Pq,
+ (_, Primaries::BT2020) => Signal::SdrWide,
+ _ => Signal::Sdr,
+ }
+ };
Ok(VideoStream {
index: stream.index() as u32,
codec: parameters.id().name().to_owned(),
@@ -183,6 +200,7 @@ fn video_stream(stream: &ffmpeg::format::stream::Stream<'_>, path: &Path) -> Res
height,
frame_rate: FrameRate::new(frame_rate),
color_range: ColorRange::from_ffmpeg(ffmpeg::color::Range::from(range)),
+ signal,
})
}
@@ -261,4 +279,46 @@ mod tests {
fn a_missing_file_is_an_error_not_a_panic() {
assert!(probe("does-not-exist.mp4").is_err());
}
+
+ /// The probe reads what a file's tags say its picture is: HLG, PQ, or
+ /// SDR where it is BT.709 - the fact a timeline turns HDR by.
+ #[test]
+ fn the_probe_reads_a_files_hdr_tags() {
+ use crate::encode::{EncodeOptions, Encoder, FrameSink, RateMode, VideoCodec};
+ use concat_core::frame::Frame;
+ let dir = std::env::temp_dir().join(format!("concat-probe-hdr-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&dir);
+ std::fs::create_dir_all(&dir).expect("a scratch folder");
+ let options = EncodeOptions {
+ codec: VideoCodec::Hevc,
+ preset: "ultrafast".to_owned(),
+ crf: 28,
+ rate_mode: RateMode::Vbr,
+ bitrate_kbps: 0,
+ ten_bit: false,
+ color_range: crate::ColorRange::Limited,
+ hardware: false,
+ threads: 0,
+ };
+ let rate = FrameRate::from_int(25);
+ for (name, hdr, want) in [
+ ("sdr.mp4", None, Signal::Sdr),
+ ("hlg.mp4", Some(false), Signal::Hlg),
+ ("pq.mp4", Some(true), Signal::Pq),
+ ] {
+ let path = dir.join(name);
+ let mut encoder = match hdr {
+ None => Encoder::create(&path, 64, 64, rate, &options),
+ Some(pq) => Encoder::create_mislabelled_hdr(&path, 64, 64, rate, &options, pq),
+ }
+ .expect("encodes");
+ for _ in 0..3 {
+ encoder.write_frame(&Frame::black(64, 64)).expect("writes");
+ }
+ encoder.finish().expect("finishes");
+ let info = probe(&path).expect("probes");
+ assert_eq!(info.video.expect("a picture").signal, want, "{name}");
+ }
+ let _ = std::fs::remove_dir_all(&dir);
+ }
}
diff --git a/src/crates/concat-perf/src/main.rs b/src/crates/concat-perf/src/main.rs
index ddb15c2b..6787a755 100644
--- a/src/crates/concat-perf/src/main.rs
+++ b/src/crates/concat-perf/src/main.rs
@@ -169,6 +169,7 @@ fn ripple_delete_of_200() -> Measure {
has_audio: false,
audio_tracks: Vec::new(),
origin: None,
+ color_space: Default::default(),
},
})
.expect("adds media")
@@ -261,6 +262,7 @@ fn undo_200_edits() -> Measure {
has_audio: false,
audio_tracks: Vec::new(),
origin: None,
+ color_space: Default::default(),
},
})
.expect("adds media")
@@ -311,6 +313,7 @@ fn document_round_trip() -> Measure {
has_audio: false,
audio_tracks: Vec::new(),
origin: None,
+ color_space: Default::default(),
},
})
.expect("adds media")
diff --git a/src/crates/concat-project/src/commands/clips.rs b/src/crates/concat-project/src/commands/clips.rs
index 538f4c2b..860f663b 100644
--- a/src/crates/concat-project/src/commands/clips.rs
+++ b/src/crates/concat-project/src/commands/clips.rs
@@ -336,6 +336,7 @@ pub(super) fn apply(
origin: item.origin,
placeholder: false,
color_range: None,
+ color_space: item.color_space,
extra: Default::default(),
});
id
@@ -420,6 +421,7 @@ pub(super) fn apply(
origin: item.origin,
placeholder: false,
color_range: None,
+ color_space: item.color_space,
extra: Default::default(),
});
id
diff --git a/src/crates/concat-project/src/commands/media.rs b/src/crates/concat-project/src/commands/media.rs
index 621f7b8d..f1e0276b 100644
--- a/src/crates/concat-project/src/commands/media.rs
+++ b/src/crates/concat-project/src/commands/media.rs
@@ -41,6 +41,7 @@ pub(super) fn apply(
origin: item.origin,
placeholder: false,
color_range: None,
+ color_space: item.color_space,
extra: Default::default(),
});
Ok(Outcome {
@@ -88,6 +89,7 @@ pub(super) fn apply(
media.audio_codec = item.audio_codec;
media.has_audio = item.has_audio;
media.audio_tracks = item.audio_tracks;
+ media.color_space = item.color_space;
media.placeholder = false;
let kind = match item.kind {
MediaKind::Video => ClipKind::Video,
diff --git a/src/crates/concat-project/src/commands/mod.rs b/src/crates/concat-project/src/commands/mod.rs
index f5030911..689495a9 100644
--- a/src/crates/concat-project/src/commands/mod.rs
+++ b/src/crates/concat-project/src/commands/mod.rs
@@ -13,9 +13,9 @@ use std::sync::Arc;
use serde::{Deserialize, Serialize};
use crate::model::{
- AppliedFilter, AudioTrack, Clip, ClipKind, ColorRange, Crop, CustomFont, Cutout, CutoutMode,
- KeyEase, KeyProperty, MediaItem, MediaKind, MediaOrigin, Project, SpeedPoint, Stroke,
- TextStyle, Timeline, Track, Transition, VideoSettings,
+ AppliedFilter, AudioTrack, Clip, ClipKind, ColorRange, ColorSpace, Crop, CustomFont, Cutout,
+ CutoutMode, KeyEase, KeyProperty, MediaItem, MediaKind, MediaOrigin, Project, SpeedPoint,
+ Stroke, TextStyle, Timeline, Track, Transition, VideoSettings,
};
mod audio;
@@ -210,6 +210,11 @@ pub struct NewMedia {
/// nothing.
#[serde(default)]
pub origin: Option<MediaOrigin>,
+ /// What the probe found the picture recorded in; see
+ /// `MediaItem::color_space`. Defaulted, for a caller from before it,
+ /// to SDR.
+ #[serde(default)]
+ pub color_space: ColorSpace,
}
/// Every edit, as the window sends it: a tagged `op` plus camelCase
diff --git a/src/crates/concat-project/src/doc.rs b/src/crates/concat-project/src/doc.rs
index b8f38759..8fc26d38 100644
--- a/src/crates/concat-project/src/doc.rs
+++ b/src/crates/concat-project/src/doc.rs
@@ -32,7 +32,7 @@ use std::sync::Arc;
use serde_json::{Map, Value, json};
-use crate::model::{Clip, MediaItem, Project, Timeline, VideoSettings};
+use crate::model::{Clip, ColorSpace, MediaItem, Project, Timeline, VideoSettings};
/// Bumped only when a change cannot be absorbed by defaulting. Read back
/// on load: a document from a later version is refused whole rather than
@@ -305,6 +305,7 @@ impl DocumentSettings {
height: self.height,
rate_num: self.rate_num,
rate_den: self.rate_den,
+ color_space: ColorSpace::Sdr,
}
}
}
diff --git a/src/crates/concat-project/src/editor.rs b/src/crates/concat-project/src/editor.rs
index 64552764..ea4b38b3 100644
--- a/src/crates/concat-project/src/editor.rs
+++ b/src/crates/concat-project/src/editor.rs
@@ -119,6 +119,7 @@ impl Editor {
return Ok(outcome);
}
self.tidy_touched(&before);
+ self.follow_first_hdr(&before);
let continues = match (gesture, self.undo.back()) {
(Some(gesture), Some(last)) => last.gesture.as_deref() == Some(gesture),
_ => false,
@@ -170,6 +171,56 @@ impl Editor {
}
}
+ /// Makes an SDR timeline HLG when the command put its first HDR clip on
+ /// it - a clip of a file recorded in HLG or PQ, where before it had
+ /// none - in the same step, so an undo takes both back. A timeline set
+ /// back to SDR with HDR clips already on it stays SDR (decided 26 Sept:
+ /// the Modify sheet can change it back), and only a timeline the
+ /// command wrote, and did not make, is looked at.
+ fn follow_first_hdr(&mut self, before: &Project) {
+ use std::collections::HashSet;
+ use std::sync::Arc;
+ let hdr = |project: &Project| -> HashSet<String> {
+ project
+ .media
+ .iter()
+ .filter(|media| media.color_space.is_hdr())
+ .map(|media| media.id.clone())
+ .collect()
+ };
+ let now = hdr(&self.project);
+ if now.is_empty() {
+ return;
+ }
+ let then = hdr(before);
+ let previous: std::collections::HashMap<&str, &Arc<crate::model::Timeline>> = before
+ .timelines
+ .iter()
+ .map(|timeline| (timeline.id.as_str(), timeline))
+ .collect();
+ for timeline in &mut self.project.timelines {
+ if timeline.video.color_space.is_hdr() {
+ continue;
+ }
+ // A timeline the command made keeps the colour it was made
+ // with - a copy of one set back to SDR stays SDR.
+ let Some(old) = previous.get(timeline.id.as_str()).copied() else {
+ continue;
+ };
+ if Arc::ptr_eq(old, timeline) {
+ continue;
+ }
+ let had = old.clips.iter().any(|clip| then.contains(&clip.media_id));
+ let has = timeline
+ .clips
+ .iter()
+ .any(|clip| now.contains(&clip.media_id));
+ if has && !had {
+ Arc::make_mut(timeline).video.color_space = crate::model::ColorSpace::Hlg;
+ }
+ }
+ }
+
/// Ends the gesture in progress, if any: the next command naming it
/// starts a new step rather than folding into the last one. Called when
/// the pointer goes up, or when enough time has passed that a second
diff --git a/src/crates/concat-project/src/lib.rs b/src/crates/concat-project/src/lib.rs
index aaac3126..109aaf98 100644
--- a/src/crates/concat-project/src/lib.rs
+++ b/src/crates/concat-project/src/lib.rs
@@ -59,6 +59,7 @@ mod tests {
has_audio,
audio_tracks: Vec::new(),
origin: None,
+ color_space: Default::default(),
},
}
}
@@ -136,6 +137,104 @@ mod tests {
}
}
+ /// A timeline turns HLG with its first HDR clip, in the same undo step
+ /// as the clip; one set back to SDR with HDR clips on it stays SDR; and
+ /// a file recorded in HDR that is only in the bin changes nothing.
+ #[test]
+ fn a_timeline_turns_hdr_with_its_first_hdr_clip() {
+ use crate::model::ColorSpace;
+ let (mut editor, _, _) = fixture();
+ assert!(editor.project().active().video.color_space.is_sdr());
+ let Command::AddMedia { mut item } = media("/iphone.mov", 10.0, true) else {
+ unreachable!()
+ };
+ item.color_space = ColorSpace::Hlg;
+ let hdr = editor
+ .apply(Command::AddMedia { item })
+ .expect("adds")
+ .created_id
+ .expect("id");
+ assert!(
+ editor.project().active().video.color_space.is_sdr(),
+ "in the bin only"
+ );
+ let track_id = editor.project().active().tracks[0].id.clone();
+ let add = |start: f64| Command::AddClip {
+ media_id: hdr.clone(),
+ track_id: track_id.clone(),
+ start,
+ ripple: false,
+ };
+ editor.apply(add(20.0)).expect("adds");
+ assert_eq!(editor.project().active().video.color_space, ColorSpace::Hlg);
+ assert!(editor.undo());
+ assert!(
+ editor.project().active().video.color_space.is_sdr()
+ && editor.project().active().clips.len() == 1,
+ "one step takes both back"
+ );
+ assert!(editor.redo());
+ let timeline_id = editor.project().active_timeline_id.clone();
+ let mut video = editor.project().active().video;
+ video.color_space = ColorSpace::Sdr;
+ editor
+ .apply(Command::SetTimelineVideo { timeline_id, video })
+ .expect("sets");
+ editor.apply(add(40.0)).expect("adds");
+ assert!(
+ editor.project().active().video.color_space.is_sdr(),
+ "set back to SDR, it stays"
+ );
+ }
+
+ /// A timeline's colour is left out of the document for SDR, kept
+ /// through a save and an open for HDR, and read as SDR from a document
+ /// naming one this build does not know; a file's likewise.
+ #[test]
+ fn a_colour_space_round_trips() {
+ use crate::model::{ColorSpace, VideoSettings};
+ let sdr = serde_json::to_value(VideoSettings::default()).expect("writes");
+ assert!(sdr.get("colorSpace").is_none(), "SDR documents unchanged");
+ let hlg = VideoSettings {
+ color_space: ColorSpace::Hlg,
+ ..VideoSettings::default()
+ };
+ let written = serde_json::to_value(hlg).expect("writes");
+ assert_eq!(written["colorSpace"], "hlg");
+ assert_eq!(
+ serde_json::from_value::<VideoSettings>(written).expect("reads"),
+ hlg
+ );
+ let unknown: VideoSettings = serde_json::from_value(json!({
+ "width": 1920, "height": 1080, "rateNum": 30, "rateDen": 1,
+ "colorSpace": "dolbyVision"
+ }))
+ .expect("reads");
+ assert!(unknown.color_space.is_sdr());
+
+ let (mut editor, _, _) = fixture();
+ let timeline_id = editor.project().active_timeline_id.clone();
+ editor
+ .apply(Command::SetTimelineVideo {
+ timeline_id,
+ video: VideoSettings {
+ color_space: ColorSpace::Pq,
+ ..editor.project().active().video
+ },
+ })
+ .expect("sets");
+ let Command::AddMedia { mut item } = media("/hdr10.mkv", 5.0, false) else {
+ unreachable!()
+ };
+ item.color_space = ColorSpace::Pq;
+ editor.apply(Command::AddMedia { item }).expect("adds");
+ let document = crate::to_document(&settings(), editor.project());
+ let loaded = Editor::from_document(&document).expect("loads");
+ assert_eq!(loaded.project().active().video.color_space, ColorSpace::Pq);
+ assert_eq!(loaded.project().media[1].color_space, ColorSpace::Pq);
+ assert!(loaded.project().media[0].color_space.is_sdr());
+ }
+
/// Editor with one media item and one clip at [0, 10) on track one.
fn fixture() -> (Editor, String, String) {
let mut editor = Editor::new();
@@ -646,6 +745,7 @@ mod tests {
has_audio: false,
audio_tracks: Vec::new(),
origin: None,
+ color_space: Default::default(),
};
let outcome = editor
.apply(Command::ReplaceClipMedia {
@@ -677,6 +777,7 @@ mod tests {
has_audio: true,
audio_tracks: Vec::new(),
origin: None,
+ color_space: Default::default(),
};
let outcome = editor
.apply(Command::ReplaceClipMedia {
@@ -744,6 +845,7 @@ mod tests {
has_audio: false,
audio_tracks: Vec::new(),
origin: None,
+ color_space: Default::default(),
}
};
assert!(
@@ -787,6 +889,7 @@ mod tests {
has_audio: false,
audio_tracks: Vec::new(),
origin: None,
+ color_space: Default::default(),
};
let freeze_id = editor
.apply(Command::FreezeFrame {
@@ -864,6 +967,7 @@ mod tests {
has_audio: false,
audio_tracks: Vec::new(),
origin: None,
+ color_space: Default::default(),
}),
})
.expect("freezes")
@@ -2346,6 +2450,7 @@ mod tests {
has_audio: false,
audio_tracks: Vec::new(),
origin: None,
+ color_space: Default::default(),
},
})
.expect("fills");
@@ -2386,6 +2491,7 @@ mod tests {
has_audio: false,
audio_tracks: Vec::new(),
origin: None,
+ color_space: Default::default(),
},
});
assert!(
@@ -3635,6 +3741,7 @@ mod tests {
audio_tracks: vec![],
placeholder: false,
color_range: None,
+ color_space: Default::default(),
origin: None,
extra: Default::default(),
});
@@ -3673,6 +3780,7 @@ mod tests {
audio_tracks: vec![],
placeholder: false,
color_range: None,
+ color_space: Default::default(),
origin: None,
extra: Default::default(),
});
diff --git a/src/crates/concat-project/src/model.rs b/src/crates/concat-project/src/model.rs
index 54409d4d..957ff762 100644
--- a/src/crates/concat-project/src/model.rs
+++ b/src/crates/concat-project/src/model.rs
@@ -168,6 +168,12 @@ pub struct MediaItem {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "wire::maybe")]
pub color_range: Option<ColorRange>,
+ /// What the probe found the picture recorded in: HLG or PQ for HDR.
+ /// Left out of the document for SDR - and absent from one written
+ /// before it was kept, which reads as SDR.
+ #[serde(default, skip_serializing_if = "ColorSpace::is_sdr")]
+ #[serde(deserialize_with = "wire::color_space")]
+ pub color_space: ColorSpace,
/// Where the file came from when the editor made it; see
/// [`MediaOrigin`]. Absent, and left out of the document, for an
/// import, and read as absent when it names an origin this build does
@@ -970,7 +976,7 @@ pub(crate) mod wire {
use serde::{Deserialize, Deserializer};
use serde_json::Value;
- use super::{ClipKind, MediaKind, ParamKey, TextAlign};
+ use super::{ClipKind, ColorSpace, MediaKind, ParamKey, TextAlign};
/// The entries of a list that parse, in order; not a list at all is
/// an empty one.
@@ -1046,6 +1052,12 @@ pub(crate) mod wire {
Ok(serde_json::from_value(value).unwrap_or(MediaKind::Video))
}
+ /// A colour space by name, SDR for one this build does not know.
+ pub fn color_space<'de, D: Deserializer<'de>>(deserializer: D) -> Result<ColorSpace, D::Error> {
+ let value = Value::deserialize(deserializer)?;
+ Ok(serde_json::from_value(value).unwrap_or_default())
+ }
+
/// A text alignment by name, centred for one this build does not know.
pub fn text_align<'de, D: Deserializer<'de>>(deserializer: D) -> Result<TextAlign, D::Error> {
let value = Value::deserialize(deserializer)?;
@@ -1666,13 +1678,42 @@ impl Default for Timeline {
}
}
-/// A timeline's output frame and rate.
+/// The colour a picture is in: SDR on Rec. 709, or HDR on Rec. 2020 with
+/// the hybrid log-gamma or the perceptual quantiser transfer. A timeline's
+/// is what it is output in; a media file's, what it was recorded in.
+#[derive(Clone, Copy, PartialEq, Eq, Debug, Default, Serialize, Deserialize)]
+#[serde(rename_all = "lowercase")]
+pub enum ColorSpace {
+ /// Rec. 709, SDR: every timeline until its first HDR clip.
+ #[default]
+ Sdr,
+ /// Rec. 2020 with HLG: what an iPhone records, and what a timeline
+ /// becomes on its first HDR clip.
+ Hlg,
+ /// Rec. 2020 with PQ: HDR10.
+ Pq,
+}
+
+impl ColorSpace {
+ /// Standard dynamic range: what a document that says nothing is in.
+ pub fn is_sdr(&self) -> bool {
+ *self == ColorSpace::Sdr
+ }
+
+ /// High dynamic range, HLG or PQ.
+ pub fn is_hdr(&self) -> bool {
+ !self.is_sdr()
+ }
+}
+
+/// A timeline's output frame, rate and colour.
///
/// The same four numbers the document's top-level `video` block has always
-/// carried, now one set per timeline. The top-level block is still written,
-/// as the active timeline's, so a build that predates this reads the
-/// document it always did, and a document from such a build gives every
-/// timeline that block on the way in.
+/// carried, now one set per timeline, and the colour it is output in. The
+/// top-level block is still written, as the active timeline's frame and
+/// rate, so a build that predates this reads the document it always did,
+/// and a document from such a build gives every timeline that block on the
+/// way in.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct VideoSettings {
@@ -1684,16 +1725,25 @@ pub struct VideoSettings {
pub rate_num: i64,
/// Denominator of the frame rate, e.g. 1001 for 29.97 fps.
pub rate_den: i64,
+ /// The colour the timeline is output in: SDR for every timeline from
+ /// before HDR, and until its first HDR clip (see
+ /// `Editor::follow_first_hdr`). Left out of the document for SDR, so
+ /// those documents stay as they were.
+ #[serde(default, skip_serializing_if = "ColorSpace::is_sdr")]
+ #[serde(deserialize_with = "wire::color_space")]
+ pub color_space: ColorSpace,
}
impl Default for VideoSettings {
- /// 1080p at 30, the frame a fresh project has always been born with.
+ /// 1080p at 30 in SDR, the frame a fresh project has always been born
+ /// with.
fn default() -> Self {
VideoSettings {
width: 1920,
height: 1080,
rate_num: 30,
rate_den: 1,
+ color_space: ColorSpace::Sdr,
}
}
}
@@ -1729,6 +1779,7 @@ impl VideoSettings {
} else {
fallback.rate_den
},
+ color_space: self.color_space,
}
}
diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.json
index 14285568..0bb685ff 100644
--- a/src/crates/concat/locales/de.json
+++ b/src/crates/concat/locales/de.json
@@ -814,6 +814,7 @@
"previewPane.play": "Wiedergabe",
"previewPane.previousFrame": "Vorheriges Bild",
"previewPane.quarter": "Viertel",
+ "project.hdrMonitorNote": "Der Monitor zeigt eine HDR-Timeline auf SDR tonegemappt, bis die HDR-Vorschau kommt.",
"project.output": "Ausgabe · {0}",
"project.project": "Projekt",
"relink.dismiss": "Verwerfen",
@@ -1005,6 +1006,7 @@
"studio.splitAtPlayhead": "Am Abspielkopf teilen",
"studio.stereo": "stereo",
"studio.textToSpeech": "Text zu Sprache…",
+ "studio.timelineNowHdr": "{0} ist jetzt HDR (HLG), wegen seines ersten HDR-Clips. Unter „Ändern“ lässt es sich zurückstellen.",
"studio.track": "Track {0}",
"studio.undo": "Rückgängig",
"sysinfo.application": "Anwendung",
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index 331a6853..4ba63368 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -814,6 +814,7 @@
"previewPane.play": "Play",
"previewPane.previousFrame": "Previous frame",
"previewPane.quarter": "Quarter",
+ "project.hdrMonitorNote": "The monitor shows an HDR timeline tone-mapped to SDR, until HDR preview arrives.",
"project.output": "Output · {0}",
"project.project": "Project",
"relink.dismiss": "Dismiss",
@@ -1005,6 +1006,7 @@
"studio.splitAtPlayhead": "Split at playhead",
"studio.stereo": "stereo",
"studio.textToSpeech": "Text to speech…",
+ "studio.timelineNowHdr": "{0} is now HDR (HLG), for its first HDR clip. Modify can set it back.",
"studio.track": "Track {0}",
"studio.undo": "Undo",
"sysinfo.application": "Application",
diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.json
index dc35d822..f18e6160 100644
--- a/src/crates/concat/locales/es.json
+++ b/src/crates/concat/locales/es.json
@@ -814,6 +814,7 @@
"previewPane.play": "Reproducir",
"previewPane.previousFrame": "Fotograma anterior",
"previewPane.quarter": "Un cuarto",
+ "project.hdrMonitorNote": "El monitor muestra una línea de tiempo HDR convertida a SDR hasta que llegue la vista previa HDR.",
"project.output": "Salida · {0}",
"project.project": "Proyecto",
"relink.dismiss": "Descartar",
@@ -1005,6 +1006,7 @@
"studio.splitAtPlayhead": "Dividir en el cabezal",
"studio.stereo": "stereo",
"studio.textToSpeech": "Texto a voz…",
+ "studio.timelineNowHdr": "{0} ahora es HDR (HLG), por su primer clip HDR. En Modificar puedes volver atrás.",
"studio.track": "Track {0}",
"studio.undo": "Deshacer",
"sysinfo.application": "Aplicación",
diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.json
index ccfa386f..f32a87e5 100644
--- a/src/crates/concat/locales/fa.json
+++ b/src/crates/concat/locales/fa.json
@@ -814,6 +814,7 @@
"previewPane.play": "پخش",
"previewPane.previousFrame": "فریم قبلی",
"previewPane.quarter": "یک‌چهارم",
+ "project.hdrMonitorNote": "مانیتور تا رسیدن پیش‌نمایش HDR، تایم‌لاین HDR را با Tone Mapping به SDR نشان می‌دهد.",
"project.output": "خروجی · {0}",
"project.project": "پروژه",
"relink.dismiss": "بستن",
@@ -1005,6 +1006,7 @@
"studio.splitAtPlayhead": "تقسیم در نشانگر پخش",
"studio.stereo": "Stereo",
"studio.textToSpeech": "تبدیل متن به گفتار…",
+ "studio.timelineNowHdr": "{0} اکنون HDR (HLG) است، به خاطر نخستین کلیپ HDR آن. در «ویرایش» می‌توانید آن را برگردانید.",
"studio.track": "ترک {0}",
"studio.undo": "واگرد",
"sysinfo.application": "برنامه",
diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.json
index 62da25db..67bb2b3a 100644
--- a/src/crates/concat/locales/fr.json
+++ b/src/crates/concat/locales/fr.json
@@ -814,6 +814,7 @@
"previewPane.play": "Lecture",
"previewPane.previousFrame": "Image précédente",
"previewPane.quarter": "Quart",
+ "project.hdrMonitorNote": "Le moniteur affiche une timeline HDR ramenée en SDR, en attendant l'aperçu HDR.",
"project.output": "Sortie · {0}",
"project.project": "Projet",
"relink.dismiss": "Ignorer",
@@ -1005,6 +1006,7 @@
"studio.splitAtPlayhead": "Couper à la tête de lecture",
"studio.stereo": "stereo",
"studio.textToSpeech": "Synthèse vocale…",
+ "studio.timelineNowHdr": "{0} est maintenant en HDR (HLG), pour son premier clip HDR. Modifier permet de revenir en arrière.",
"studio.track": "Track {0}",
"studio.undo": "Annuler",
"sysinfo.application": "Application",
diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.json
index aad94590..3f8fe6e3 100644
--- a/src/crates/concat/locales/hr.json
+++ b/src/crates/concat/locales/hr.json
@@ -814,6 +814,7 @@
"previewPane.play": "Reprodukcija",
"previewPane.previousFrame": "Prethodna sličica",
"previewPane.quarter": "Četvrtina",
+ "project.hdrMonitorNote": "Monitor prikazuje HDR vremensku crtu mapiranu u SDR, dok ne stigne HDR pregled.",
"project.output": "Izlaz · {0}",
"project.project": "Projekt",
"relink.dismiss": "Odbaci",
@@ -1005,6 +1006,7 @@
"studio.splitAtPlayhead": "Podijeli na playheadu",
"studio.stereo": "stereo",
"studio.textToSpeech": "Tekst u govor…",
+ "studio.timelineNowHdr": "{0} je sada HDR (HLG), zbog prvog HDR isječka. U Izmijeni ga možete vratiti.",
"studio.track": "Traka {0}",
"studio.undo": "Poništi",
"sysinfo.application": "Aplikacija",
diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.json
index e3ca2a1d..ec641ec0 100644
--- a/src/crates/concat/locales/it.json
+++ b/src/crates/concat/locales/it.json
@@ -814,6 +814,7 @@
"previewPane.play": "Riproduci",
"previewPane.previousFrame": "Fotogramma precedente",
"previewPane.quarter": "Un quarto",
+ "project.hdrMonitorNote": "Il monitor mostra una timeline HDR convertita in SDR, finché non arriva l'anteprima HDR.",
"project.output": "Uscita · {0}",
"project.project": "Progetto",
"relink.dismiss": "Scarta",
@@ -1005,6 +1006,7 @@
"studio.splitAtPlayhead": "Dividi alla testina",
"studio.stereo": "stereo",
"studio.textToSpeech": "Sintesi vocale…",
+ "studio.timelineNowHdr": "{0} ora è HDR (HLG), per la sua prima clip HDR. Da Modifica puoi tornare indietro.",
"studio.track": "Track {0}",
"studio.undo": "Annulla",
"sysinfo.application": "Applicazione",
diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.json
index 5d99ac54..f1c45b83 100644
--- a/src/crates/concat/locales/ja.json
+++ b/src/crates/concat/locales/ja.json
@@ -814,6 +814,7 @@
"previewPane.play": "再生",
"previewPane.previousFrame": "前のフレーム",
"previewPane.quarter": "1/4",
+ "project.hdrMonitorNote": "HDR プレビューに対応するまで、モニターは HDR タイムラインを SDR にトーンマッピングして表示します。",
"project.output": "出力 · {0}",
"project.project": "プロジェクト",
"relink.dismiss": "閉じる",
@@ -1005,6 +1006,7 @@
"studio.splitAtPlayhead": "再生ヘッドで分割",
"studio.stereo": "stereo",
"studio.textToSpeech": "テキスト読み上げ…",
+ "studio.timelineNowHdr": "最初の HDR クリップが入ったため、{0} は HDR (HLG) になりました。「変更」で元に戻せます。",
"studio.track": "Track {0}",
"studio.undo": "取り消す",
"sysinfo.application": "アプリケーション",
diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.json
index cda62d51..8225833b 100644
--- a/src/crates/concat/locales/ko.json
+++ b/src/crates/concat/locales/ko.json
@@ -814,6 +814,7 @@
"previewPane.play": "재생",
"previewPane.previousFrame": "이전 프레임",
"previewPane.quarter": "1/4",
+ "project.hdrMonitorNote": "HDR 미리보기가 나오기 전까지 모니터는 HDR 타임라인을 SDR로 톤 매핑해 보여 줍니다.",
"project.output": "출력 · {0}",
"project.project": "프로젝트",
"relink.dismiss": "닫기",
@@ -1005,6 +1006,7 @@
"studio.splitAtPlayhead": "재생 헤드에서 나누기",
"studio.stereo": "stereo",
"studio.textToSpeech": "텍스트 음성 변환…",
+ "studio.timelineNowHdr": "첫 HDR 클립이 들어와 {0}이(가) 이제 HDR (HLG)입니다. 수정에서 되돌릴 수 있습니다.",
"studio.track": "Track {0}",
"studio.undo": "실행 취소",
"sysinfo.application": "응용 프로그램",
diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.json
index 2b9fb4e6..ea2f5873 100644
--- a/src/crates/concat/locales/pt-BR.json
+++ b/src/crates/concat/locales/pt-BR.json
@@ -814,6 +814,7 @@
"previewPane.play": "Reproduzir",
"previewPane.previousFrame": "Quadro anterior",
"previewPane.quarter": "Um quarto",
+ "project.hdrMonitorNote": "O monitor mostra uma linha do tempo HDR convertida para SDR até chegar a prévia em HDR.",
"project.output": "Saída · {0}",
"project.project": "Projeto",
"relink.dismiss": "Descartar",
@@ -1005,6 +1006,7 @@
"studio.splitAtPlayhead": "Dividir no cursor",
"studio.stereo": "stereo",
"studio.textToSpeech": "Texto para fala…",
+ "studio.timelineNowHdr": "{0} agora é HDR (HLG), por causa do primeiro clipe HDR. Em Modificar dá para voltar.",
"studio.track": "Track {0}",
"studio.undo": "Desfazer",
"sysinfo.application": "Aplicativo",
diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.json
index ff197263..d1d9a72d 100644
--- a/src/crates/concat/locales/ru.json
+++ b/src/crates/concat/locales/ru.json
@@ -814,6 +814,7 @@
"previewPane.play": "Воспроизвести",
"previewPane.previousFrame": "Предыдущий кадр",
"previewPane.quarter": "Четверть",
+ "project.hdrMonitorNote": "Пока нет HDR-просмотра, монитор показывает HDR-таймлайн, приведённый к SDR.",
"project.output": "Вывод · {0}",
"project.project": "Проект",
"relink.dismiss": "Закрыть",
@@ -1005,6 +1006,7 @@
"studio.splitAtPlayhead": "Разрезать по курсору",
"studio.stereo": "стерео",
"studio.textToSpeech": "Озвучивание текста…",
+ "studio.timelineNowHdr": "{0} теперь HDR (HLG) — из-за первого HDR-клипа. Вернуть можно в «Изменить».",
"studio.track": "Дорожка {0}",
"studio.undo": "Отменить",
"sysinfo.application": "Приложение",
diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.json
index f6f941e4..f4a6575c 100644
--- a/src/crates/concat/locales/tr.json
+++ b/src/crates/concat/locales/tr.json
@@ -814,6 +814,7 @@
"previewPane.play": "Oynat",
"previewPane.previousFrame": "Önceki kare",
"previewPane.quarter": "Çeyrek",
+ "project.hdrMonitorNote": "HDR önizleme gelene kadar monitör, HDR zaman çizelgesini SDR'ye ton eşlemeli gösterir.",
"project.output": "Çıkış · {0}",
"project.project": "Proje",
"relink.dismiss": "Kapat",
@@ -1005,6 +1006,7 @@
"studio.splitAtPlayhead": "Oynatma imlecinde böl",
"studio.stereo": "stereo",
"studio.textToSpeech": "Metinden konuşma…",
+ "studio.timelineNowHdr": "{0} ilk HDR klibi nedeniyle artık HDR (HLG). Değiştir'den geri alabilirsiniz.",
"studio.track": "Track {0}",
"studio.undo": "Geri al",
"sysinfo.application": "Uygulama",
diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.json
index 6369cb76..fbc2b51f 100644
--- a/src/crates/concat/locales/zh-Hans.json
+++ b/src/crates/concat/locales/zh-Hans.json
@@ -814,6 +814,7 @@
"previewPane.play": "播放",
"previewPane.previousFrame": "上一帧",
"previewPane.quarter": "四分之一",
+ "project.hdrMonitorNote": "在支持 HDR 预览之前,监视器会把 HDR 时间线色调映射为 SDR 显示。",
"project.output": "输出 · {0}",
"project.project": "项目",
"relink.dismiss": "忽略",
@@ -1005,6 +1006,7 @@
"studio.splitAtPlayhead": "在播放头处分割",
"studio.stereo": "立体声",
"studio.textToSpeech": "文字转语音…",
+ "studio.timelineNowHdr": "{0} 因加入第一个 HDR 片段,现在是 HDR (HLG)。可在“修改”中改回。",
"studio.track": "轨道 {0}",
"studio.undo": "撤销",
"sysinfo.application": "应用程序",
diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.json
index 2708e8b5..2bc8b8d4 100644
--- a/src/crates/concat/locales/zh-TW.json
+++ b/src/crates/concat/locales/zh-TW.json
@@ -814,6 +814,7 @@
"previewPane.play": "播放",
"previewPane.previousFrame": "上一個影格",
"previewPane.quarter": "四分之一",
+ "project.hdrMonitorNote": "在支援 HDR 預覽之前,監看器會把 HDR 時間軸色調映射為 SDR 顯示。",
"project.output": "輸出 · {0}",
"project.project": "專案",
"relink.dismiss": "忽略",
@@ -1005,6 +1006,7 @@
"studio.splitAtPlayhead": "在播放磁頭處分割",
"studio.stereo": "立體聲",
"studio.textToSpeech": "文字轉語音…",
+ "studio.timelineNowHdr": "{0} 因加入第一個 HDR 片段,現在是 HDR (HLG)。可在「修改」中改回。",
"studio.track": "軌道 {0}",
"studio.undo": "復原",
"sysinfo.application": "應用程式",
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rs
index e44c75c2..2a717383 100644
--- a/src/crates/concat/src/lib.rs
+++ b/src/crates/concat/src/lib.rs
@@ -1166,6 +1166,9 @@ pub fn run() -> Result<(), slint::PlatformError> {
app.on_project_rate_changed(on_window!(|state, index: i32| {
state.handle(Msg::Project(ProjectMsg::RateChanged(index)));
}));
+ app.on_project_color_space_changed(on_window!(|state, index: i32| {
+ state.handle(Msg::Project(ProjectMsg::ColorSpaceChanged(index)));
+ }));
app.on_project_custom_width_edited(on_window!(|state, width: f32| {
state.handle(Msg::Project(ProjectMsg::CustomWidth(width)));
}));
diff --git a/src/crates/concat/src/panes/project.rs b/src/crates/concat/src/panes/project.rs
index 99cd5c70..0a43d2ee 100644
--- a/src/crates/concat/src/panes/project.rs
+++ b/src/crates/concat/src/panes/project.rs
@@ -4,6 +4,7 @@
//! The project sheet: the Details panel's Modify button, as a form.
use concat_project::Command;
+use concat_project::model::ColorSpace;
use slint::SharedString;
use crate::studio::{OUTPUTS, RATES, Studio, custom_frame, custom_rate, fps_of};
@@ -22,6 +23,8 @@ pub enum ProjectMsg {
CustomWidth(f32),
CustomHeight(f32),
CustomFps(f32),
+ /// A row of the colour list: SDR, HDR HLG, HDR PQ.
+ ColorSpaceChanged(i32),
Apply,
}
@@ -38,8 +41,13 @@ pub struct ProjectPane {
pub custom_size: (u32, u32),
/// The custom rate, as the exact fraction.
pub custom_rate: (i64, i64),
+ /// What the timeline is output in.
+ pub color_space: ColorSpace,
}
+/// The colour list's rows, in the sheet's order.
+const COLOR_SPACES: [ColorSpace; 3] = [ColorSpace::Sdr, ColorSpace::Hlg, ColorSpace::Pq];
+
impl ProjectPane {
/// Applies one message. The studio is the rest of the window; while
/// this runs the studio's copy of the pane is a blank it must not read.
@@ -67,6 +75,7 @@ impl ProjectPane {
.unwrap_or(RATES.len()),
custom_size: (width, height),
custom_rate: (num, den),
+ color_space: video.color_space,
};
}
ProjectMsg::Close => self.open = false,
@@ -92,13 +101,17 @@ impl ProjectPane {
self.custom_size = custom_frame(self.custom_size.0 as f32, height);
}
ProjectMsg::CustomFps(fps) => self.custom_rate = custom_rate(f64::from(fps)),
+ ProjectMsg::ColorSpaceChanged(index) => {
+ self.color_space =
+ COLOR_SPACES[(index.max(0) as usize).min(COLOR_SPACES.len() - 1)];
+ }
ProjectMsg::Apply => self.apply(studio),
}
}
- /// Applies the sheet and closes it. The name is the project's; the frame
- /// and the rate are the active timeline's, and go as one edit so an undo
- /// takes both back together. The frame goes the way the monitor's picker
+ /// Applies the sheet and closes it. The name is the project's; the
+ /// frame, the rate and the colour are the active timeline's, and go as
+ /// one edit so an undo takes them back together. The frame goes the way the monitor's picker
/// sends it, so the two cannot disagree about what a size means.
fn apply(&mut self, studio: &mut Studio) {
let sheet = std::mem::take(self);
@@ -113,6 +126,7 @@ impl ProjectPane {
video.height = height;
video.rate_num = num;
video.rate_den = den;
+ video.color_space = sheet.color_space;
session.prepare_save((!name.is_empty()).then_some(name.as_str()));
if !name.is_empty() {
studio.project_name = name;
@@ -159,6 +173,10 @@ impl ProjectPane {
custom_height: height as f32,
custom_fps: fps_of(num, den) as f32,
rate_readout: format!("{num}/{den}").into(),
+ color_space: COLOR_SPACES
+ .iter()
+ .position(|space| *space == self.color_space)
+ .unwrap_or(0) as i32,
}
}
}
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index 0322599c..89d8b7b0 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -1928,9 +1928,15 @@ impl Studio {
// commit path sets `last_commit` again right after calling here.
self.last_commit = None;
let session = self.session.as_mut()?;
+ let chosen = matches!(command, Command::SetTimelineVideo { .. });
+ let before = session.video().color_space;
match session.apply(command) {
Ok(view) => {
+ let after = session.video().color_space;
self.after_change();
+ if !chosen {
+ self.tell_of_hdr(before, after);
+ }
view.created_id
}
Err(error) => {
@@ -1948,12 +1954,27 @@ impl Studio {
let Some(session) = self.session.as_mut() else {
return;
};
+ let before = session.video().color_space;
match session.apply_within(Some(gesture), command) {
- Ok(_) => self.after_change(),
+ Ok(_) => {
+ let after = session.video().color_space;
+ self.after_change();
+ self.tell_of_hdr(before, after);
+ }
Err(error) => self.notify(&error, true),
}
}
+ /// Says so when an edit turned the active timeline HDR - its first HDR
+ /// clip, which the editor follows (see `Editor::follow_first_hdr`) - so
+ /// the change is never a surprise, and says where it is set back.
+ fn tell_of_hdr(&mut self, before: model::ColorSpace, after: model::ColorSpace) {
+ if before.is_sdr() && after.is_hdr() {
+ let name = self.timeline().name.clone();
+ self.notify(&tf("studio.timelineNowHdr", &[&name]), false);
+ }
+ }
+
/// The bookkeeping every change to the edit needs: the caches that
/// follow the document, the autosave, the monitor and the mix.
fn after_change(&mut self) {
diff --git a/src/crates/concat/ui/app.slint b/src/crates/concat/ui/app.slint
index ecf72261..99b4be6b 100644
--- a/src/crates/concat/ui/app.slint
+++ b/src/crates/concat/ui/app.slint
@@ -250,6 +250,7 @@ export component App inherits Window {
callback project-custom-width-edited(width: float);
callback project-custom-height-edited(height: float);
callback project-custom-fps-edited(fps: float);
+ callback project-color-space-changed(index: int);
callback project-apply();
/// The two speech sheets: captions from a clip's sound, and a title's
@@ -619,6 +620,7 @@ export component App inherits Window {
custom-width-edited(width) => { root.project-custom-width-edited(width); }
custom-height-edited(height) => { root.project-custom-height-edited(height); }
custom-fps-edited(fps) => { root.project-custom-fps-edited(fps); }
+ color-space-changed(index) => { root.project-color-space-changed(index); }
apply => { root.project-apply(); }
}
diff --git a/src/crates/concat/ui/dialogs/project.slint b/src/crates/concat/ui/dialogs/project.slint
index 664afe9d..8a36ebac 100644
--- a/src/crates/concat/ui/dialogs/project.slint
+++ b/src/crates/concat/ui/dialogs/project.slint
@@ -10,8 +10,8 @@ import { NumberField } from "../primitives/number-field.slint";
// The project sheet: what the Details panel's Modify button opens.
//
-// Three facts a project is made of - its name, its frame and its rate - on
-// one short form, applied together. The folder is stated and not editable:
+// The facts a project is made of - its name, and its timeline's frame, rate
+// and colour - on one short form, applied together. The folder is stated and not editable:
// a project is its folder, and moving one is a job for the file manager.
export struct ProjectSheetData {
@@ -32,6 +32,8 @@ export struct ProjectSheetData {
custom-fps: float,
/// The rate as the fraction it is kept as: "24000/1001".
rate-readout: string,
+ /// Row in the colour list: SDR, HDR HLG, HDR PQ.
+ color-space: int,
}
export component ProjectDialog inherits Modal {
@@ -43,6 +45,7 @@ export component ProjectDialog inherits Modal {
callback custom-width-edited(width: float);
callback custom-height-edited(height: float);
callback custom-fps-edited(fps: float);
+ callback color-space-changed(index: int);
callback apply();
open: root.data.open;
@@ -161,6 +164,25 @@ export component ProjectDialog inherits Modal {
}
}
}
+
+ // What the timeline is output in. A timeline turns HDR (HLG) on
+ // its first HDR clip; this is where it is set back, or to PQ.
+ DialogRow {
+ label: I18n.t("common.color");
+ Select {
+ current: root.data.color-space;
+ options: ["SDR", "HDR (HLG)", "HDR (PQ)"];
+ details: ["Rec. 709", "Rec. 2020", "Rec. 2020"];
+ changed(index) => { root.color-space-changed(index); }
+ }
+ }
+
+ if root.data.color-space > 0: Text {
+ text: I18n.t("project.hdrMonitorNote");
+ color: Theme.fg-dim;
+ font-size: Theme.fs-sm;
+ wrap: word-wrap;
+ }
}
Rectangle {