Skip to content

copy_raw mode for bypassing fragmented mp4 creation#151

Merged
lukseven merged 10 commits intodev-live-feedsfrom
luk/bypass-processor
Feb 16, 2026
Merged

copy_raw mode for bypassing fragmented mp4 creation#151
lukseven merged 10 commits intodev-live-feedsfrom
luk/bypass-processor

Conversation

@lukseven
Copy link
Copy Markdown
Contributor

This pull request introduces a new "bypass" processing mode for MPEGTS streams, allowing AVPipe to copy streams directly into parts without using ffmpeg/libav. The most significant changes include the implementation of the BypassProcessor interface and its integration into the AVPipe initialization and run/cancel flows, modifications to reporting and stats handling for MPEGTS streams, and improvements to the NetReader's cancellation and recovery logic.

The use of the bypass processor is configurable per live stream, and enabled by setting /live_recording/recording_config/recording_params/xc_params/input_cfg/copy_mode=raw_only

Bypass processing and integration:

  • Added the BypassProcessor interface and implemented it in broadcastproto/mpegts/bypass.go, enabling direct stream copying when CopyModeRawOnly is selected. This processor is managed with negative handles to distinguish it from regular ffmpeg-based processors. [1] [2] [3]
  • Integrated bypass processor creation and lifecycle management into XcInit, XcRun, and XcCancel in avpipe.go, including handle assignment, processor startup, cancellation, and cleanup. [1] [2] [3] [4]

MPEGTS stats and reporting enhancements:

  • Introduced ReportStart method to SequentialOpener and MpegtsPacketProcessor, allowing reporting when the first packet is received. This is triggered via a new onFirstPacket callback in MpegTsConsumer. [1] [2] [3] [4] [5]
  • Added AV_IN_STAT_MPEGTS_START stat type and corresponding string name for improved event tracking. [1] [2]

NetReader improvements:

  • Enhanced cancellation logic in NetReader to close the underlying reader safely and to handle context cancellation during connection attempts. [1] [2] [3] [4]
  • Modified recovery logic to always treat errors as recoverable, and expanded test coverage for cancellation scenarios. [1] [2]

Configuration and global management:

  • Extended CopyMode with CopyModeRawOnly and clarified InputConfig handling for processor selection. [1] [2]
  • Added global management functions for bypass processors: initialization, retrieval, and deletion. [1] [2]

[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22]

* use bypass processor if `raw_only` is specified on the stream independent of the `bypass_libav_reader` setting
* ensure BypassProcessor.Status/Cancel/Wait don't panic if called before Start()
* ensure net reader is canceled even if blocked on reading from network (by closing the socket)
* comment typo
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new MPEGTS “bypass” mode (copy_mode=raw_only) that copies incoming MPEGTS directly into parts without invoking ffmpeg/libav, along with related lifecycle wiring, stats/reporting updates, and NetReader cancellation improvements.

Changes:

  • Introduces a BypassProcessor abstraction and an MPEGTS implementation to copy streams directly to segmented outputs.
  • Integrates bypass initialization/run/cancel into XcInit/XcRun/XcCancel using negative handles.
  • Adds “first packet received” reporting (AV_IN_STAT_MPEGTS_START) and improves NetReader cancellation behavior and tests.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
goavpipe/structs.go Adds CopyModeRawOnly, new stat type, JSON tags/default tweaks for input processor config.
goavpipe/handlers.go Adds BypassProcessor interface and global bypass-processor handle management.
broadcastproto/mpegts/bypass.go New bypass processor implementation built on NetReader + MPEGTS packet processing.
broadcastproto/mpegts/netreader.go Improves cancellation by tracking/closing the active reader and honoring ctx cancellation in connect loop.
broadcastproto/mpegts/netreader_test.go Adds a cancellation test scenario with no incoming packets.
broadcastproto/mpegts/mpegts.go Adds ReportStart() plumbing and logs fd with stats output.
broadcastproto/mpegts/custom.go Adds onFirstPacket callback to trigger start reporting on first packet.
avpipe_seq_writer.go Implements ReportStart() for sequential MPEGTS output handler.
avpipe.go Adds bypass mode selection in XcInit and bypass execution/cancel paths in XcRun/XcCancel; refactors AVPipeOpenInput via AVPipeOpenInputGo.
go.mod Adds github.com/gammazero/deque as an indirect dependency.
go.sum Adds checksums for github.com/gammazero/deque.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread avpipe.go
Comment thread avpipe.go
Comment thread goavpipe/structs.go
Comment thread broadcastproto/mpegts/bypass.go
@jslching jslching deleted the branch dev-live-feeds February 11, 2026 20:19
@jslching jslching closed this Feb 11, 2026
@jslching
Copy link
Copy Markdown
Contributor

Tried to fix misspelled branch name...

@jslching jslching reopened this Feb 11, 2026
@jslching jslching changed the base branch from dev-live-feeeds to dev-live-feeds February 11, 2026 20:22
@lukseven lukseven marked this pull request as ready for review February 16, 2026 17:37
@lukseven lukseven changed the title Luk/bypass processor copy_raw mode for bypassing fragmented mp4 creation Feb 16, 2026
@lukseven lukseven merged commit 25170d3 into dev-live-feeds Feb 16, 2026
@lukseven lukseven deleted the luk/bypass-processor branch February 16, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants