vote up 1 vote down star

I would like to combine two videos into one. The first video should cover the entire screen. The second video should cover a smaller area at the upper right the screen (thus overlapping the first video).

Ideally the process should be automated. For example with a script that takes two input videos and outputs one movie file.

Can anyone recommend a video editing tool for Linux that would allow me to do this?

PS: The context is lecture recording. The main screen will be covered with a recording of the whiteboard or the presenter's desktop, while the presenter himself would be visible in he upper right rectangle of the screen.

Edit
As a developer I'd be willing to familiarize me with GStreamer and write an application that does just what I need. Would that be a good idea?

Edit 2
Just found this interesting gst-launch script that does almost exactly what I want. Let me try that out.

flag

44% accept rate
What operating system are you planning to use for this? – mac Nov 22 at 22:22
@mac, for Linux, I updated my post. – StackedCrooked Nov 22 at 22:24

3 Answers

vote up 2 vote down

I asked a similar question in question 71694. I ended up writing a python script to do what I wanted. This was easier than expected and I have ended up with a completely automated solution, though programming skills are obviously required.

Here is my work-flow;

  1. Export the input videos to image sequences using ffmpeg
  2. Define a configuration file that determines the location of the videos in the output, their frame-rates, start & stop times etc.
  3. The python script combines the images using the Python Imaging Library(PIL) and writes them out as a new image sequence
  4. use ffmpeg to recombine the output into a video

I am happy to share more details & code if you want to go down this route. Otherwise, I have also used Camtasia (not Linux so probably no use to you) to do produce some basic picture-in-picture stuff (they have nice tutorial here)

link|flag
That's an interesting approach. I'm gonna check out what the possibilities are, but just a few quick questions: Is there a significant loss in quality? How did you preserve audio? How do you associate timestamps for each image? – StackedCrooked Nov 22 at 22:43
1) no loss in quality as I export to uncompressed bitmaps (it takes a lot of disk space temporarily) 2) it doesn't process audio right now - you could add the original audio track back in at stage 4 as ffmpeg can do this 3) A master frame-rate defined for the output video - for each output frame the script works out which frame is 'current' for each input stream and combines them There are python bindings for ffmpeg and I hope to eventually read & write the video streams directly to avoid saving the temporary images – rupello Nov 22 at 22:58
vote up 2 vote down

This one liner shows you how to do it, just adjust sizes to match your screen resolution.

gst-launch \
    v4l2src device=/dev/video1 \
    	! video/x-raw-yuv,width=352,height=288,framerate=\(fraction\)30/1 \
    	! videoscale \
    	! video/x-raw-yuv,width=640,height=480 \
    	! cairotextoverlay text=1 shaded-background=true deltax=310 deltay=-430 \
    	! videobox left=0  top=0  border-alpha=0 \
    	! videomixer name=mix \
    	! xvimagesink \
    v4l2src device=/dev/video0 \
    	! video/x-raw-yuv,width=640,height=480,framerate=\(fraction\)30/1 \
    	! videoscale \
    	! video/x-raw-yuv,width=1280,height=960 \
    	! cairotextoverlay text=2 shaded-background=true deltax=630 deltay=-910 \
    	! videobox left=0 top=0 border-alpha=0 \
    ! mix.
link|flag
vote up 1 vote down

Fascinating problem. I do not have a out-of-the-box solution but a couple of leads and alternate ways of doing that.

Leads

  • See this page they used imagemagick toolkit and some bash scripting (scripts available on the site). They needed to do something more complex than you need, but I suppose the technique is the same.
  • There are also various plugins available for FFmpeg. This watermark plugin uses an animated GIF on the main video. Again... different task, but I assume the code is highly recyclable for your ends.

Alternative ways of doing it

  • Record them simultaneously! You can use for example cheese to keep a shot of the teacher in the corner of the screen, and recordmydesktop to record the screen as a whole.
  • Use a video editor like OpenShot or Cinelerra to do the composite after you recorded separately the two videos.

Hope this helps you a bit in finding your way to solve the problem. Best luck!

link|flag

Your Answer

Get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.