Off-The-Shelf Hacker: Use Picture-in-Picture in Your Next Tech Video

An interesting way to demonstrate physical computing gadgets, like thermocouples, interacting with on-screen gauges is by using a “picture-in-picture” (PiP) video compositing technique.
I didn’t have the video ready by press time for last week’s story, so I just went with the meter moving up and down on-screen. Readers had to take it on faith that the thermocouple actually worked. It did. Today, we’ll do a quick tutorial on making a video that details using the “PiP” technique in Kdenlive open source video editor.
You’ll Need Clips
The finished video is of the entire Linux desktop with the meter running under the Processing IDE. A small embedded video of the working thermocouple is superimposed at the lower right-hand corner of the larger video. Another example might show a servo-activated mechanism move, as we push an on-screen slider back and forth. I use the ASUS notebook for video editing since the Raspberry Pi is a bit underpowered for that type of job. You can certainly show the finished clip on the Pi.
We’ll need a screen capture clip of the meter moving up and down, along with a separate video of the gadget (thermocouple) going in and out of the hot water. Essentially it’s a two-camera process.
Capturing the on-screen meter is pretty straight forward and was covered in the recent article on capturing a screen demo on video. The gadget clip was shot on my Samsung Galaxy S8+ smartphone. A “hands-free” mount is needed because it’s impossible to work the thermocouple, coordinate all the video processes and hold the smartphone camera, all at once. Quite a while back I built a goose-neck mount for the Galaxy phone to participate in conference calls and shoot short videos for my speaker proposals.

Gooseneck mount with the old Galaxy S5 smartphone
The Galaxy phone is held in the mount with a big rubber band and the whole rig is clipped to the lip on the edge of my desk. The phone was oriented to shoot the video horizontally. No $1,000 stand needed here!
Syncing the Two Video Programs
Run stty at the command line to ensure data is available to the Processing gauge program. Start Processing and load the thermocouple gauge program. Test that the meter needle moves up and down as you put the thermocouple probe in and out of the hot water.
Start the SimpleScreenRecorder. Specify the file name and directory for saving the video file. Don’t start recording yet. We need to sync recording the screen with recording the gadget clip.
Start the video recording program on the Galaxy phone. Position the camera, so that the glass and thermocouple appear centered in the frame. Make sure the program is set to capture video, not a photo.
Hit the “record” button on the Galaxy phone to begin recording the gadget clip. Immediately hit the “start recording” button on the SimpleScreenRecorder program on the Linux notebook. Minimize the recording window, so it isn’t in the desktop frame.
Pick up the thermocouple and dunk it in the hot water a couple of times. The meter on the desktop should move up and down.
Click the un-minimize button on the SimpleScreenRecorder recording window and push the “pause recording” button to stop the screen capture. Click the “save recording” button at the bottom of the window to write the clip out to a file.
Next, click the “record” button on the Galaxy video program to stop recording the gadget clip. Save the file and transfer it over to the Linux notebook. Email works great for sending a photo or video to myself on different machines. For larger files, send them over a USB cable plugged into the phone and the notebook.
With the two files now available on the notebook, we can marry them together into a single video file.
Put the Picture in the Picture
Start Kdenlive on the Linux notebook.
Click on the “Add Clip” menu tab in the clip list area. Select the embedded video clip from the file list. Grab the video and place it on video timeline No. 2.
Again click on the “Add Clip” tab and select the screen capture video from the file list. Grab the video and place it on video timeline No. 1.
Highlight the video No. 1 timeline. Play the video in the clip monitor until you see the meter start to move upward. This should correspond to dipping the thermocouple into the hot water. Make note of the position of the timeline. Now select the video No. 2 timeline. Grab and slide the video so that dipping the thermocouple in the water syncs with the meter moving upward. You can watch the clip monitor and use the timeline position indicator to line the two clips up pretty closely.
Next, while still highlighting video timeline No. 2, right-click and select “add transition,” then “composite.” Click on the right/left edge of the orange composite transition box, crossing both timelines and resize it to fit timeline No. 2 (the embedded gadget clip). Move the timeline position indicator line anywhere on the overlapping clips. Click the orange composite transition box again to bring up the composite transition configuration window, as well as a red box around the video frame, in the clip monitor window. Grab a corner of the red box to shrink the gadget clip window to a reasonable size. Grab the center of the red box to move the window to the lower right part of the desktop capture video clip. Use the timeline position indicator line and the clip monitor to see how the desktop video looks with the superimposed gadget video. You may have to jockey everything around a bit to get it to sync-up and look right.
Finally, hit the “Render” button at the top of the Kdenlive screen. Set the output file name and push the “Render to File” button at the bottom of the window. After a few minutes, there will be an MP4 file that you can play using mplayer or upload to YouTube.
Here’s the video, with a title page inserted at the front. I also muted the audio in both clips, before rendering the output file.
That’s A Wrap
It seems like a lot of steps to combine two videos into a composite demo clip. Once you do it a couple of times, you’ll see a lot of areas where you can streamline the process and add little professional touches to up your tech video demo game. Rendering using the MP4 format (H264/ACC) gives nice quality video with a reasonable file size.
The Galaxy is a great phone and is well suited for capturing video or photos for articles. All of the photos and videos you see in OTSH came from a Galaxy smartphone, either the now-retired S5 Active or my current S8+. I was thinking I might try the old S5 for a few multicamera clips, since it’s paid for and just collecting dust right now. Still perfectly usable as a camera. That’s a topic for another story.
Catch Dr. Torq’s Off-The-Shelf Hacker column, each Saturday, only on The New Stack! Contact him directly for consulting, speaking appearances and commissioned projects at doc@drtorq.com or 407-718-3274.