New exec features

I’ve improved exec support in nginx-rtmp. Several new directives were added:

  • exec_publish – run external program on publish event
  • exec_play – run external program on play event
  • exec_publish_done – run external program when publisher closes stream
  • exec_play_done – run external program when player closes
    stream
  • exec_record_done – run external program when recording has finished

Previously implemented exec command is supported as well. The difference is old plain exec keeps external program running during all publishing period. It supports program restart. This behavior convenient for online transcoding with ffmpeg. The new features are pure notifiers. Unlike on_publish and on_play program result code is not used.

All (old & new) execs support the following variables:

  • app – application name
  • name – stream name
  • addr – client address
  • flashver – client flash version
  • pageurl – client page url
  • swfurl – client swf url
  • tcurl – client tc url
  • path – recorded file path (only for exec_record_done)

application foo {
    live on;

    # register all publishers in text file
    exec_publish bash -c "echo $addr $app $name >> /var/publishers"

    # register all players too
    exec_play bash -c "echo $addr $app $name $pageurl $swfurl >> /var/players"

    # make previews
    recorder preview {
        record keyframes;
        record_max_frames 4;
        record_path /var/rec;
        record_interval 30s;

        exec_record_done ffmpeg -i $path -vcodec png -vframes 1 -an -f rawvideo -s 320x240 -ss 00:00:01 -y $path.png;
    }
}

Go to nginx-rtmp project page

Advertisements
  1. #1 by John on September 18, 2012 - 2:21 pm

    Nice additions! Is there any information on RTMP / AMF callbacks? Like, when Flash connects to an nginx-rtmp application and does this in the ‘Live’ manner. Then, if someone wants to start recording a callback on the NetConnection with a command like ‘startRecord’ could start the FLV writing, and cause a callback like ‘recordStarted’ back to the Flash app. A matching stopRecord with recordStopped feedback would be nice aswell. That way, from the webpage, a user can have a live stream running and at some points decide to capture it to a server. Or is this something that needs to be added as a plugin to this module…

  2. #2 by rarut on September 18, 2012 - 2:51 pm

    You’re right. These callbacks should be implemented in plugins.

    • #3 by gion on September 23, 2012 - 7:27 pm

      You could if you want of course, add lua scripting support and make everyone happy and profit :D.
      Congratulations on all your hard and demanding work!

      • #4 by rarut on September 23, 2012 - 8:10 pm

        I think I could but I don’t see if it makes any sense. There’s no output in handler unlike http case.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: