Recording to Red5 using gstreamer on RPi 3

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Recording to Red5 using gstreamer on RPi 3

Jasen Martin
Hi All

We are developing a simple IoT streaming / recording system with a Raspberry Pi 3 and red5 1.0.8

Currently we are using gstreamer to stream the rpi camera output to rtmp://ipaddress/live without issue using this gstreamer command:

sudo ./gst-launch-1.0 rpicamsrc bitrate2097152 preview=false rotation=180 sensor-mode=5 !video/x-h264,width=1280,height=720,framerate=25/profile=high!h264parse!flvmux!rtmpsink location=rtmp://ipaddress/live/frontdoor

I know I can use gstreamer to separately record to file, but we need to consumer the stream on mobile/desktop, and it does not seem to be a good idea to try and do both at the same time, and ideally we need manage the files inside a red5 app.

The question I have is, how can I tell red5 to record this stream via this command line, is that possible, or do I need to write / modify an app (such as oflademo) and capture the stream and record it programmically?

Generally, I would simple use the publish command with the recording option, however, because I am relying on gstreamer on a the RPi, I don't have that option.

It there an option in the Red5 URI to set the stream to record, such as:

rtmp://ipaddress/live/frontdoor?record=true

I am new to gstreamer, but have used red5 with flex/flash for years and its always been great, but I am now at the end of my knowledge with gstreamer and red5 :)

Hope this make some kind of sense.

Any help or advice much appreciated.

Jasen

--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Recording to Red5 using gstreamer on RPi 3

Rajdeep Rath
Hi

Thank you very much for sharing the info. There are two primary ways to do this.

1. In red5/conf/red5-web.properties file you can change :

broadcaststream.auto.record=false
To
broadcaststream.auto.record=true

2. Add code to server side application to record the live stream to file.


If you want to record on demand then you have to update your code accordingly. 

If you pass parameters via rtmp query string, you can capture the same in your app via I connection.getConnectionParams().

Btw if you don't mind which csmeravmodule are you using either rpi. Is it a proper usb camera or is it like this one : =>

OV7670 CMOS Camera Module Lens CMOS 640X480 SCCB W/ I2C Interface 

Regards
Rajdeep Rath


On May 26, 2017 6:23 AM, "Jasen Martin" <[hidden email]> wrote:
Hi All

We are developing a simple IoT streaming / recording system with a Raspberry Pi 3 and red5 1.0.8

Currently we are using gstreamer to stream the rpi camera output to rtmp://ipaddress/live without issue using this gstreamer command:

sudo ./gst-launch-1.0 rpicamsrc bitrate2097152 preview=false rotation=180 sensor-mode=5 !video/x-h264,width=1280,height=720,framerate=25/profile=high!h264parse!flvmux!rtmpsink location=rtmp://ipaddress/live/frontdoor

I know I can use gstreamer to separately record to file, but we need to consumer the stream on mobile/desktop, and it does not seem to be a good idea to try and do both at the same time, and ideally we need manage the files inside a red5 app.

The question I have is, how can I tell red5 to record this stream via this command line, is that possible, or do I need to write / modify an app (such as oflademo) and capture the stream and record it programmically?

Generally, I would simple use the publish command with the recording option, however, because I am relying on gstreamer on a the RPi, I don't have that option.

It there an option in the Red5 URI to set the stream to record, such as:

rtmp://ipaddress/live/frontdoor?record=true

I am new to gstreamer, but have used red5 with flex/flash for years and its always been great, but I am now at the end of my knowledge with gstreamer and red5 :)

Hope this make some kind of sense.

Any help or advice much appreciated.

Jasen

--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Recording to Red5 using gstreamer on RPi 3

Rajdeep Rath
Correction for typos.

Btw if you don't mind which camera module are you using with rpi. Is it a proper usb camera or is it like this one : =>

OV7670 CMOS Camera Module Lens CMOS 640X480 SCCB W/ I2C Interface 

On May 26, 2017 11:12 AM, "Rajdeep Rath" <[hidden email]> wrote:
Hi

Thank you very much for sharing the info. There are two primary ways to do this.

1. In red5/conf/red5-web.properties file you can change :

broadcaststream.auto.record=false
To
broadcaststream.auto.record=true

2. Add code to server side application to record the live stream to file.


If you want to record on demand then you have to update your code accordingly. 

If you pass parameters via rtmp query string, you can capture the same in your app via I connection.getConnectionParams().

Btw if you don't mind which csmeravmodule are you using either rpi. Is it a proper usb camera or is it like this one : =>

OV7670 CMOS Camera Module Lens CMOS 640X480 SCCB W/ I2C Interface 

Regards
Rajdeep Rath


On May 26, 2017 6:23 AM, "Jasen Martin" <[hidden email]> wrote:
Hi All

We are developing a simple IoT streaming / recording system with a Raspberry Pi 3 and red5 1.0.8

Currently we are using gstreamer to stream the rpi camera output to rtmp://ipaddress/live without issue using this gstreamer command:

