我正在使用以下命令来做到这一点:
/usr/local/bin/gst-launch-1.0 filesrc location=/home/ubuntu/DELTA.mpg ! textoverlay text="Hello" ! filesink location=/home/ubuntu/delta2.mpg
Run Code Online (Sandbox Code Playgroud)
但是我得到以下输出:
ubuntu@ip-10-185-10-118:~$ /usr/local/bin/gst-launch-1.0 filesrc location=/home/ubuntu/DELTA.mpg ! textoverlay text="Hello" ! filesink location=file4.mpg
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
WARNING: from element /GstPipeline:pipeline0/GstTextOverlay:textoverlay0: Could
not multiplex stream.
Additional debug info:
gstbasetextoverlay.c(1892): gst_base_text_overlay_video_event(): /GstPipeline:pipeline0/GstTextOverlay:textoverlay0:
received non-TIME newsegment event on video input
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:00.024475840
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
ubuntu@ip-10-185-10-118:~$
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么?
这里的问题是您试图在未解码的流上覆盖文本。filesrc元素只是从文件中读取数据并输出原始字节。您需要先对其进行解码,然后覆盖文本,然后将其编码回并写入文件。
这是简单的预览管道:
$ gst-launch filesrc location=test.mpg \
! decodebin2 ! textoverlay text=Hello ! xvimagesink
Run Code Online (Sandbox Code Playgroud)
这是覆盖文本并将视频编码回文件的管道:
$ gst-launch \
filesrc location=test.mpg \
! decodebin2 name=demuxer \
demuxer. \
! textoverlay text=Hello \
! x264enc ! muxer. \
demuxer. ! audioconvert ! vorbisenc ! muxer. \
matroskamux name=muxer \
! filesink location=output.mkv
Run Code Online (Sandbox Code Playgroud)
我使用了不同的输出格式,只是为了不依赖于其他gstreamer插件。您可以切换vorbisenc到faac并matroskamux以mpegtsmux获得output.mpg文件。