Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

layers LA5: `raea export xml` imports into Premiere Pro and DaVinci Resolve as raea rendered it, stereo kept

Zachary Guglin1caad9f02485
diff --git a/apps/layers/src/tests.rs b/apps/layers/src/tests.rs
index 58f6b792..365061e6 100644
--- a/apps/layers/src/tests.rs
+++ b/apps/layers/src/tests.rs
@@ -183,6 +183,10 @@ fn the_xml_has_the_tracks_bottom_first_and_footage_linked_to_its_sound() {
// the file's sound as its two channels, left and right; the two tracks to output channels 1 and 2
assert!(x.contains("<channelcount>1</channelcount><layout>stereo</layout><audiochannel><sourcechannel>2</sourcechannel><channellabel>right</channellabel></audiochannel>"));
assert!(x.contains("<outputchannelindex>1</outputchannelindex></track>") && x.contains("<outputchannelindex>2</outputchannelindex></track>"));
+ // each channel panned to its own side by an Audio Pan on the clip, as Resolve writes it; nothing on the track
+ assert!(!x.contains("PannerCurrentValue"), "{x}");
+ assert!(x.contains("<effectid>audiopan</effectid><effectcategory>audiopan</effectcategory><effecttype>audiopan</effecttype><mediatype>audio</mediatype><parameter><parameterid>pan</parameterid><name>Pan</name><valuemin>-1</valuemin><valuemax>1</valuemax><value>-1</value>"), "{x}");
+ assert_eq!(x.matches("<parameterid>pan</parameterid>").count(), 4, "two stereo clips, two channels each");
// the music at -12 dB as Audio Levels' linear gain
assert!(x.contains("<parameterid>level</parameterid><name>Level</name><valuemin>0.00003162</valuemin><valuemax>31.6228</valuemax><value>0.251189</value>"), "{x}");
}
diff --git a/apps/layers/src/xml.rs b/apps/layers/src/xml.rs
index c30b1bda..c69c632b 100644
--- a/apps/layers/src/xml.rs
+++ b/apps/layers/src/xml.rs
@@ -4,7 +4,9 @@
//! captions), its audio tracks below. Footage points at its file where it is, placed as raea drew it (Basic Motion's
//! scale and centre, a Crop where object-fit: cover cuts it, its Opacity); a footage clip and its own sound are linked
//! clipitems, which Premiere's Unlink and Resolve's Link Clips separate. Sound is laid out as Premiere writes it (read
-//! from an XML Premiere Pro 2026 exported): a stereo file's channels each a mono clipitem on a track of its own. A layer's movie fills the frame, its alpha
+//! from an XML Premiere Pro 2026 exported): a stereo file's channels each a mono clipitem on a track of its own, each
+//! panned to its side by an Audio Pan on the clip, as Resolve and FCP7 write it (both editors import a channel centred
+//! without it; Premiere's own track pan, PannerCurrentValue, was tried and neither read it). A layer's movie fills the frame, its alpha
//! straight. Pure: the export (lib.rs) makes the layers and writes this beside them.
use std::fmt::Write as _;
@@ -221,7 +223,9 @@ pub fn write(l: &Layers, dir: &Path) -> (String, Vec<String>) {
let mut a = String::new();
for (ti, m) in mono.iter().enumerate() {
// a stereo pair's left track goes to output channel 1, its right to 2
- let out = if mono.get(ti + 1).is_some_and(|n| n.iter().any(|(_, _, ch)| *ch == 2)) || m.iter().any(|(_, _, ch)| *ch == 2) { format!("<outputchannelindex>{}</outputchannelindex>", if m.iter().any(|(_, _, ch)| *ch == 2) { 2 } else { 1 }) } else { String::new() };
+ // which side of a stereo pair the track is: 1 left, 2 right; none for a mono file's own track
+ let side = if m.iter().any(|(_, _, ch)| *ch == 2) { Some(2) } else if mono.get(ti + 1).is_some_and(|n| n.iter().any(|(_, _, ch)| *ch == 2)) { Some(1) } else { None };
+ let out = side.map_or(String::new(), |k| format!("<outputchannelindex>{k}</outputchannelindex>"));
let _ = write!(a, "<track currentExplodedTrackIndex=\"0\" totalExplodedTrackCount=\"1\" premiereTrackType=\"Mono\">");
for (id, c, ch) in m {
let gain = 10f64.powf(c.gain_db / 20.0);
@@ -229,6 +233,12 @@ pub fn write(l: &Layers, dir: &Path) -> (String, Vec<String>) {
if (gain - 1.0).abs() > 1e-6 {
body.push_str(&effect("Audio Levels", "audiolevels", "audiolevels", "audiolevels", "audio", &param("level", "Level", 0.00003162, 31.6228, &format!("{gain:.6}"))));
}
+ // a stereo file's channel panned to its own side, as FCP7's Audio Pan on the clip (-1 left, 1 right): Premiere
+ // and Resolve both import each channel centred without it, and both read it (heard 11-16); a mono file's
+ // stays centred
+ if channels(c) == 2 {
+ body.push_str(&effect("Audio Pan", "audiopan", "audiopan", "audiopan", "audio", &param("pan", "Pan", -1.0, 1.0, if *ch == 1 { "-1" } else { "1" })));
+ }
if *ch == 1 && (c.fade_in > 0.0 || c.fade_out > 0.0) {
notes.push(format!("{} (frames {}-{}): its fades ({:.2} s in, {:.2} s out) aren't carried; set them in the editor", name_of(c.file), c.start, c.end() - 1, c.fade_in, c.fade_out));
}
diff --git a/docs/layers.feature b/docs/layers.feature
index 5b0adcf0..618cae1f 100644
--- a/docs/layers.feature
+++ b/docs/layers.feature
@@ -165,8 +165,16 @@ Feature: A render in layers: captions, graphics, footage and sound apart, for Ca
Motion), at its gain (Audio Levels)
And a video clip and its own sound are linked clipitems, so they move together, and each editor's own control
separates them: in Premiere, Unlink; in Resolve, Link Clips off (Cmd/Ctrl+Shift+L); in CapCut, Extract audio
+ And sound is laid out as Premiere writes it (read from an XML Premiere Pro 26.2.2 exported): the sequence
+ explodedTracks, each stereo file's channels described one by one, each channel a mono clipitem on a track of its
+ own (sourcetrack and outputchannelindex 1 and 2), every clipitem of a clip and the clip it's linked to linked
+ together, a masterclipid each and a timecode on every file. One stereo clipitem on a "Stereo" track, the first
+ layout, imported into Premiere with no sound at all
+ And each channel of a stereo file is panned to its side by an Audio Pan on its clip (-1 left, 1 right), as
+ Resolve and FCP7 write it: without it both editors import the channels centred, and a stereo track plays as
+ mono; Premiere's own track pan (PannerCurrentValue) was tried, and neither editor read it
And a command of an editor's own (`raea export premiere`, `raea export resolve`) is added only where LA5b finds
- that editor reading the XML differently
+ that editor reading the XML differently: none is, on 11-16
Scenario: LA5b. Premiere and Resolve open it as raea rendered it
Given the LA3a fixtures exported
@@ -175,6 +183,17 @@ Feature: A render in layers: captions, graphics, footage and sound apart, for Ca
middle matches the reference render
And which alpha codecs stay transparent in each is recorded here, with the version tested, and the export
uses the first that does
+ And on 11-16, on this Mac, the multi-clip test (three raea-rendered clips A, B and C labelled with their source
+ time, cuts, a re-trim, a picture in picture on a card, four captions, graphics coming and going, footage sound
+ linked and a muted clip, a raea-rendered stereo music track, low note left and high note right): Premiere Pro
+ 26.2.2 and DaVinci Resolve 21.2.0 each import it with every track, clip, source time, placement and caption as
+ raea rendered it, nothing offline, ProRes 4444 transparent, the footage's sound linked (Unlink, Link Clips) and
+ the music stereo, panned left and right on its clips
+
+ Scenario: LA5c. CapCut opens what raea export capcut writes (docs/capcut.feature CC3a)
+ Then on 11-16 CapCut 9.4.4589 listed both tests the export entered in its project list (markers from a draft it
+ made itself) and played them as raea rendered them: the footage's main track, the picture in picture on its
+ card, the overlay and captions tracks transparent (ProRes 4444), the sound and the music
Rule: LA6. raea's timeline is laid out the same way (raea-feed, after LA1)
Scenario: LA6a. A timeline read from the code puts captions on the Captions track