如何通过gstreamer发送两个视频

时间:2019-06-19 04:49:34

标签: 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进行编码。

同样,使用上面的代码,它成为下面的管道连接图。

enter image description here

在连接图中,混音器输入为mpeg2,但输出为jpeg。

我应该如何在mpeg2,H.264中输出?

1 个答案:

答案 0 :(得分:0)

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

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