Friday, July 19, 2013

HTML5 Videos and FLVPlayer Integration

I've been working with HTML5 videos lately. There are several articles out there but nothing that specifically addresses how to fall back to Flash using FLVPlayer.

First thing you need to do is create three versions of your video: MP4, OGV and WEBM. Miro Video Converter is a free utility that can convert to all three formats. Even if you are starting with an MP4 video I suggest creating a new MP4 video from it in case it contains some metadata that is incompatible with all of the HTML5 video players out there. I've run into this on more than one occasion.

I'll use s3.company.com as a placeholder for the server that serves your videos and your FLVPlayer.

<html>
<head>
    <script type="text/javascript" src="http://s3.company.com/players/flvplayer155/swfobject/swfobject.js"></script>
    <script type="text/javascript">
        var flashvars = {
            flvpFolderLocation: "http://s3.company.com/players/flvplayer155/flvplayer/",
            flvpWidth: "720",
            flvpHeight: "480",
            flvpVideoSource: "http://s3.company.com/videos/video1.mp4",
            flvpInterfaceDisplay: "autohide",
            flvpInterfaceLayout: "overlay",
            flvpShowbCc: "false",
            flvpShowbMenu: "false",
            flvpShowbInfo: "false",
            flvpShowbForward: "false",
            flvpShowbBack: "false",
            flvpAutoStartMovie: "false",
            flvpVideoBuffer: "3",
            flvpVidConstraints: "fit to width",
            flvpTurnOnCorners: "false"
        };

        var params = {
            menu: "true",
            allowfullscreen: "true"
        };
                              
    </script>
</head>
<body bgcolor="#888888">  
    <video controls width="720" height="480">
        <source src="http://s3.company.com/videos/video1.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
        <source src="http://s3.company.com/videos/video1.ogv" type='video/ogg; codecs="theora, vorbis"'>
        <source src="http://s3.company.com/videos/video1.webm" type='video/webm'>
        <div id="flashUpgrade">
            <a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a>
        </div>
    </video>
    <script type="text/javascript">
        swfobject.embedSWF("http://s3.company.com/players/flvplayer155/FLVplayer.swf", "flashUpgrade", "720", "480", "9.0.0", "http://s3.company.com/players/flvplayer155/swfobject/expressInstall.swf", flashvars, params);
    </script>
</body>
</html>
  1. Since FLVPlayer builds its embed object using javascript, move the declarations for flashvars and params to the SCRIPT section in HEAD.
  2. Android and some other HTML5 players do not like AUTOPLAY in the VIDEO tag. Leave that out.
  3. Make sure the MP4 video is first in the list of all three video file SOURCEs for HTML5.
  4. FLVPlayer overwrites the flashUpgrade DIV with its embed code, so put its swfobject.embedSWF call in a SCRIPT section after /VIDEO so browsers that don't understand HTML5 will still load the flash video player. Don't autostart FLVPlayer either (flvpAutoStartMovie: "false" in flashvars).
  5. Replace 720 and 480 in all three locations with the dimensions of your video if different.

Thursday, October 25, 2012

Wired remote volume control for ClearOne Gentner AP800 matrix mixer

How to use the Arduino microcontroller to remotely control this matrix mixer.



The Gentner AP800 has 12 balanced inputs and 12 balanced outputs. Each of the 12 inputs can be assigned to one or more of the 12 outputs. The level of each input and output can be adjusted from -20dB to 20dB. In addition each input can be muted. However, the level at which an input is sent to a particular output is not adjustable. An input's level will determine its volume across all of the output channels it is assigned to.

This unit will work fine for my particular application, Halloween sound effect playback. I am using this matrix mixer to control the relative levels of different kinds of wind and music played through two sets of stereo speakers.

But I need a way to fine-tune the relative levels of sound effects while listening to them, rather than going back and forth between the sound rack and the listening location. Additionally, since the sound effects are stereo, I want a single knob that adjusts both the left and right volume simultaneously.

After reading the manual for the AP800 I discovered it can be completely controlled through its serial port. I decided to build a wired remote control that would use an Arduino to send serial commands to the AP800 as I adjust various potentiometers.



View Schematic
 

View Arduino Code

The Arduino's TTL serial output needs to be converted to RS-232 serial (different voltage) before it can be interfaced to the AP800. I am using the NKC RS232 to TTL converter (DTE).

There are two components: A "base station" and a "remote" that are connected together over standard CAT5 ethernet cable. If a crossover cable is used accidentally, nothing will be damaged, but the remote will not work.

The remote has a dim red LED to indicate that it is connected to the base station and is receiving power. An "unlock" button, while pressed, initiates a process on the Arduino to read the potentiometers and send the correct serial commands to the AP800.

I made this mostly out of spare parts I had laying around the shop. If I had a bigger remote box I would have added a third potentiometer and moved the mode selector to the remote. However, keeping the mode selector at the base station allows me to leave the volume remote out in one of the listening areas where I want to easily adjust the levels for that area without accidentally adjusting those for a different area.

The Arduino program has four sets of variables - ModeX_InputYZ - one set for each of the four modes selected by the rotary switch. These determine which inputs are controlled by the two potentiometers for each mode select setting.


Sunday, October 14, 2012

Pneumatic Jack in the Box, Part 3

To support the mask I built a frame out of perforated metal tape. I basically fit each piece into the mask from the inside, then attached the pieces together with small nuts and bolts. The frame was then screwed into a stand made of three pieces of 1x2 wood left over from the torsion box coffin lid project.

