WordPress Plugin: Added RTMP Stream Support to WordPress video.js plugin (hope it works)

I’ve been experimenting with video plugins lately, and I’d like to get streaming working for the large MP4 videos that I host here. I was using JW Player, but I thought it’d be interesting to tryout the video.js player as well.

video.js is an HTML5 video player with smooth fallback to Flash for those users who cannot use HTML5.

I noticed on the Video.JS blog that RTMP support is now present and supported by the video.js embedded video player. Unfortunately, the video.js WordPress plugin doesn’t yet support this feature, so I modified my video.js plugin file in my WordPress install to support RTMP streaming.

It’s stuttering, but it could be because I am uploading a large file to S3 at the moment at 1.4 MB/sec (11.2 Mb/sec), so I may be using up
my local bandwidth.

Use is:

[ videojs stream="rtmp://stream.example.com/cfx/st/&mp4:MY-VIDEO_1080P.mp4" mp4="http://cdn.example.com/MY-VIDEO_1080P.mp4"]

Relevant section of the code as modified:

/* The [ video ] or [ videojs ] shortcode */
function video_shortcode($atts, $content=null){
 add_videojs_header();
 
 $options = get_option('videojs_options'); //load the defaults
 
 extract(shortcode_atts(array(
 'stream' => '',
 'mp4' => '',
 'webm' => '',
 'ogg' => '',
 'youtube' => '',
 'poster' => '',
 'width' => $options['videojs_width'],
 'height' => $options['videojs_height'],
 'preload' => $options['videojs_preload'],
 'autoplay' => $options['videojs_autoplay'],
 'loop' => '',
 'controls' => '',
 'id' => '',
 'class' => '',
 'muted' => ''
 ), $atts));

 $dataSetup = array();
 
 // ID is required for multiple videos to work
 if ($id == '')
 $id = 'example_video_id_'.rand();

 // RTMP MP4 Source Supplied
 if ($stream)
 $stream_source = '<source src="'.$stream.'" type=\'rtmp/mp4\' />';
 else
 $stream_source = '';

 // MP4 Source Supplied
 if ($mp4)
 $mp4_source = '<source src="'.$mp4.'" type=\'video/mp4\' />';
 else
 $mp4_source = '';

 // WebM Source Supplied
 if ($webm)
 $webm_source = '<source src="'.$webm.'" type=\'video/webm; codecs="vp8, vorbis"\' />';
 else
 $webm_source = '';

 // Ogg source supplied
 if ($ogg)
 $ogg_source = '<source src="'.$ogg.'" type=\'video/ogg; codecs="theora, vorbis"\' />';
 else
 $ogg_source = '';
 
 if ($youtube) {
 $dataSetup['forceSSL'] = 'true';
 $dataSetup['techOrder'] = array("youtube");
 $dataSetup['src'] = $youtube;
 }
 // Poster image supplied
 if ($poster)
 $poster_attribute = ' poster="'.$poster.'"';
 else
 $poster_attribute = '';
 
 // Preload the video?
 if ($preload == "auto" || $preload == "true" || $preload == "on")
 $preload_attribute = ' preload="auto"';
 elseif ($preload == "metadata")
 $preload_attribute = ' preload="metadata"';
 else 
 $preload_attribute = ' preload="none"';

 // Autoplay the video?
 if ($autoplay == "true" || $autoplay == "on")
 $autoplay_attribute = " autoplay";
 else
 $autoplay_attribute = "";
 
 // Loop the video?
 if ($loop == "true")
 $loop_attribute = " loop";
 else
 $loop_attribute = "";
 
 // Controls?
 if ($controls == "false")
 $controls_attribute = "";
 else
 $controls_attribute = " controls";
 
 // Is there a custom class?
 if ($class)
 $class = ' ' . $class;
 
 // Muted?
 if ($muted == "true")
 $muted_attribute = " muted";
 else
 $muted_attribute = "";
 
 // Tracks
 if(!is_null( $content ))
 $track = do_shortcode($content);
 else
 $track = "";

 $jsonDataSetup = str_replace('\\/', '/', json_encode($dataSetup));

 //Output the <video> tag
 $videojs = <<<_end_

 <!-- Begin Video.js -->
 <video id="{$id}" class="video-js vjs-default-skin{$class}" width="{$width}" height="{$height}"{$poster_attribute}{$controls_attribute}{$preload_attribute}{$autoplay_attribute}{$loop_attribute}{$muted_attribute} data-setup='{$jsonDataSetup}'>
 {$stream_source}
 {$mp4_source}
 {$webm_source}
 {$ogg_source}{$track}
 </video>
 <!-- End Video.js -->

_end_;

How to Use a Camcorder to Produce (Almost) Professional Video

(featured image by Ted Eytan, “Filming in DC 37297)

I have the privilege of working in video ministry as one of my hobbies.¬†If you’re a new camera operator looking for basic instruction or an experienced camera operator looking to improve your quality by reviewing fundamentals, this blog post should help you.

While there are several pages and videos that do a pretty good job of explaining how to run a video camera, I’m going to use this blog entry to point to to the best instructional videos and give my own brief explanation of the basics. I’m not going to write a book here, but there are plenty of high-quality books on the subject worth reading.
Continue reading

Video Project: Church in a Day – Decatur, Indiana (2009)

So, I decided to show my support for the 2009 Church in a Day project in Decatur, Indiana and get some use out of my new video camera and tripod and non-linear editing software.

It was really awesome to get to see the Church in a Day project up close. Church in a Day is a project of the United Pentecostal Church International in which a bunch of volunteers converge on a plot of land and in less than 24 hours have a functional church built. My video doesn’t do the wonder of this justice; if you get a chance, spend a few hours helping at one of these.

The result is this video. The video is a stupidly long edit, and the music is terribly annoying. I think my videos since then have improved. The video is posted here as originally edited in 2009. I’ve improved since then.
Continue reading

Video Project: Run for Recovery Promo (2010)

A friend is a professional counselor and invited me to shoot a video promo for an upcoming run to raise awareness for addictions recovery.

The primary camera’s footage was unusable due to a significant color-balance issue, so I had to edit the video using the secondary cameras. Additionally, the video suffered from a lack of writing and pre-shoot planning. I should have insisted on a script and should have gotten additional moving shots and B-roll footage should have been inserted. I was severely limited in time and equipment. I also wanted to release this long before the event, and wasn’t able to release it early enough for it to be useful.
Continue reading

Video Project: Adult Life Training, Inc. Computer Training Video Pilot (2009)

My father runs a non-profit organization which teaches adults (typically senior citizens) basic computer skills.

We talked about using video to augment the in-class teaching, and this video is part of that project. I hope you all will enjoy this dated but somewhat interesting video.

Video Project: 34 CBCS Change of Command Ceremony (1 JUNE 2012)

I had the privilege of recording the 34th Combat Communications Squadron’s (United States Air Force) final change of command ceremony on June 1, 2012. Lt Col Prescod handed over command of the 34th Combat Comm to Maj Montelepre.

While I had a lot of computer issues while editing this, causing some minor issues with the resultant video, I hope you all will enjoy this anyway.