gstreamer - 如何使用gstreamer从mp4(h264/aac)到mp4(h264/mp​​3)进行转码和调整大小?

标签 gstreamer mp4 h.264 aac gst-launch

我想使用 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

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

最佳答案

@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.

关于gstreamer - 如何使用gstreamer从mp4(h264/aac)到mp4(h264/mp​​3)进行转码和调整大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28036830/

相关文章:

c# - 如何从 mp4 容器中获取 aac 音频? (Windows Phone 7 和 C#)

video-streaming - 使用 gstreamer 通过 rtp 流式传输 H.264 视频

c - 如何向现有管道 GstElement 添加多个过滤器?

h.264 - 将MOOV原子放在MP4文件的开头是否有不利之处?

python - Pocketsphinx + Gstreamer 竞赛条件? Pocketsphinx无法在Python脚本中同时收听音频+录音?

java - 如何在 Android/Java 中为视频添加水印

python - 使用 cv2 时删除 [h264 @ xxx] 错误控制台输出

ffmpeg - RTSP 流的 H.264 解码错误日志

Python + GStreamer - 无法连接

c - Gstreamer-mp3 上的持续时间查询错误