An additional piece of metal tape serves as the "jaw" and tucks neatly into the chin of the mask. I also bent out part of the metal tape to tuck into the nose. There was no need to glue or otherwise attach the mask to the metal perforated tape; the nose and jaw hold quite well on their own.


I attempted to mount the servo to the wood using pieces of rubber to cut down on vibration, but I do not think it helped much. The servo I used, the Hi Tec HS-82MG, uses metal gears and apparently this makes the servo very noisy.

At some point I may try the HS-81 servo which has identical specs to the 82MG except for having nylon gears.

Important: Observe the motion of the servo as it is controlled by the Arduino before attaching the horn and control wire. Make sure you know what position the servo is in (mouth closed or mouth open) before fastening the horn onto the servo and connecting the control wire to the mouth.

The first video below shows the inside of the mask frame.

After attaching the wooden stand to the accordion's top platform, I ran two cables. One regular speaker cable and a separate, shielded servo control cable. The two cables are zip-tied together and run down to the electronics enclosure to connect to the ELK-120 and the Arduino.

The servo control cable is shielded to prevent the servo from responding to stray EMF or interference from the high-level speaker signal. The outer shield connects to the AC chassis ground at the electronics enclosure end of the cable only. Three wires inside the shield are for signal ground, +5VDC from the power supply, and the servo control line from the Arduino.

The final phase was to "dress" the clown so that it didn't just look like a head on a platform. I created a shoulder and neck form out of tape and attached it around the head stand. I then draped black felt and blue satin cloth over the shoulders and attached it at the front and back of the inside of the box.

Finally, the purple frilly lace ruffle for the neck. This conveniently hides any part of the frame or shoulder form from showing as well. This was a little difficult to find, until I realized I could use a child-size tutu. Looks fine.

Videos:
10/04/12: Clown head with mouth servo
10/13/12: Demonstration of completed Jack-in-the-box halloween prop (featured below)




Start from the beginning: Pneumatic Jack in the Box, Part 1

Thursday, September 20, 2012

Pneumatic Jack in the Box, Part 2

Make sure you view all the videos posted in Part 1 before continuing.

The ELK-120 sound board can pull up to 2A@12VDC and the mouth servo may require more current @5VDC than the Arduino's voltage regulator can support, so I went with a dual-output power supply that provides 12VDC and 5VDC outputs.

However, the Arduino and the DF Robot Relay boards all need 9VDC.

I built a simple voltage regulator circuit using the LM350T voltage regulator IC to drop 12VDC down to 9VDC. I discovered the DF Robot relay boards will draw power from the Arduino when it is only powered by the USB connection to my laptop, so I added a 1N914 diode between the Arduino and the voltage regulator board so the Arduino will only receive power from the voltage regulator's output to which the other boards are also connected.

On the same board I also placed some terminal blocks, pull-down resistors, and unique-value resistors for the Arduino's analog inputs. The accordion head platform position sensor, lid position flex sensor and Insteon InlineLinc trigger input all connect to this "interface" board.



Here are some pictures of the prop with the base, accordion platform, electronics and most of the pneumatics completed. The lid cylinder has not yet been installed.

JITB internals from left side JITB internals from right front corner JITB internals from rear right corner

In the last photo, note the magnet mounted to a strip of aluminum bar attached to one of the drawer slides on the base of the accordion. The magnet moves back and forth between two reed switches which tell the Arduino the position of the head platform. Each reed switch connects to a different unique-value resistor on the interface board which allows both reed switches to work off of a single analog input. When the head is down, one value is read, when it is up, another value is read.

On the rear panel are the connections for power in, air in, an AC outlet for the UV spots (controlled by one of the DF Robot relays) and a weatherproof panel protecting a USB port for external access to adjust the Arduino program (called a "sketch") and a one-amp circuit breaker for the AC outlet. Since I am using (2) 3W UV LED spotlights to light the JITB from two different angles, 120W is more than enough. I was concerned about overloading the 18-gauge internal wiring or the small DF Robot relay assigned to the spotlights. Hence the one-amp breaker.

JITB rear panel connectionsI made a YouTube video explaining how to make the flange mount for the air in connector.

Next I made the left, right, front and top panels out of 1/2" plywood, gave them a coat of Kilz white primer, then projected some art I found on the internet onto them and lightly traced the projected images with a pen. You don't want to trace the outlines with a very dark or thick pen as this will show through the primer and the fluorescent paint.

Here are some pictures of how the panels turned out. They look even brighter under UV light. After painting them, I sprayed them with interior gloss polyurethane to give them some basic protection from damage. Interior polyurethane won't block UV, exterior-grade will. We don't want to block UV since this is fluorescent paint.

Note: Make sure you are done painting before the polyurethane coat! I forgot some dark wash "shadow" lines at the edges of clothing and under the chin on a couple of the panels.

JITB left panel JITB right panel JITB top panel
JITB front panel with motor arbor through eye JITB front panel motor on back of panel On the back of the front panel I mounted a 25RPM Dayton gearmotor from Grainger. A 1/2" thick slab of rubber prevents motor vibration from resonating the panel.

Videos:
09/25/12: JITB assembled no head - with lid cylinder (featured below)
10/04/12: Clown head with mouth servo



Part 3 will review the animatronic clown head and shoulder assembly.

I am keeping a Parts List for this project updated on Google Docs.

Continue to Pneumatic Jack in the Box, Part 3