首页 > 解决方案 > 如何通过 gstreamer 发送两个视频

问题描述

亲爱的

我正在寻找一种将两个视频并排放置并以 H.264 发送的方法。

#!/bin/bash
gst-launch-1.0 -e \
filesrc location="/home/namako/tairyou_2.mp4" \
! decodebin \
! videoscale \
! capsfilter caps="video/x-raw,width=240" \
! videoconvert \
! videomixer.sink_0 \
\
filesrc location="/home/namako/tairyou_2.mp4" \
! decodebin \
! videoscale \
! capsfilter caps="video/x-raw,width=240" \
! videoconvert \
! videomixer.sink_1 \
\
videomixer background=1 name=videomixer sink_0::xpos=0 sink_0::ypos=0 sink_1::xpos=512 sink_1::ypos=0 \
! decodebin \
! videoscale \
! capsfilter caps="video/x-raw,width=240" \
! videoconvert \
! x264enc \
! rtph264pay \
! udpsink host=127.0.0.1 port=5000

我做了上面的代码,但显示了以下“错误”。

パイプラインを一時停止 (PAUSED) にしています...
Pipeline is PREROLLING ...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
ERROR: from element /GstPipeline:pipeline0/GstX264Enc:x264enc0: Can not initialize x264 encoder.
追加のデバッグ情報:
gstx264enc.c(1587): gst_x264_enc_init_encoder (): /GstPipeline:pipeline0/GstX264Enc:x264enc0
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

好像h.264不能编码。

另外,使用上面的代码,就变成了下面的流水线连接图。

在此处输入图像描述

在连接图中,videomixer 输入为 mpeg2,但输出为 jpeg。

我应该怎么做才能在 mpeg2、H.264 中输出?

标签: gstreamer

解决方案


谢谢!可以使用以下代码播放视频。

#!/bin/bash
gst-launch-1.0 -e \
filesrc location="filename" \
! decodebin \
! videoscale \
! capsfilter caps="video/x-raw,width=480,height=270" \
! videoconvert \
! videomixer.sink_0 \
\
filesrc location="filename" \
! decodebin \
! videoscale \
! capsfilter caps="video/x-raw,width=480,height=270" \
! videoconvert \
! videomixer.sink_1 \
\
videomixer background=1 name=videomixer sink_0::xpos=0 sink_0::ypos=0 sink_1::xpos=480 sink_1::ypos=0 \
! decodebin \
! videoscale \
! capsfilter caps="video/x-raw,width=480,height=270" \
! videoconvert \
! x264enc \
! rtph264pay \
! udpsink host=127.0.0.1 port=5000


推荐阅读