我想使用 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 我想提出两项改进:
- 如果可能,请使用 gstreamer-1
- 您的解决方案读取源文件两次。那没有必要。此外,执行此操作时,音频和视频流不会同步。您可以从 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/mp3)进行转码和调整大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28036830/