Skip to content

Proposal: WebSocket video streaming with MPEG1 transcoding (support H265) using go-astiav (CGO / FFmpeg) #18

Description

@LongND0105

Hi author,

I’d like to share a feature I’ve recently implemented while working with lkmio/lkm, and ask whether it would be appropriate to contribute it via a Pull Request.

What I’ve implemented

I added a new video streaming path that:

  • Streams video over WebSocket
  • Transcodes the input stream to mpeg1video in real time
  • Pushes the output as MPEG-TS packets to connected WebSocket clients

Technical details

  • The transcoding pipeline is implemented using CGO bindings via go-astiav
  • FFmpeg components used include:
    • libavformat
    • libavcodec
    • libavutil
  • Decoding, filtering (if needed), and encoding are handled directly through FFmpeg APIs exposed by go-astiav
  • No external ffmpeg binary process is spawned; everything runs in-process via CGO

This design keeps the implementation:

  • Consistent with existing FFmpeg-based logic in the project
  • Efficient for real-time streaming
  • Easier to extend for other codecs or transports in the future

Use cases

  • Low-latency video preview
  • Browser-based playback using WebSocket players (e.g. jsmpeg-like clients)
  • Debugging / monitoring live video streams without HLS/DASH

Backward compatibility

  • The new WebSocket streaming path is isolated and does not affect existing APIs or streaming flows

Next step

Before preparing a Pull Request, I’d like to ask: Would you be open to accepting a PR for this feature?

If so, I’m happy to:

  • Refactor or simplify the code if needed
  • Align with project conventions
  • Add documentation or example usage

Thanks for your time, and I look forward to your feedback.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions