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


28

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

有没有不慢或没有故障的东西?

我正在跑步(K)Ubuntu。


您是否尝试过gtk-recordmydesktop?我可以用它记录大多数东西。ffmpeg -i x11grab也可以。如果您在获取音频alsa-loop工作时遇到问题。
RobotHumans 2011年

Answers:


11

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

sudo apt-get install recordmydesktop

从主要渠道安装它。


我在戴耳机时已经使用了它,它会录制对方的音频。我猜它正在录制来自默认麦克风的音频(因此它正在捕获我自己的声音,而不是对方的声音)。任何想法如何解决?
Marcus Junius Brutus

11

此命令将捕获您的整个桌面:因此,无论何时要记录skype会话(或其他任何内容),请使用此命令。

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

1
谢谢!如何只记录特定的窗口,例如网络摄像头的窗口和其他人的窗口?也许甚至是如何单独记录它们以使其更容易编辑。
curiousguy

1
@curiousguy,要使用recordmydesktop记录特定的窗口,请使用“ xwininfo”获取窗口ID,然后使用recordmydesktop来使用“ --windowid”参数。如果要将窗口缩放到特定大小(以像素为单位),可以采用不同的方法-我相信Compiz可以选择此选项,Openbox也会告诉您窗口的尺寸。(我正在使用Fedora。)另外,我相信Openbox可以让您“取消装饰”一个窗口,如果recordmydesktop正在记录您的窗口边框,这将很有帮助。但是,我不确定ffmpeg是否可行?
PJ Brunet

在ubuntu下启用x11grab的情况下如何编译?需要什么包装?
v010dya 2014年

8

背景

借助ffmpeg和大量可用的帮助文章(包括本网站),在通话过程中(或在任何X11桌面活动中)录制实时视频和音频并不是很难。但是,如果您追求更高的质量,则将迅速达到同时获取和压缩媒体这一简单方法的极限。因此,需要一种工具(或一组工具)来实现以下目的:

  1. 记录通话时无需压缩即可将其压缩到文件中以进行进一步处理,这可以识别出在通话时我们仅对音频感兴趣。
  2. 以后以高质量压缩录制的呼叫。

下面的Bash脚本(myrecmyrec-novideomyproc)是我在这个任务的尝试。我敢肯定有写这些脚本的更整洁的方法,但是我正在旅途中学习Bash脚本(一旦投入使用,我会非常满意,我可能会补充)。

先决条件

  1. ffmpeg
  2. pulseaudio
  3. skype

如果1还是2不存在于你的系统,你的首选包管理器安装它们(我用的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的回声消除模块已加载,但我认为这仅是为了消除我自己的语音回声。问题是,当将麦克风音频与声卡音频混合时,稍有延迟就会使最终的流难以收听。有谁知道如何防止麦克风录制扬声器的声音?


最后的笔记

我希望您发现这些工具有用。我期待着听到您的想法以求改进和评论。


2
哇。如果您没有一个git帐户,则可能要启动一个git帐户,并将这些脚本保留在那里。
RobertL

尊敬的Xavras,我修复了所有用户设置,并更改了临时文件前缀,并从文件格式中排除了秒数。运行脚本后,出现错误“ ...〜/ Desktop / sky_20160506_12-10h.mkv:无此类文件或目录”提前创建文件或以root用户运行无济于事。为什么会这样呢?
superAnnoyingUser

您好,@学生,您现在可能已经对它进行了整理,但直到今天我才收到有关您的评论的通知。查看您引用的错误,我会认为代字号(〜)并未解析为适当的路径。尝试以完整格式提供路径,例如/ home / student /。您是否在录制或处理脚本中遇到了问题?
Xavras Wyzryn '16

4

Open Broadcaster Software(OBS)Studio将所有这些要求结合到一个易于使用的前端中。

它是开源的,跨平台的:

对于Ubuntu 15.04和更高版本:

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

对于其他发行版/早期Ubuntu版本,请查看git Wiki


0

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

xvidcap

在默认情况下,您的视频位于./test-0000.mpeg。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.