29

I'd like to conduct recorded video interviews with Skype and am looking for a reliable tool to accomplish that.

Is there anything out there that's not slow or buggy?

I'm running (K)Ubuntu.

3
  • have you tried gtk-recordmydesktop? i can record most anything with it. ffmpeg -i x11grab works too. if you're having problems getting the audio alsa-loop works. Commented Apr 20, 2011 at 15:16
  • Try asking at askubuntu.com. Commented Apr 21, 2011 at 23:36
  • @RobotHumans You were mentioning alsa-loop... How do we use that?
    – 71GA
    Commented May 18, 2020 at 7:38

5 Answers 5

12

This command will capture your full desktop: So use this command, whenever you want to record skype-conversation ( or anything else )

ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg   
4
  • 1
    Thanks! How can I record only specific windows e.g. the window of my webcam and the window of the other person's? Perhaps even how to record them separately to make it easier to edit.
    – curiousguy
    Commented Apr 23, 2011 at 11:03
  • 1
    @curiousguy, to record a specific window with recordmydesktop, use "xwininfo" to get the window id, then with recordmydesktop use the "--windowid" parameter. If you want to scale your window to a specific size (in pixels) there's different ways to do it--I believe Compiz has this as an option, also Openbox will tell you the window dimensions. (I'm using Fedora.) Also I believe Openbox will let you "undecorate" a window, which is helpful if recordmydesktop is recording your window border. However, I'm not sure if this is possible with ffmpeg?
    – Jay Brunet
    Commented Jun 10, 2011 at 0:20
  • How would one compile with x11grab enabled under ubuntu? What package does it need?
    – v010dya
    Commented Jan 22, 2014 at 13:14
  • Does it record the sound? Commented Oct 16, 2020 at 6:17
11

There is software recordMyDesktop http://recordmydesktop.sourceforge.net/about.php which you can record any part of you screen you want. I use it to record my skype sessions.

sudo apt-get install recordmydesktop

to install it from main channels.

2
  • I've used that while wearing a headset and it would record the audio of the other party. I guess it was recording audio from the default microphone (so it was capturing my own voice but not the other party's). Any idea how to fix that ? Commented Jan 29, 2017 at 0:46
  • 1
    Does it record the sound as well? Commented Oct 16, 2020 at 6:17
9

Background

Recording live video and audio during a call (or during any X11 desktop activity) is not very difficult thanks to ffmpeg and the amount of help articles available (including this site). However, if you aim at higher quality, you will quickly reach the limits of the simple approach of simultaneous media grabbing and compressing. Hence the need for a tool (or a set of tools) that would enable to:

  1. Record calls without compression into a file for further processing, recognizing that when calling a phone we are interested only in audio.
  2. Compress the recorded calls in high quality at a later time.

The following Bash scripts (myrec, myrec-novideo and myproc) are my attempt at this task. I am sure there are neater ways of writing these scripts, but I was learning Bash scripting on the go (with tremendous satisfaction once I got it to work, I might add).

Prerequisites

  1. ffmpeg
  2. pulseaudio
  3. skype

If 1 or 2 are not present in your system, install them with your preferred package manager (I use synaptic). For skype visit www.skype.com.


Record lossless video and lossless audio - myrec

  1. Create a text file
  2. Save it as myrec (or whatever name works for you)
  3. Make myrec executable by issuing the command: chmod +x myrec
  4. Paste the following code into it and modify User settings section to suit your setup:

#!/bin/bash

echo "Record lossless audio and lossless video for further processing."
echo "Created file name always starts with temp_YYYYMMDD_HHMMSS."
echo "Syntax:"
echo "myrec [optional file description]"
echo "Optional file description is appended to the file name, with spaces replaced by underscores."
echo
echo

### User settings - adjust values to suit your system and needs

# I used to have the name of my webcam mic here, but that stopped working after a system update. "default" was the only fix I found. If you have more than one microphone connected, you may need to tell Pulseaudio which mic you want to be the default, I think pavucontrol is the utility for it.
# If you want to try supplying a name here, run pacmd, then within it the command list-sources will give you a list of possible microphones. Use the name field value without angle brackets.
microphone_audio_device="default"

# Run pacmd, within it the command list-sinks will give you a list of devices to choose from. Use the name field value without angle brackets.
speakers_audio_device="alsa_output.pci-0000_00_1b.0.analog-stereo.monitor"

# Select frame size.
# Some standard frame sizes for reference:
# wvga 852x480
# wxga 1366x768
# wsxga 1600x1024
# wuxga 1920x1200
# woxga 2560x1600
# wqsxga 3200x2048
# wquxga 3840x2400
# whsxga 6400x4096
# whuxga 7680x4800
frame_size="wsxga"

# Framerate in frames per second
framerate="30"

# Indicate which screen the video should be recorded from and an optional offset.
# For example:
# :0.0+10,20
# where 0.0 is display.screen number of your X11 server, same as the DISPLAY environment variable. 10 is the x-offset and 20 the y-offset of the frame, measured from the top left corner of the screen to the top left corner of the frame.
frame_position=":0.0"

