问题描述
我正在尝试编写gstreamer管道以将mpeg4视频转换为mpegts格式。
我尝试过以下管道,但没有运气
$ gst-launch-1.0 -e filesrc location=20200818125158_00001.ts.mp4 ! qtdemux name=mdemux ! \
h264parse ! video/x-h264,stream-format=byte-stream ! mpegtsmux name=mux ! filesink location=20200818125158_00001.ts
在管道上方执行时,我得到以下错误
Setting pipeline to PAUSED ...
Pipeline is prerollING ...
WARNING: from element /GstPipeline:pipeline0/GstQTDemux:mdemux: Delayed linking Failed.
Additional debug info:
./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstQTDemux:mdemux:
Failed delayed linking some pad of GstQTDemux named mdem
我的输入格式
gst-discoverer-1.0 vid.mp4
Analyzing file:///vid.mp4
Done discovering file:///vid.mp4
Topology:
container: Quicktime
video: MPEG-4 Video (Simple Profile)
Properties:
Duration: 0:00:07.267000000
Seekable: yes
Live: no
Tags:
video codec: MPEG-4 video
maximum bitrate: 8400000
bitrate: 298925
encoder: Lavf57.83.100
container format: ISO MP4/M4A
我的目标格式
Topology:
container: MPEG-2 Transport Stream
video: H.264 (High Profile)
Properties:
Duration: 0:00:09.900164000
Seekable: yes
Live: no
Tags:
video codec: H.264
解决方法
video codec: MPEG-4 video
您在源文件中的视频编解码器是MPEG-4 Video。这与H.264不同。尝试使用mpegvideoparse
代替h264parse
。
不需要强制Als video/x-h264,stream-format=byte-stream
设置上限。解析器和多路复用器应自行就上限达成共识。
花了多个小时并阅读了有关gstreamer的更多信息之后,我才找到了正确的管道。下面的管道对我有用
gst-launch-1.0 filesrc location=vid.mp4 ! qtdemux ! avdec_mpeg4 ! X264enc ! mpegtsmux ! filesink location=vid.ts