Upload stream with SCTE markers without transcoding

This commit is contained in:
Rafael Caricio 2022-04-18 00:20:10 +02:00
parent cddaba3478
commit 455637af2a
Signed by: rafaelcaricio
GPG key ID: 3C86DBCE8E93C947
4 changed files with 9 additions and 10 deletions

2
.gitignore vendored
View file

@ -1,2 +1,4 @@
*.srt *.srt
*.mp4 *.mp4
*.dot
*.png

2
Cargo.lock generated
View file

@ -377,6 +377,7 @@ dependencies = [
[[package]] [[package]]
name = "gst-plugin-version-helper" name = "gst-plugin-version-helper"
version = "0.9.0" version = "0.9.0"
source = "git+https://gitlab.freedesktop.org/rafaelcaricio/gst-plugins-rs.git?branch=add-imgcmp#490f1ac8c9014af0e968f2ecd50d4430ab34fa11"
dependencies = [ dependencies = [
"chrono", "chrono",
] ]
@ -384,6 +385,7 @@ dependencies = [
[[package]] [[package]]
name = "gst-plugin-videofx" name = "gst-plugin-videofx"
version = "0.9.0" version = "0.9.0"
source = "git+https://gitlab.freedesktop.org/rafaelcaricio/gst-plugins-rs.git?branch=add-imgcmp#490f1ac8c9014af0e968f2ecd50d4430ab34fa11"
dependencies = [ dependencies = [
"atomic_refcell", "atomic_refcell",
"cairo-rs", "cairo-rs",

View file

@ -8,7 +8,7 @@ eyre = "0.6.6"
glib = { git = "https://github.com/gtk-rs/gtk-rs-core" } 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 = { 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-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" ctrlc = "3.2.1"
signal-hook = "0.3.13" signal-hook = "0.3.13"
#tokio = { version = "1.17", features = ["full"] } #tokio = { version = "1.17", features = ["full"] }

View file

@ -3,7 +3,6 @@ use gst::prelude::*;
use log::{debug, info}; use log::{debug, info};
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
use std::process;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::time::Duration; 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<Mutex<u32>>); pub struct EventId(Arc<Mutex<u32>>);
impl EventId { impl EventId {
pub fn new() -> Self {
Self(Arc::new(Mutex::new(0)))
}
pub fn next(&self) -> u32 { pub fn next(&self) -> u32 {
let mut counter = self.0.lock().unwrap(); let mut counter = self.0.lock().unwrap();
*counter += 1; *counter += 1;
@ -62,13 +57,13 @@ fn main() -> eyre::Result<()> {
gst_mpegts::gst_mpegts_initialize(); 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( let pipeline = gst::parse_launch(
r#" r#"
urisourcebin uri=https://plutolive-msl.akamaized.net/hls/live/2008623/defy/master.m3u8 ! tsdemux name=demux ! queue ! h264parse ! tee name=v 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 v. ! queue ! decodebin ! videoconvert ! imgcmp name=imgcmp location=/Users/rafaelcaricio/Downloads/defy-AD-SLATE-APRIL3022.jpeg ! autovideosink
demux. ! queue ! aacparse ! mux. demux. ! queue ! aacparse ! mux.
@ -86,7 +81,7 @@ fn main() -> eyre::Result<()> {
let bus = pipeline.bus().unwrap(); let bus = pipeline.bus().unwrap();
bus.add_watch({ bus.add_watch({
let event_counter = EventId::new(); let event_counter = EventId::default();
let ad_running = Arc::new(AtomicBool::new(false)); let ad_running = Arc::new(AtomicBool::new(false));
let main_loop = main_loop.clone(); let main_loop = main_loop.clone();
let pipeline_weak = pipeline.downgrade(); let pipeline_weak = pipeline.downgrade();