sudo ./gst-launch-1.0 rpicamsrc bitrate2097152 preview=false rotation=180 sensor-mode=5 !video/x-h264,width=1280,height=720,framerate=25/profile=high!h264parse!flvmux!rtmpsink location=rtmp://ipaddress/live/frontdoor

I know I can use gstreamer to separately record to file, but we need to consumer the stream on mobile/desktop, and it does not seem to be a good idea to try and do both at the same time, and ideally we need manage the files inside a red5 app.

The question I have is, how can I tell red5 to record this stream via this command line, is that possible, or do I need to write / modify an app (such as oflademo) and capture the stream and record it programmically?

Generally, I would simple use the publish command with the recording option, however, because I am relying on gstreamer on a the RPi, I don't have that option.

It there an option in the Red5 URI to set the stream to record, such as:

rtmp://ipaddress/live/frontdoor?record=true

I am new to gstreamer, but have used red5 with flex/flash for years and its always been great, but I am now at the end of my knowledge with gstreamer and red5 :)

Hope this make some kind of sense.

Any help or advice much appreciated.

Jasen

--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Recording to Red5 using gstreamer on RPi 3

Jasen Martin
Thanks Rajdeep for your reply

We are using the standard rpi camera module v2 (https://www.raspberrypi.org/products/camera-module-v2/) for the moment. We may decided to use different camera later, like an usb camera.

We have found a different approach...rather than simply recording from rpi/gstreamer/camera->red5 continuously, now we can just start recording what we need and when. We will be are using a infrared detector to tell the red5 app to start recording only when the IR detector senses movement for example.

Simply awesome red5/team!

Here is the code we found to start/stop recording the current client stream:

 http://sziebert.net/posts/server-side-stream-recording-with-red5/


    public void recordShow(IConnection conn) {
        log.debug("Recording show for: " + conn.getScope().getContextPath());
        String streamName = String.valueOf(System.currentTimeMillis());
        // Get a reference to the current broadcast stream.
        ClientBroadcastStream stream = (ClientBroadcastStream) app.getBroadcastStream(
                conn.getScope(), "hostStream");
        try {
            // Save the stream to disk.
            stream.saveAs(streamName, false);
        } catch (Exception e) {
            log.error("Error while saving stream: " + streamName, e);
        }
    }
 
    /**
     * Stops recording the publishing stream for the specified
     * IConnection.
     *
     * @param conn
     */
    public void stopRecordingShow(IConnection conn) {
        log.debug("Stop recording show for: " + conn.getScope().getContextPath());
        // Get a reference to the current broadcast stream.
        ClientBroadcastStream stream = (ClientBroadcastStream) app.getBroadcastStream(
                conn.getScope(), "hostStream");
        // Stop recording.
        stream.stopRecording();
    }

This approach is far better, some slight modification needed to get working with latest red5 (1.0.8), we needed to remove app from app.getBroadcastStream (becuase extends MultiThreadedApplicationAdapter now)


Jasen

On Fri, May 26, 2017 at 3:44 PM, Rajdeep Rath <[hidden email]> wrote:
Correction for typos.

Btw if you don't mind which camera module are you using with rpi. Is it a proper usb camera or is it like this one : =>

OV7670 CMOS Camera Module Lens CMOS 640X480 SCCB W/ I2C Interface 

On May 26, 2017 11:12 AM, "Rajdeep Rath" <[hidden email]> wrote:
Hi

Thank you very much for sharing the info. There are two primary ways to do this.

1. In red5/conf/red5-web.properties file you can change :

broadcaststream.auto.record=false
To
broadcaststream.auto.record=true

2. Add code to server side application to record the live stream to file.


If you want to record on demand then you have to update your code accordingly. 

If you pass parameters via rtmp query string, you can capture the same in your app via I connection.getConnectionParams().

Btw if you don't mind which csmeravmodule are you using either rpi. Is it a proper usb camera or is it like this one : =>

OV7670 CMOS Camera Module Lens CMOS 640X480 SCCB W/ I2C Interface 

Regards
Rajdeep Rath


On May 26, 2017 6:23 AM, "Jasen Martin" <[hidden email]> wrote:
Hi All

We are developing a simple IoT streaming / recording system with a Raspberry Pi 3 and red5 1.0.8

Currently we are using gstreamer to stream the rpi camera output to rtmp://ipaddress/live without issue using this gstreamer command:

sudo ./gst-launch-1.0 rpicamsrc bitrate2097152 preview=false rotation=180 sensor-mode=5 !video/x-h264,width=1280,height=720,framerate=25/profile=high!h264parse!flvmux!rtmpsink location=rtmp://ipaddress/live/frontdoor

I know I can use gstreamer to separately record to file, but we need to consumer the stream on mobile/desktop, and it does not seem to be a good idea to try and do both at the same time, and ideally we need manage the files inside a red5 app.

The question I have is, how can I tell red5 to record this stream via this command line, is that possible, or do I need to write / modify an app (such as oflademo) and capture the stream and record it programmically?

Generally, I would simple use the publish command with the recording option, however, because I am relying on gstreamer on a the RPi, I don't have that option.

It there an option in the Red5 URI to set the stream to record, such as:

rtmp://ipaddress/live/frontdoor?record=true

I am new to gstreamer, but have used red5 with flex/flash for years and its always been great, but I am now at the end of my knowledge with gstreamer and red5 :)

