Skip to content

Commit

Permalink
Pure elixir source (#33)
Browse files Browse the repository at this point in the history
* Created tcp_server.
* RTMP source pure elixir implementation (#26)
* Improved validator (#32)
  • Loading branch information
roznawsk committed Oct 19, 2022
1 parent 2fe678b commit 43c6115
Show file tree
Hide file tree
Showing 47 changed files with 2,480 additions and 625 deletions.
42 changes: 28 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@
[![API Docs](https://img.shields.io/badge/api-docs-yellow.svg?style=flat)](https://hexdocs.pm/membrane_rtmp_plugin)
[![CircleCI](https://circleci.com/gh/membraneframework/membrane_rtmp_plugin.svg?style=svg)](https://circleci.com/gh/membraneframework/membrane_rtmp_plugin)

This package provides RTMP server which listens to a connection from a client and element for streaming to an RTMP server. It is part of [Membrane Multimedia Framework](https://membraneframework.org).
### Server
After establishing connection it receives RTMP stream, demux it and outputs H264 video and AAC audio.
At this moment only one client can connect to the server.
### Client
After establishing connection with server it waits to receive video and audio streams. Once both streams are received they are streamed to the server.
Currently only the following codecs are supported:
- H264 for video
- AAC for audio

This package provides RTMP server which receives an RTMP stream from a client and an element for streaming to an RTMP server.
It is part of [Membrane Multimedia Framework](https://membraneframework.org).

## Installation

Expand All @@ -22,37 +14,59 @@ The package can be installed by adding `membrane_rtmp_plugin` to your list of de
```elixir
def deps do
[
{:membrane_rtmp_plugin, "~> 0.8.1"}
{:membrane_rtmp_plugin, "~> 0.9.0"}
]
end
```

## SourceBin

Requires a socket, which has been connected to the client. It receives RTMP stream, demuxes it and outputs H264 video and AAC audio.

## Client
After establishing connection with server it waits to receive video and audio streams. Once both streams are received they are streamed to the server.
Currently only the following codecs are supported:
- H264 for video
- AAC for audio

## Tcp Server
It's a simple implementation of tcp server. It opens a tcp port and listens for incoming connections. For each new connection, a user-provided function is executed.

### Prerequisites
In order to successfully build and install the plugin, you need to have **ffmpeg == 4.4** installed on your system

## Usage
### `Membrane.RTMP.Source` - RTMP Server

### RTMP receiver
Server-side example, in which Membrane will act as an RTMP server and receive the stream, can be found under [`examples/source.exs`](examples/source.exs). Run it with:

```bash
elixir examples/source.exs
```

When the server is ready you can connect to it with RTMP. If you just want to test it, you can use FFmpeg:

```bash
ffmpeg -re -i test/fixtures/testsrc.flv -f flv -c:v copy -c:a copy rtmp://localhost:5000
```
### `Membrane.RTMP.Sink` - Streaming over RTMP
Streaming implementation example is provided with the following [script](examples/sink.exs). Run it with:

### Streaming with RTMP
Streaming implementation example is provided with the following [`examples/sink.exs`](examples/sink.exs). Run it with:

```bash
elixir examples/sink.exs
```

It will connect to RTMP server provided via URL and stream H264 video and AAC audio.
RTMP server that will receive this stream can be launched with ffmpeg by running the following commands:

```bash
export RTMP_URL=rtmp://localhost:1935
ffmpeg -listen 1 -f flv -i rtmp://localhost:1935 -c copy dest.flv
```

It will receive stream and once streaming is completed dump it to .flv file. If you are using the command above, please remember to run it **before** the streaming script.

## Copyright and License

Copyright 2021, [Software Mansion](https://swmansion.com/?utm_source=git&utm_medium=readme&utm_campaign=membrane_rtmp_plugin)
Expand Down
7 changes: 0 additions & 7 deletions bundlex.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ defmodule Membrane.RTMP.BundlexProject do

defp natives(_platform) do
[
rtmp_source: [
sources: ["source/rtmp_source.c"],
deps: [unifex: :unifex],
interface: [:nif],
preprocessor: Unifex,
pkg_configs: ["libavformat", "libavutil"]
],
rtmp_sink: [
sources: ["sink/rtmp_sink.c"],
deps: [unifex: :unifex],
Expand Down
3 changes: 0 additions & 3 deletions c_src/membrane_rtmp_plugin/source/_generated/.gitignore

This file was deleted.

217 changes: 0 additions & 217 deletions c_src/membrane_rtmp_plugin/source/rtmp_source.c

This file was deleted.

24 changes: 0 additions & 24 deletions c_src/membrane_rtmp_plugin/source/rtmp_source.h

This file was deleted.

25 changes: 0 additions & 25 deletions c_src/membrane_rtmp_plugin/source/rtmp_source.spec.exs

This file was deleted.

Loading

0 comments on commit 43c6115

Please sign in to comment.