# Include the trailing slash after target directory name.
# Expect a very large file!
target_directory="/target/directory/name/"

### End of user settings



record_command="ffmpeg -f pulse -thread_queue_size 512k -i $speakers_audio_device -f pulse -thread_queue_size 512k -i $microphone_audio_device -f x11grab -s $frame_size -r $framerate -thread_queue_size 512k -i $frame_position -map 0 -map 1 -map 2 -codec:a copy -codec:v libx264 -qp 0 -preset ultrafast"
temporary_file_prefix="temp_"

# The IFS (Internal Field Separator) system variable stores the character that separates command line arguments.
# We can use it to replace spaces with underscores.
temp=$IFS
IFS='_'
description="$*"
IFS=$temp

if [ $# -eq 0 ]; then
  $record_command $target_directory$temporary_file_prefix`date +%Y%m%d_%H%M%S`.mkv
else
  $record_command $target_directory$temporary_file_prefix`date +%Y%m%d_%H%M%S`_$description.mkv
fi

Recording audio only is handled by a separate script in the following section.


Record only lossless audio - myrec-novideo

  1. Create a text file
  2. Save it as myrec-novideo (or whatever name works for you)
  3. Make myrec-novideo executable by issuing the command: chmod +x myrec-novideo
  4. Paste the following code into it and modify User settings section to suit your setup:

#!/bin/bash

echo "Record lossless audio for further processing."
echo "Created file name always starts with temp_YYYYMMDD_HHMMSS."
echo "Syntax:"
echo "myrec-novideo [optional file description]"
echo "Optional file description is appended to the file name, with spaces replaced by underscores."
echo
echo


### User settings - adjust values to suit your system

# I used to have the name of my webcam mic here, but that stopped working after a system update. "default" was the only fix I found. If you have more than one microphone connected, you may need to tell Pulseaudio which mic you want to be the default, I think pavucontrol is the utility for it.
# If you want to try supplying a name here, run pacmd, then within it the command list-sources will give you a list of possible microphones. Use the name field value without angle brackets.
microphone_audio_device="default"

# Run pacmd, within it the command list-sinks will give you a list of devices to choose from. Use the name field value without angle brackets.
speakers_audio_device="alsa_output.pci-0000_00_1b.0.analog-stereo.monitor"

# Include the trailing slash after target directory name.
# Expect a large file!
target_directory="/target/directory/name/"

### End of user settings



record_command="ffmpeg -f pulse -thread_queue_size 512k -i $speakers_audio_device -f pulse -thread_queue_size 512k -i $microphone_audio_device -map 0 -map 1 -codec:a copy -codec:a copy"
temporary_file_prefix="temp_"

# The IFS (Internal Field Separator) system variable stores the character that separates command line arguments.
# We can use it to replace spaces with underscores.
temp=$IFS
IFS='_'
description="$*"
IFS=$temp

if [ $# -eq 0 ]; then
  $record_command $target_directory$temporary_file_prefix`date +%Y%m%d_%H%M%S`.mkv
else
  $record_command $target_directory$temporary_file_prefix`date +%Y%m%d_%H%M%S`_$description.mkv
fi


Process the recorded files - myproc

  1. Create a text file
  2. Save it as myproc (or whatever name works for you)
  3. Make myproc executable by issuing the command: chmod +x myproc
  4. Paste the following code into it and modify User settings section to suit your setup:


#!/bin/bash

echo "Compress files recorded with myrec or myrec-novideo."
echo "For files to be processed they need to reside in the storage directory and start with temp_"
echo "The two audio tracks (mic and speakers) are mixed together into one new stream, but they are also available as separate tracks in the final file."

# Mixing is because players I know cannot play two audio tracks from the same file simultaneously.
# The mic also captures sounds produced by the speakers. It has two effects:
# 1. You can use this single track to hear both yourself (the mic) and whatever came out of your speakers. Personally I did not like the degraded quality of recorded speaker sounds, hence the direct recording off the sound card and mixing that with the mic track.
# 2. Speaker sounds recorded by the mic are slightly delayed when compared to the direct recording off the sound card. The mixed track is thus hard to listen to.
# I do have echo cancellation module loaded in Pulseaudio, perhaps there is something wrong with my configuration?

### User settings

# Indicate storage directory without the trailing slash
storage_directory="/storage/directory/name"

### End of user settings

# Any temp_ file may contain 3 streams (audio, audio, video) indexed as (0, 1, 2), or just 2 streams (audio, audio) indexed as (0, 1).
# A file temp2_ contains just one stream: both audio streams from temp_ mixed.
# The step with temp2_ is necessary as the mixing option (-filter_complex) is a global option (i.e. not stream-specific). Attempts at doing it all in one go prevent the separate tracks from being copied into the final file.

for f in $storage_directory/temp_*
do
  if [ -e ${f/temp_/} ]
  then
    # Do not overwrite an existing final file. Prevents unnecessary work when the script is run regularly as a cron job.
    echo "$f: A final file (without temp_) already exists. Skipping. If you want to reencode, please delete the final file manually."
  else
    # Variable g will contain the name of the second temporary file with both audio streams mixed into one.
    g=${f/temp_/temp2_}

    # Mixing mic and sound card tracks into one stream
    ffmpeg -i "$f" -map 0:0 -map 0:1 -filter_complex amix=inputs=2:duration=longest:dropout_transition=2 -codec:a libvorbis -n "$g"

    # Create the final file: copy the mixed audio stream from temp2_, add and compress both separate audio streams from temp_, compress at high quality the video stream from temp_.
    # The question mark in -map 0:2? tells ffmpeg to ignore the error if this stream (video) is missing. Allows this same script to be used for audio-only recordings.
    ffmpeg -i "$f" -i "$g" -map 1:0 -map 0:0 -map 0:1 -map 0:2? -codec:a:0 copy -codec:a:1 libvorbis -codec:a:2 libvorbis -codec:v libx264 -qp 18 -preset slow -threads 0 -n "${g/temp2_/}"

    # Delete temp2_
    rm "$g"
  fi
done


Thanks to ffmpeg's flexibility, myproc can process files that may or may not contain the video stream.


How to use the scripts

  1. Decide where Skype's video call window is going to be on your screen and set the window size to a desired dimension. Skype will remember this window setting, so you only have to do it once. At every subsequent call the window will appear in the same place in the same size. Remember to tell myrec of your settings. In general, try to have the video call window somewhere near your webcam, so that the person on the other side has a chance to think that you are looking them in the eye.
  2. Have a terminal window open. Whenever you wish to start recording, use the command:

    • to record audio and video: . myrec some description
    • to record audio only: . myrec-novideo some description

    some description is optional in both scripts. You can use the Tab key to expand script names to save some typing. ffmpeg will start recording to a file named temp_YYYYMMDD_HHMMSS_some_description.mkv, where YYYYMMDD_HHMMSS is the date and time of the recording.

  3. Press q at the terminal window where ffmpeg is recording once you are ready to stop.
  4. Run . myproc to process (compress) the files. You can either do it manually, or set up a cron job to do it while you are away.
  5. Once you verify that compression went as expected, delete the temp_ file.


Issues

  1. Unable to specify microphone by name, can only use the special value default. I used to have the mic name there, but this setting stopped working after a system update. It could be something restricted to my setup only, or to pulseaudio.
  2. Mic audio contains my voice and the sound from the speakers. The sound from the speakers is slightly behind the audio stream recorded directly off the sound card. Pulse's echo cancellation module is loaded, but I think it is only meant to cancel my own voice echo. The thing is that when mic audio is mixed with sound card audio the slight delay makes the resulting stream hard to listen to. Does anyone have an idea how to prevent the mic from recording the sounds from the speakers?


Final notes

I hope you find these tools useful. I look forward to hearing your thoughts for improvement and comments.

3
  • 2
    Wow. You might want to start a git account if you don't have one and also keep these scripts on there.
    – RobertL
    Commented Nov 10, 2015 at 3:06
  • Dear Xavras, I fixed all the user settings and I changed the temporary file prefix and the excluded the seconds from the file format. Upon running the script I get the error " ... ~/Desktop/sky_20160506_12-10h.mkv: No such file or directory " Creating the file in advance or running as root does not help. Why may this be? Commented May 6, 2016 at 10:14
  • Hello @Student, you may have sorted it out by now, but I received a notification about your comment only today. Looking at the error you quoted I would think that the tilde (~) did not get resolved into its appropriate path. Try providing the path in its full form, like /home/student/. Did you run into the issue in the recording or processing script?
    – likewise
    Commented Dec 4, 2016 at 4:08
5

Open Broadcaster Software (OBS) Studio ties all these requirements into an easy to use frontend.

It's open source, and cross platform:

For Ubuntu 15.04 and later:

sudo add-apt-repository ppa:obsproject/obs-studio
sudo apt-get update && sudo apt-get install obs-studio ffmpeg

For other distros/earlier Ubuntu versions, checkout the git wiki

2
  • It does not work, the audio from my mic does not work when recording skype and the video shows with a weird blue hue. Too bad. I've also tried to install the NDI pluggin, but it lacks a library and anyway the linux version of Skype does not include the option to enable NDI. Commented Apr 6, 2020 at 12:30
  • 1. The mic will work if you use JACK, and 2. If you use the xcomposite screen capture, there is an advanced option to swap red and blue, that may resolve your hue issue
    – cleary
    Commented Apr 6, 2020 at 22:50
0

xvidcap allows you to select an area from your desktop and record it. Start it with the command

xvidcap

find your video at ./test-0000.mpeg by default.

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .