From 455637af2ac61d18c3effa4987076ffd1fc500c6 Mon Sep 17 00:00:00 2001 From: Rafael Caricio Date: Mon, 18 Apr 2022 00:20:10 +0200 Subject: [PATCH] Upload stream with SCTE markers without transcoding --- .gitignore | 2 ++ Cargo.lock | 2 ++ Cargo.toml | 2 +- src/main.rs | 13 ++++--------- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 12adb15..5e9d520 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.srt *.mp4 +*.dot +*.png diff --git a/Cargo.lock b/Cargo.lock index acad895..574ff62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -377,6 +377,7 @@ dependencies = [ [[package]] name = "gst-plugin-version-helper" version = "0.9.0" +source = "git+https://gitlab.freedesktop.org/rafaelcaricio/gst-plugins-rs.git?branch=add-imgcmp#490f1ac8c9014af0e968f2ecd50d4430ab34fa11" dependencies = [ "chrono", ] @@ -384,6 +385,7 @@ dependencies = [ [[package]] name = "gst-plugin-videofx" version = "0.9.0" +source = "git+https://gitlab.freedesktop.org/rafaelcaricio/gst-plugins-rs.git?branch=add-imgcmp#490f1ac8c9014af0e968f2ecd50d4430ab34fa11" dependencies = [ "atomic_refcell", "cairo-rs", diff --git a/Cargo.toml b/Cargo.toml index cc48619..22a25f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ eyre = "0.6.6" glib = { git = "https://github.com/gtk-rs/gtk-rs-core" } gst = { package = "gstreamer", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features = ["v1_20"] } gst-mpegts = { package = "gstreamer-mpegts-sys", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features = ["v1_20"] } -gst-plugin-videofx = { path = "../gst-plugins-rs/video/videofx" } +gst-plugin-videofx = { git = "https://gitlab.freedesktop.org/rafaelcaricio/gst-plugins-rs.git", branch = "add-imgcmp" } ctrlc = "3.2.1" signal-hook = "0.3.13" #tokio = { version = "1.17", features = ["full"] } diff --git a/src/main.rs b/src/main.rs index 04717c7..48a2e95 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,6 @@ use gst::prelude::*; use log::{debug, info}; use std::fs::File; use std::io::Write; -use std::process; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; use std::time::Duration; @@ -39,14 +38,10 @@ fn send_splice_out(element: &gst::Element, event_id: u32, time: gst::ClockTime) }) } -#[derive(Clone)] +#[derive(Clone, Default)] pub struct EventId(Arc>); impl EventId { - pub fn new() -> Self { - Self(Arc::new(Mutex::new(0))) - } - pub fn next(&self) -> u32 { let mut counter = self.0.lock().unwrap(); *counter += 1; @@ -62,13 +57,13 @@ fn main() -> eyre::Result<()> { gst_mpegts::gst_mpegts_initialize(); } - // ! rtpmp2tpay ! udpsink sync=true host=184.73.103.62 port=5000 + // ! filesink sync=true location=video.ts let pipeline = gst::parse_launch( r#" urisourcebin uri=https://plutolive-msl.akamaized.net/hls/live/2008623/defy/master.m3u8 ! tsdemux name=demux ! queue ! h264parse ! tee name=v - v. ! queue ! mpegtsmux name=mux scte-35-pid=500 scte-35-null-interval=450000 ! filesink sync=true location=video.ts + v. ! queue ! mpegtsmux name=mux scte-35-pid=500 scte-35-null-interval=450000 ! rtpmp2tpay ! udpsink sync=true host=54.225.215.79 port=5000 v. ! queue ! decodebin ! videoconvert ! imgcmp name=imgcmp location=/Users/rafaelcaricio/Downloads/defy-AD-SLATE-APRIL3022.jpeg ! autovideosink demux. ! queue ! aacparse ! mux. @@ -86,7 +81,7 @@ fn main() -> eyre::Result<()> { let bus = pipeline.bus().unwrap(); bus.add_watch({ - let event_counter = EventId::new(); + let event_counter = EventId::default(); let ad_running = Arc::new(AtomicBool::new(false)); let main_loop = main_loop.clone(); let pipeline_weak = pipeline.downgrade();