【问题标题】:How to use gstreamer for transcoding and resizing from mp4(h264/aac) to mp4(h264/mp3)?如何使用 gstreamer 从 mp4(h264/aac) 转码和调整大小到 mp4(h264/mp​​3)?
【发布时间】:2015-01-20 02:31:46
【问题描述】:

我想使用 gstreamer 对 mp4.(mp4-h264_1920x1080/aac => mp4-h264_640x480/mp3) 进行转码和调整大小。我写下了这个命令。

$ gst-launch-0.10 filesrc location=./gain_1.mp4 ! qtdemux name=demux demux.video_00 ! queue ! ffdec_h264 ! videoscale ! 'video/x-raw-yuv,width=640,height=480' ! x264enc ! queue ! qtmux name=mux mux.video_0 demux.audio_00 ! queue ! ffdec_aac ! lame bitrate=128 ! queue ! mux.audio_0 mux. ! filesink location=0000.mp4 –v -e
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Redistribute latency...
^CCaught interrupt -- handling interrupt.
Interrupt: Stopping pipeline ...

(gst-launch-0.10:17958): GLib-CRITICAL **: Source ID 1 was not found when attempting to remove it
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

这没用。

仅对视频进行转码:

gst-launch-0.10 filesrc location=./gain_1.mp4 ! qtdemux name=demux demux.video_00 ! queue ! ffdec_h264 ! videoscale ! 'video/x-raw-yuv, width=640, height=480' ! x264enc ! queue ! mux. mp4mux name=mux ! filesink location=0000.mp4 –v -e

也只转码音频:

gst-launch-0.10 filesrc location=./gain_1.mp4 ! qtdemux name=demux demux.audio_00 ! ffdec_aac ! lame bitrate=128 ! queue ! mux. mp4mux name=mux ! filesink location=0000.mp4 –v -e

如何使用相同的命令对音频和视频进行转码?

【问题讨论】:

  • 第一个命令的具体问题是什么?
  • @Mathieu_Du 当我被要求运行该命令时,该消息是下一个。 => 将管道设置为 PAUSED ... Pipeline 正在 PREROLLING ... 重新分配延迟... 并且刚刚结束。
  • 尝试在解复用器的音频垫之后放置一个队列,也许在 ffdec_aac 之前?
  • @Mathieu_Du 我试图排个队。像这样~~~x264enc!队列 !多路复用器。 demux.audio_00 !队列 ! ffdec_aac !蹩脚~~~~ 但是,结果是一样的。
  • 好吧,我不确定那里会发生什么,你应该用 gstreamer 1.0 试试这个,如果你仍然重现,请在 gtsreamer IRC 上讨论。

标签: gstreamer mp4 h.264 aac gst-launch


【解决方案1】:

@Lionel.J 我想提出两个改进建议:

  1. 如果可能,请使用 gstreamer-1
  2. 您的解决方案读取源文件两次。那没有必要。此外,执行此操作时,音频和视频流不会同步。您可以从 qtdemux 中读取音频和视频流。

这是一个使用 gstreamer-1 完成工作并且只读取一次源代码的管道:

gst-launch-1.0 -e filesrc location=/path/to/big_buck_bunny_720p_h264.mov ! \
decodebin name=decode ! \
videoscale ! 'video/x-raw,width=640,height=480' ! \
x264enc ! queue ! mp4mux name=mp4mux ! filesink location=0000.mp4 \
decode. ! audioconvert ! lamemp3enc bitrate=128 ! queue ! mp4mux.

【讨论】:

  • 它给了我:(gst-launch-1.0:5692):GStreamer-CRITICAL **:gst_element_make_from_uri:断言'gst_uri_is_valid(uri)'失败警告:错误的管道:语法错误
  • @mabg 管道应该如图所示工作。也许你错过了一个插件。尝试使用-v 运行以了解发生了什么。 export GST_DEBUG_DUMP_DOT_DIR=/tmp 在运行管道之前会导致 gst-launch 在不同时间转储管道。那也有帮助。要将转储转换为图片,请运行dot -Tpng -o pipeline.png /tmp/one-of-the-files.dot
  • 问题出在 video/x-rax,width=...语法错误
  • x264enc 是 GStreamer 丑陋插件的一部分。可能您需要单独安装它(在类似 Debian 的 Linux 上打包 gstreamer1.0-plugins-ugly)。
【解决方案2】:

哦~ 我解决了这个问题。 下一个命令做得很好。

gst-launch-0.10 ffmux_mp4 name=mux ! \
filesink location=0000.mp4 \
filesrc location=./gain_1.mp4 ! qtdemux name=vdemux vdemux.video_00 ! queue ! ffdec_h264 ! videoscale ! 'video/x-raw-yuv, width=640, height=480' ! x264enc ! queue ! mux. \
filesrc location=./gain_1.mp4 ! qtdemux name=ademux ademux.audio_00 ! ffdec_aac ! lame bitrate=128 ! queue ! mux.`

【讨论】:

    猜你喜欢
    • 2013-11-12
    • 1970-01-01
    • 1970-01-01
    • 2017-12-15
    • 1970-01-01
    • 2013-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多