我正在尝试重新编码MKV文件的音频部分,该文件包含一些video/x-h264
和一些audio/x-raw
。我不能只对MKV进行解复用并重新复用。甚至简单地说:
gst-launch-1.0 filesrc location=test.mkv ! matroskademux name=demux
matroskamux name=mux ! filesink location=test2.mkv
demux.video_00 ! mux.video_00
demux.audio_00 ! mux.audio_00
惨败:
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
WARNING: from element /GstPipeline:pipeline0/GstMatroskaDemux:demux: Delayed linking failed.
Additional debug info:
../gstreamer/gst/parse/grammar.y(506): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstMatroskaDemux:demux:
failed delayed linking pad video_00 of GstMatroskaDemux named demux to pad video_00 of GstMatroskaMux named mux
WARNING: from element /GstPipeline:pipeline0/GstMatroskaDemux:demux: Delayed linking failed.
Additional debug info:
../gstreamer/gst/parse/grammar.y(506): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstMatroskaDemux:demux:
failed delayed linking pad audio_00 of GstMatroskaDemux named demux to pad audio_00 of GstMatroskaMux named mux
ERROR: from element /GstPipeline:pipeline0/GstMatroskaDemux:demux: Internal data stream error.
Additional debug info:
../gst-plugins-good/gst/matroska/matroska-demux.c(5715): gst_matroska_demux_loop (): /GstPipeline:pipeline0/GstMatroskaDemux:demux:
streaming stopped, reason not-linked (-1)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
我在上面提到的代码转换方面的最佳尝试是:
gst-launch-1.0 -v filesrc location=test.mkv ! matroskademux name=demux
matroskamux name=mux ! filesink location=test2.mkv
demux.video_00 ! queue ! 'video/x-h264' ! h264parse ! mux.
demux.audio_00 ! queue ! rawaudioparse ! audioconvert ! audioresample ! avenc_aac ! mux.
结果相同。移除焊盘名称audio_00
会导致gst
卡在PREROLLING
。
我见过一些人面临类似的问题:
- http://gstreamer-devel.966125.n4.nabble.com/Putting-h264-file-inside-a-container-td4668158.html
- http://gstreamer-devel.966125.n4.nabble.com/Changing-the-container-format-td3576914.html
正如其中所述,只保留视频或只保留音频是有效的。
我认为rawaudioparse
不应该在这里。我试过你的管道,也遇到了麻烦。我刚刚想出了一些我本该做的事情,它似乎奏效了:
filesrc location=test.mkv ! matroskademux
matroskademux0. ! queue ! audioconvert ! avenc_aac ! matroskamux ! filesink location=test2.mkv
matroskademux0. ! queue ! h264parse ! matroskamux0.
在我的情况下,音频是:
Stream #0:0(eng): Audio: pcm_f32le, 44100 Hz, 2 channels, flt, 2822 kb/s (default)
另一种格式可能需要附加转换。。
问题是焊盘video_00
和audio_00
已重命名为video_0
和audio_0
。使用gst-inspect-1.0 matroskademux
可以看出这一点,这表明焊盘的格式现在读取video_%u
请注意,gstreamer的一些文档页面没有更新以反映这一点
第一个命令,MKV到MKV应该是:
gst-launch-1.0 filesrc location=test.mkv ! matroskademux name=demux
matroskamux name=mux ! filesink location=test2.mkv
demux.video_0 ! queue ! mux.video_0
demux.audio_0 ! queue ! mux.audio_0
(注意添加的queue
s(
第二个命令,MKV到MKV重新编码音频应为:
gst-launch-1.0 -v filesrc location=test.mkv ! matroskademux name=demux
matroskamux name=mux ! filesink location=test2.mkv
demux.video_0 ! queue ! 'video/x-h264' ! h264parse ! mux.
demux.audio_0 ! queue ! rawaudioparse ! audioconvert ! audioresample ! avenc_aac ! mux.
如果不指定焊盘,并在需要时使用盖帽过滤器,也可以获得相同的结果。
感谢用户Florian Zwoch提供的工作管道