Hope this make some kind of sense.

Any help or advice much appreciated.

Jasen

--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
------------------------------------------------------------
Jasen Martin
0424 984 955
------------------------------------------------------------

--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Recording to Red5 using gstreamer on RPi 3

Rajdeep Rath
Good stuff !! Thanks for sharing your thoughts.

On May 27, 2017 10:17 AM, "Jasen Martin" <[hidden email]> wrote:
Thanks Rajdeep for your reply

We are using the standard rpi camera module v2 (https://www.raspberrypi.org/products/camera-module-v2/) for the moment. We may decided to use different camera later, like an usb camera.

We have found a different approach...rather than simply recording from rpi/gstreamer/camera->red5 continuously, now we can just start recording what we need and when. We will be are using a infrared detector to tell the red5 app to start recording only when the IR detector senses movement for example.

Simply awesome red5/team!

Here is the code we found to start/stop recording the current client stream:

 http://sziebert.net/posts/server-side-stream-recording-with-red5/


    public void recordShow(IConnection conn) {
        log.debug("Recording show for: " + conn.getScope().getContextPath());
        String streamName = String.valueOf(System.currentTimeMillis());
        // Get a reference to the current broadcast stream.
        ClientBroadcastStream stream = (ClientBroadcastStream) app.getBroadcastStream(
                conn.getScope(), "hostStream");
        try {
            // Save the stream to disk.
            stream.saveAs(streamName, false);
        } catch (Exception e) {
            log.error("Error while saving stream: " + streamName, e);
        }
    }
 
    /**
     * Stops recording the publishing stream for the specified
     * IConnection.
     *
     * @param conn
     */
    public void stopRecordingShow(IConnection conn) {
        log.debug("Stop recording show for: " + conn.getScope().getContextPath());
        // Get a reference to the current broadcast stream.
        ClientBroadcastStream stream = (ClientBroadcastStream) app.getBroadcastStream(
                conn.getScope(), "hostStream");
        // Stop recording.
        stream.stopRecording();
    }

This approach is far better, some slight modification needed to get working with latest red5 (1.0.8), we needed to remove app from app.getBroadcastStream (becuase extends MultiThreadedApplicationAdapter now)


Jasen

On Fri, May 26, 2017 at 3:44 PM, Rajdeep Rath <[hidden email]> wrote:
Correction for typos.

Btw if you don't mind which camera module are you using with rpi. Is it a proper usb camera or is it like this one : =>

OV7670 CMOS Camera Module Lens CMOS 640X480 SCCB W/ I2C Interface 

On May 26, 2017 11:12 AM, "Rajdeep Rath" <[hidden email]> wrote:
Hi

Thank you very much for sharing the info. There are two primary ways to do this.

1. In red5/conf/red5-web.properties file you can change :

broadcaststream.auto.record=false
To
broadcaststream.auto.record=true

2. Add code to server side application to record the live stream to file.


If you want to record on demand then you have to update your code accordingly. 

If you pass parameters via rtmp query string, you can capture the same in your app via I connection.getConnectionParams().

Btw if you don't mind which csmeravmodule are you using either rpi. Is it a proper usb camera or is it like this one : =>

OV7670 CMOS Camera Module Lens CMOS 640X480 SCCB W/ I2C Interface 

Regards
Rajdeep Rath


On May 26, 2017 6:23 AM, "Jasen Martin" <[hidden email]> wrote:
Hi All

We are developing a simple IoT streaming / recording system with a Raspberry Pi 3 and red5 1.0.8

Currently we are using gstreamer to stream the rpi camera output to rtmp://ipaddress/live without issue using this gstreamer command:

sudo ./gst-launch-1.0 rpicamsrc bitrate2097152 preview=false rotation=180 sensor-mode=5 !video/x-h264,width=1280,height=720,framerate=25/profile=high!h264parse!flvmux!rtmpsink location=rtmp://ipaddress/live/frontdoor

I know I can use gstreamer to separately record to file, but we need to consumer the stream on mobile/desktop, and it does not seem to be a good idea to try and do both at the same time, and ideally we need manage the files inside a red5 app.

The question I have is, how can I tell red5 to record this stream via this command line, is that possible, or do I need to write / modify an app (such as oflademo) and capture the stream and record it programmically?

Generally, I would simple use the publish command with the recording option, however, because I am relying on gstreamer on a the RPi, I don't have that option.

It there an option in the Red5 URI to set the stream to record, such as:

rtmp://ipaddress/live/frontdoor?record=true

I am new to gstreamer, but have used red5 with flex/flash for years and its always been great, but I am now at the end of my knowledge with gstreamer and red5 :)

Hope this make some kind of sense.

Any help or advice much appreciated.

Jasen

--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
------------------------------------------------------------
Jasen Martin
0424 984 955
------------------------------------------------------------

--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.