我有一个MPEG-TS文件,其中包含两个视频/音频流对:
$ gst-discoverer-1.0 Recorder_Aug01_12-30-39.ts
Analyzing Recorder_Aug01_12-30-39.ts
Done discovering Recorder_Aug01_12-30-39.ts
Topology:
container: MPEG-2 Transport Stream
audio: MPEG-2 AAC
audio: MPEG-4 AAC
video: H.264 (High Profile)
audio: MPEG-2 AAC
audio: MPEG-4 AAC
video: H.264 (High Profile)
Properties:
Duration: 0:01:49.662738259
Seekable: yes
Tags:
audio codec: MPEG-2 AAC
video codec: H.264现在,我想将第一个视频和音频流和第二个视频/音频提取到两个单独的MP4容器中。
用一个简单的管道并行地显示这两个视频流:
$ gst-launch-1.0 filesrc location=Recorder_Aug01_12-30-39.ts ! tsdemux name=ts \
ts.video_0_0102 ! queue ! h264parse ! avdec_h264 ! videoconvert ! videoscale ! autovideosink \
ts.video_0_0100 ! queue ! h264parse ! avdec_h264 ! videoconvert ! videoscale ! autovideosink当我将mp4mux与一个流上的filesink元素一起引入时,它仍然工作,第一个视频流显示,第二个视频保存到MP4容器文件中:
$ gst-launch-1.0 filesrc location=Recorder_Aug01_12-30-39.ts ! tsdemux name=ts \
ts.video_0_0102 ! queue ! h264parse ! avdec_h264 ! videoconvert ! videoscale ! ximagesink \
ts.video_0_0100 ! queue ! h264parse ! mp4mux ! filesink location=2.mp4现在我的问题是:一旦我尝试通过文件墨水保存这两个流,它就失败了:
$ gst-launch-1.0 filesrc location=Recorder_Aug01_12-30-39.ts ! tsdemux name=ts \
ts.video_0_0102 ! queue ! h264parse ! mp4mux ! filesink location=1.mp4 \
ts.video_0_0100 ! queue ! h264parse ! mp4mux ! filesink location=2.mp4
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstMP4Mux:mp4mux0: Could not multiplex stream.
Additional debug info:
gstqtmux.c(3486): gst_qt_mux_add_buffer (): /GstPipeline:pipeline0/GstMP4Mux:mp4mux0:
Buffer has no PTS.
Execution ended after 0:00:00.001992389
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...我希望使用gstreamer来实现这一点,因为它以后应该是需要大量反省的更大的处理工作流的一部分,因此使用ffmpeg或一些外部二进制文件是不可能的。
发布于 2018-04-11 07:43:11
GStreamer缓冲区没有PTS故障模式
这可能不能完全解决使用GStreamer的问题,但这是我现在使用的解决方法。它包括隔离失败的组件,即gstreamer管道中的“mp4mux”元素。
我发现,即使是Gstreamer中的示例视频编码目前也失败了,例如缓冲区中没有PTS失败模式:
gst-launch-1.0 videotestsrc num_buffers=300 ! videoconvert ! videoscale ! omxh264enc ! h264parse ! mp4mux ! filesink location=test.mp4只对h264编码使用Gstreamer。
删除mp4mux元素使我们能够成功地创建.h264文件。如果您使用的是Raspberry Pi omxh264编码器元素,那么特别方便。
gst-launch-1.0 videotestsrc num_buffers=300 ! videoconvert ! videoscale ! omxh264enc ! filesink location=test.h264解决音视频混合问题
现在,要将其转换为MP4 (最初的目标),我们可以使用很好的轻量级Gpac MP4box。
sudo apt-get install gpac
MP4Box -isma -inter 250 -fps 30.0 -mpeg4 -hint -noprog -add test.h264 test.mp4然后你可以添加你的音频
MP4Box -add audio.mp3 test.mp4摘要
https://stackoverflow.com/questions/45455279
复制相似问题