sh 简单的gstreamer管道,用于将从网络摄像头捕获的视频录制到OGG,同时在屏幕上显示视频。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 简单的gstreamer管道,用于将从网络摄像头捕获的视频录制到OGG,同时在屏幕上显示视频。相关的知识,希望对你有一定的参考价值。

#!/bin/sh

##
# Simple gstreamer pipeline to record a video captured from a webcam (through v4l) to OGG file while
# showing the video also on the screen.
#
# Sample usage:
#
# Record to webcam.ogg:
#
#   ./camrec.sh
#
# Record to output.ogg:
#
#   ./camrec.sh output.ogg
#
# To adjust capture width/hight or set the V4L device see variables below.
#
# Pipeline:
#
# Capture video from V4L source, convert to ffmpegcolorspace, split result (with tee and two queues)
# to two separate path. One shows currently captured video on screen (xvimagesink), the other one 
# encodes the captured video to OGG-container with theoraenc and writes the result to a file (filesink). 
#
#                                                                      +-------------+
#                                                                   +--| xvimagesink |
#                                                                 [Q]  +-------------+
# +---------+  +-----------------+  +------------------+  +-----+ /
# | v4l2src |--| video/x-raw-yuv |--| ffmpegcolorspace |--| tee |
# +---------+  +-----------------+  +------------------+  +-----+ \
#                                                                 [Q]  +-----------+  +--------+  +----------+
#                                                                   +--| theoraenc |--| oggmux |--| filesink |
#                                                                      +-----------+  +--------+  +----------+
# 2012-11-19, sw@kaltpost.de, http://gpio.kaltpost.de
##

##
# --- Settings
##

# Output file 
OUTPUT=$1

# capture device to use
V4LDEV="/dev/video0"

# capture width
WIDTH=1280

# capture height
HEIGHT=720

# bitrate for theoraenc
BITRATE=256

##
# --- END of settings
##


if [ "X$1" = "X" ]
then
   OUTPUT="webcam.ogg"
fi

echo "**"
echo "* Starting recording from webcam@${V4LDEV} to: ${OUTPUT}@${WIDTH}x${HEIGHT}"
echo "* Using OGG-container and THEORA-encoding with bitrate: ${BITRATE}" 
echo "* Press CTRL+C to end recording"
echo "**"

#
# -e switch makes gst to close the OGG container properly when exited with CTRL+C
#
gst-launch -e \
   v4l2src device=${V4LDEV} ! video/x-raw-yuv,format=\(fourcc\)YUY2,width=${WIDTH},height=${HEIGHT} ! \
   ffmpegcolorspace ! \
   tee name="splitter" ! queue ! xvimagesink sync=false splitter. ! \
   queue ! videorate ! video/x-raw-yuv ! \
   theoraenc bitrate=${BITRATE} ! oggmux ! filesink location=${OUTPUT}

以上是关于sh 简单的gstreamer管道,用于将从网络摄像头捕获的视频录制到OGG,同时在屏幕上显示视频。的主要内容,如果未能解决你的问题,请参考以下文章

sh 用于RPI的Gstreamer 1.8构建脚本

Gstreamer Appsink 未从管道获取数据

处理 chrome 的 rtp 流需要哪些 gstreamer 管道设置?

在 EOS 上用 Python 重启 GStreamer 管道

使用 GStreamer 在 Android 上进行硬件视频解码

gstreamer视频对话需要经过网络吗