2

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

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

4

2 回答 2

2

@Lionel.JI 想提出两项改进:

  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.
于 2016-03-19T18:13:18.360 回答
1

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

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.`
于 2015-01-27T02:20:04.043 回答