NLE composition inconsistent duration
Rodrigo Santos
rsantos at sequence.film
Tue Oct 11 14:53:18 UTC 2022
Hi,
I have the following code in Rust that creates a nlecomposition and adds to it two nleurisource elements. The duration of both sources is set to 10s, and the start of the second source is set to 10s. The output is being stored in a file.
My expectation is that the video file would have a total of 20s of duration, but its actual duration is 33s: the first video has a duration of 22s while the second video has 11s of duration. Is this a bug or am I missing something?
The weird thing is if I don't change the uri when I create the second source (both sources having the same value for the uri property) the resulting video file will have 20s of duration as expected (each video plays for 10s).
fn add_to_bin(bin: &Element, element: &Element) {
let bin = bin.dynamic_cast_ref::<Bin>().unwrap();
bin.add_many(&[element]).unwrap();
}
fn create_nle_src (uri: &str, start: u64, inpoint: u64, duration: i64, priority: u32) -> Element {
let nlesource = ElementFactory::make("nleurisource", None).unwrap();
nlesource.set_property("uri", uri);
nlesource.set_property("start", start);
nlesource.set_property("inpoint", inpoint);
nlesource.set_property("duration", duration);
nlesource.set_property("priority", priority);
nlesource
}
fn main() {
<....>
let comp = ElementFactory::make("nlecomposition", Some("test-composition")).unwrap();
let caps = "video/x-raw(ANY)";
let caps = Caps::from_str(caps).expect("Could not create caps from str");
comp.set_property("caps", caps);
let uri = "file:///C:/Users/rodsantos/Downloads/video.mp4"; //big buck bunny video
let inpoint = ClockTime::from_seconds(0).nseconds();
let duration: i64 = ClockTime::from_seconds(10).nseconds().try_into().expect("Cast failed");
let mut start: u64 = 0;
let nlesource= create_nle_src(uri, start, inpoint, duration, 1);
add_to_bin(&comp, &nlesource);
start += duration as u64;
let uri = "file:///C:/Users/rodsantos/Downloads/sintel_trailer-480p.webm"; //sintel trailer video
let duration: i64 = ClockTime::from_seconds(10).nseconds().try_into().expect("Cast failed");
let nlesource = create_nle_src(uri, start, inpoint, duration, 1);
add_to_bin(&comp, &nlesource);
comp.emit_by_name::<bool>("commit", &[&true]);
let videoconvert = ElementFactory::make("videoconvert", None).unwrap();
let compositor = ElementFactory::make("compositor", None).unwrap();
let encoder = ElementFactory::make("x264enc", None).unwrap();
let mux = ElementFactory::make("avimux", None).unwrap();
let filesink = ElementFactory::make("filesink", None).unwrap();
let pipeline = Pipeline::new(None);
pipeline.add_many(&[
&comp,
&videoconvert,
&compositor,
&encoder,
&mux,
&filesink,
]).unwrap();
Element::link_many(&[
&comp,
&videoconvert,
&compositor,
&encoder,
&mux,
&filesink
]).unwrap();
filesink.set_property("location", "test.avi");
pipeline.set_state(State::Playing).expect("Could not set pipeline to Playing state");
<....>
}
Rodrigo Santos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20221011/0177ed59/attachment.htm>
More information about the gstreamer-devel
mailing list