如何在 Linux 上录制 Skype 视频通话?

如何在 Linux 上录制 Skype 视频通话?

我想通过 Skype 进行录制的视频采访,并且正在寻找可靠的工具来实现这一目标。

有没有什么东西既不慢又不麻烦?

我正在运行 (K)Ubuntu。

答案1

此命令将捕获您的完整桌面:因此,每当您想要记录 Skype 对话(或其他任何内容)时,请使用此命令

ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg   

答案2

有软件recordMyDesktophttp://recordmydesktop.sourceforge.net/about.php您可以录制屏幕上您想要的任何部分。我用它来记录我的 Skype 会话。

sudo apt-get install recordmydesktop

从主要渠道安装它。

答案3

背景

由于 ffmpeg 和大量可用的帮助文章(包括本网站),在通话期间(或任何 X11 桌面活动期间)录制实时视频和音频并不是很困难。然而,如果您的目标是更高的质量,您很快就会达到同时媒体抓取和压缩的简单方法的极限。因此,需要一个(或一组工具)能够:

  1. 将通话录音而不压缩到文件中以供进一步处理,认识到在拨打电话时我们只对音频感兴趣。
  2. 稍后以高质量压缩录制的通话。

以下 Bash 脚本(myrecmyrec-novideomyproc)是我对此任务的尝试。我确信有更简洁的方法来编写这些脚本,但我正在学习 Bash 脚本(我可能会补充说,一旦我让它工作,我就会感到非常满意)。

先决条件

  1. ffmpeg
  2. pulseaudio
  3. skype

如果12不存在于您的系统中,请使用您首选的包管理器(我使用synaptic)安装它们。供skype参观www.skype.com


录制无损视频和无损音频 -myrec

  1. 创建一个文本文件
  2. 将其另存为myrec(或任何适合您的名称)
  3. myrec通过发出以下命令使其可执行:chmod +x myrec
  4. 将以下代码粘贴到其中并修改User settings部分以适合您的设置:

#!/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

仅录制音频由下一节中的单独脚本处理。


仅录制无损音频 -myrec-novideo

  1. 创建一个文本文件
  2. 将其另存为myrec-novideo(或任何适合您的名称)
  3. myrec-novideo通过发出以下命令使其可执行:chmod +x myrec-novideo
  4. 将以下代码粘贴到其中并修改User settings部分以适合您的设置:

#!/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


处理录制的文件 -myproc

  1. 创建一个文本文件
  2. 将其另存为myproc(或任何适合您的名称)
  3. myproc通过发出以下命令使其可执行:chmod +x myproc
  4. 将以下代码粘贴到其中并修改User settings部分以适合您的设置:


#!/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


由于ffmpeg的灵活性,myproc可以处理可能包含也可能不包含视频流的文件。


如何使用脚本

  1. 确定 Skype 的视频通话窗口在屏幕上的位置,并将窗口大小设置为所需的尺寸。 Skype 将记住此窗口设置,因此您只需执行一次。在随后的每次调用中,窗口将以相同的大小出现在相同的位置。请记住告知myrec您的设置。一般来说,尝试将视频通话窗口放在网络摄像头附近,以便对方有机会认为您正在看着他们的眼睛。
  2. 打开终端窗口。每当您想开始录制时,请使用以下命令:

    • 录制音频和视频:. myrec some description
    • 仅录制音频:. myrec-novideo some description

    some description在两个脚本中都是可选的。您可以使用Tab键扩展脚本名称以节省一些输入。 ffmpeg将开始录制到名为 的文件temp_YYYYMMDD_HHMMSS_some_description.mkv,其中YYYYMMDD_HHMMSS是录制的日期和时间。

  3. 准备停止时,按正在录制q的终端窗口。ffmpeg
  4. 运行. myproc以处理(压缩)文件。您可以手动执行此操作,也可以设置一个cron作业在您离开时执行此操作。
  5. 验证压缩是否按预期进行后,删除该temp_文件。


问题

  1. 无法通过名称指定麦克风,只能使用特殊值default。我曾经在那里有麦克风名称,但此设置在系统更新后停止工作。这可能仅限于我的设置,或者仅限于pulseaudio.
  2. 麦克风音频包含我的声音和扬声器发出的声音。扬声器发出的声音稍微落后于直接从声卡录制的音频流。Pulse的回声消除模块已加载,但我认为这只是为了消除我自己的语音回声。问题是,当麦克风音频与声卡音频混合时,轻微的延迟会使生成的流很难听。有谁知道如何防止麦克风录制扬声器的声音?


最后的笔记

我希望您发现这些工具很有用。我期待听到您的改进想法和意见。

答案4

xvidcap 允许您从桌面选择一个区域并记录它。使用命令启动它

xvidcap

默认情况下,在 ./test-0000.mpeg 中查找您的视频。

相关内容