zoukankan      html  css  js  c++  java
  • 〖Linux〗录像桌面视频同时录音

    1. 安装依赖的包

    sudo apt-get install -y ffmpeg oss-compat alsa-oss

    2. 录制桌面视频并录音

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

    3. 使用脚本在后台进行录像

    #!/bin/bash - 
    #===============================================================================
    #
    #          FILE: recordscreen.sh
    # 
    #         USAGE: ./recordscreen.sh 
    # 
    #   DESCRIPTION: 
    # 
    #       OPTIONS: ---
    #  REQUIREMENTS: ---
    #          BUGS: ---
    #         NOTES: ---
    #        AUTHOR: linkscue (scue), linkscue@gmail.com
    #  ORGANIZATION: 
    #       CREATED: 2013年08月17日 18时28分01秒 HKT
    #      REVISION:  ---
    #===============================================================================
    
    #-------------------------------------------------------------------------------
    #  使用举例:
    #
    #  1. 录制无声桌面视频
    #     ./recordscreen.sh
    #     结束无声桌面视频录制
    #     ./recordscreen.sh off
    #
    #  2. 录制有声桌面视频
    #     ./recordsrceen.sh a
    #     结束有声桌面视频录制
    #     ./recordscreen.sh a off
    #-------------------------------------------------------------------------------
    
    #-------------------------------------------------------------------------------
    #  结束视频录像函数
    #-------------------------------------------------------------------------------
    
    kill_process(){
        kill $(pidof ffmpeg)
    }
    
    #-------------------------------------------------------------------------------
    #  -f oos -i /dev/dsp                           # 录音
    #  -f x11grab                                   # 输入类型为x11grab
    #  -s wxga                                      # 大小是wxga(1366x768)
    #  -r 25                                        # 帧频是25(25张图片/秒)
    #  -i :0.0                                      # 设置输入源,本地X默认在0.0
    #  -sameq                                       # 与输入流一样的质量
    #  -vcodec msmpeg4v2                            # 压缩输出的avi视频格式
    #-------------------------------------------------------------------------------
    
    #默认录像不带声音,当有传参为a时录音
    if [[ "$1" == "a" ]]; then
        shift                                       # 输入参数向左移 $2 --> $1
        cmd="ffmpeg -f oss -i /dev/dsp -f x11grab -s wxga -r 25 -i :0.0 -sameq -vcodec msmpeg4v2"
        acmd="aoss $cmd"
        if [[ "$1" != "" ]]; then
            kill_process
        else
            # 使用 nohup 使此命令忽略终端的退出(终端终止此命令依然运行)
            nohup $acmd /tmp/out_$(date +%F_%X).avi >/dev/null 2>&1 &
        fi
    else
        cmd="ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq -vcodec msmpeg4v2"
        if [[ "$1" != "" ]]; then
            kill_process
        else
            # 使用 nohup 使此命令忽略终端的退出(终端终止此命令依然运行)
            nohup $cmd /tmp/out_$(date +%F_%X).avi >/dev/null 2>&1 &
        fi
    fi
  • 相关阅读:
    2011 ACM-ICPC 成都赛区解题报告(转)
    Subarray Sorting (线段树)
    sample
    gamma correction / /alpha blend
    mipmap
    antialiasing
    汇编指令
    zfighting 的问题
    勉励自己
    Ambient Occulution
  • 原文地址:https://www.cnblogs.com/scue/p/3279038.html
Copyright © 2011-2022 走看看