gstreamer - 如何通过 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 中输出?
解决方案
谢谢!可以使用以下代码播放视频。
#!/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
推荐阅读
- rust - 循环局部变量
- strapi - Strapi - 自定义路由上的 webhook
- azure - 如何使用 jmespath 在 AZ Cli PowerShell 中获取 appid 和密码?
- vba - 如何格式化以纯文本格式格式化的 Outlook 消息
- npm - npm - 我可以将 npm 包发布到我的服务器吗?
- c - for循环C后缺少数组值
- postgresql - 为什么在客户端进程被杀死后连接仍保留在 pg_stat_activity 中?
- python - 不使用 group by 的 django 子查询
- javascript - “页面顶部”按钮的悬停效果在单击时会粘住,如何撤消此操作?
- api - 如何将所有 API 调用放在一个 JS 文件中,以及如何在组件中使用它来使用来自 API 的内容