解码:(根据码流类型自适应创建相应解码器)
gst-launch-1.0 filesrc location=./home/user/DCIM/Camera/VID_20201001_103749.mov ! qtdemux ! droidvdec ! videoparse format=i420 width=1920 height=1080 framerate=30/1 ! filesink location=test_1920x1080.yuv
将720×1560@rgbx 转换为 1920×1080@I420:
gst-launch-1.0 filesrc location=./test_0323.yuv blocksize=4492800 ! videoparse format=rgbx width=720 height=1560 framerate=30/1 ! videoconvert ! “video/x-raw,format=I420,width=720,height=1560,framerate=30/1” ! videoscale ! “video/x-raw,format=I420,width=1920,height=1080,framerate=30/1” ! filesink location=./test_rgbxToI420.yuv
生成yuv:
gst-launch-1.0 -e videotestsrc ! “video/x-raw,format=I420,width=1920,height=1080,framerate=30/1” ! filesink location=./video_test_1920x1080.yuv
yuv查看:
gst-launch-1.0 filesrc location=./test_1920x1080.yuv blocksize=3110400 ! “video/x-raw, format=I420,width=1920,height=1080,framerate=30/1” ! videoparse format=i420 width=1920 height=1080 ! autovideosink
编码:
将YUV编码生成裸码流(H264):
gst-launch-1.0 filesrc location=test_1920x1080.yuv blocksize=3110400 ! “video/x-raw,format=I420,width=1920,height=1080,framerate=30/1” ! droidvenc ! “video/x-h264,stream-format=avc,alignment=au,width=1920,height=1080,framerate=30/1” ! h264parse ! “video/x-h264, stream-format=byte-stream” ! filesink location=test1.h264
将YUV编码生成avi文件(H264):
gst-launch-1.0 filesrc location=test_1920x1080.yuv blocksize=3110400 ! “video/x-raw,format=I420,width=1920,height=1080,framerate=30/1” ! droidvenc ! “video/x-h264,stream-format=avc,alignment=au,width=1920,height=1080,framerate=30/1” ! h264parse ! “video/x-h264, stream-format=byte-stream” ! avimux ! filesink location=./test1.avi
将YUV编码生成裸码流(H265):
gst-launch-1.0 filesrc location=test_1920x1080.yuv blocksize=3110400 ! “video/x-raw,format=I420,width=1920,height=1080,framerate=30/1” ! droidvenc ! “video/x-h265,stream-format=hvc1,alignment=au,width=1920,height=1080,framerate=30/1” ! h265parse ! “video/x-h265, stream-format=byte-stream” ! filesink location=test1.h265
将YUV编码生成MP4文件(H265):
gst-launch-1.0 filesrc location=test_1920x1080.yuv ! videoparse format=i420 width=1920 height=1080 framerate=30/1 ! droidvenc ! “video/x-h265,stream-format=hvc1,alignment=au,width=1920,height=1080,framerate=30/1” ! h265parse ! “video/x-h265, stream-format=hvc1” ! qtmux ! filesink location= test.mp4
生成avi
gst-launch-1.0 -e videotestsrc ! “video/x-raw,format=I420,width=320,height=240,framerate=30/1” ! avenc_mpeg4 ! mpeg4videoparse ! avmux_mp4 ! filesink location=./0523_test1.avi
gst-launch-1.0 -e videotestsrc ! “video/x-raw,format=I420,width=320,height=240,framerate=30/1” ! avenc_mpeg2video ! mpegvideoparse ! avmux_mpegts ! filesink location=./0523_test1.ts
编码生成ts文件(视频)
gst-launch-1.0 -e videotestsrc ! “video/x-raw,format=I420,width=320,height=240,framerate=30/1” ! droidvenc ! “video/x-h264,stream-format=avc,alignment=au,width=320,height=240,framerate=30/1” ! h264parse ! “video/x-h264, stream-format=byte-stream”! avmux_mpegts ! filesink location=./0523_test1.ts
编码生成ts文件(视频+音频)
gst-launch-1.0 -e videotestsrc ! “video/x-raw,format=I420,width=320,height=240,framerate=30/1” ! queue ! droidvenc ! “video/x-h264,stream-format=avc,alignment=au,width=320,height=240,framerate=30/1”
! h264parse ! “video/x-h264, stream-format=byte-stream”! mux. audiotestsrc ! avenc_aac ! queue ! mux. avmux_mpegts name=mux ! filesink location=./0523_test1.ts
camera:
将采集的yuv数据编码封装成avi文件:
gst-launch-1.0 droidcamsrc ! capsfilter ! “video/x-raw,format=NV21,width=1920,height=1080,framerate=30/1” ! videoparse format=i420 width=1920 height=1080 framerate=30/1 ! queue ! droidvenc ! “video/x-h264,stream-format=avc,alignment=au,width=1920,height=1080,framerate=30/1” ! h264parse ! “video/x-h264, stream-format=byte-stream” ! mux. pulsesrc !capsfilter ! “audio/x-raw,format=U8,channels=1,width=8,depth=8,rate=8000,signed=TRUE”! mux. avimux name=mux filesink location= test.avi
将采集的yuv数据编码封装成MP4文件:
gst-launch-1.0 -e droidcamsrc ! capsfilter ! “video/x-raw,format=NV21,width=1920,height=1080,framerate=30/1” ! videoparse format=i420 width=1920 height=1080 framerate=30/1 ! queue ! droidvenc ! “video/x-h264,stream-format=avc,alignment=au,width=1920,height=1080,framerate=30/1” ! h264parse ! “video/x-h264, stream-format=avc” ! mux. pulsesrc ! “audio/x-raw,format=U8,channels=1,width=8,depth=8,rate=8000,signed=TRUE” ! queue ! mux. qtmux name=mux ! filesink location= test.mp4
将采集的yuv数据编码封装成MP4文件(H265):
gst-launch-1.0 -e droidcamsrc ! capsfilter ! “video/x-raw,format=NV21,width=1920,height=1080,framerate=30/1” ! videoparse format=i420 width=1920 heig
ht=1080 framerate=30/1 ! queue ! droidvenc ! “video/x-h265,stream-format=hvc1,alignment=au,width=1920,height=1080,framerate=30/1” ! h265parse ! “video/x-h265, stream-fo
rmat=hvc1″ ! mux. pulsesrc ! “audio/x-raw,format=U8,channels=1,width=8,depth=8,rate=8000,signed=TRUE” ! queue ! mux. qtmux name=mux ! filesink location= test.mp4
音频:
播放MP3音频文件
gst-launch-1.0 filesrc location=./so/video/Test_videos_and_audios/Test_audio/daoxiang.mp3 ! decodebin ! pulsesink
gst-launch-1.0 filesrc location=./so/video/Test_videos_and_audios/Test_audio/daoxiang.mp3 ! mpegaudioparse ! avdec_mp3 ! autoaudiosink
编码生成音频文件
gst-launch-1.0 -e pulsesrc ! wavenc ! queue ! filesink location=test.wav
播放包含原始音频数据 (PCM) 的 .WAV 文件
gst-launch-1.0 filesrc location=test.wav ! wavparse ! audioconvert ! audioresample ! autoaudiosink
将pcm编码成aac文件
gst-launch-1.0 -e audiotestsrc ! audio/x-raw, channels=2, rate=44100, format=S16LE, layout=interleaved ! queue ! audiorate ! audioconvert ! avenc_aac ! qtmux ! filesink location=/home/user/test.aac
RTP(video)
gst-launch-1.0 -e videotestsrc ! “video/x-raw,format=I420,width=320,height=240,framerate=30/1” ! droidvenc ! “video/x-h264,stream-format=avc,alignment=au,width=320,height=240,framerate=30/1” ! h264p
arse ! “video/x-h264, stream-format=byte-stream” ! avmux_mpegts ! “video/mpegts,systemstream=true” ! rtpmp2tpay ! udpsink name=sink host=172.16.23.27 port=7236
gst-launch-1.0 -e videotestsrc ! “video/x-raw,format=I420,width=320,height=240,framerate=30/1” ! avenc_mpeg2video ! mpegvideoparse ! avmux_mpegts ! “video/mpegts,systemstream=true” ! rtpmp2tpay ! udpsink name=sink host=172.16.23.27 port=7236
RTP(video + audio)
gst-launch-1.0 -e videotestsrc ! “video/x-raw,format=I420,width=320,height=240,framerate=30/1” ! queue ! droidvenc ! “video/x-h264,stream-format=avc,alignment=au,width=320,height=240,framerate=30/1”
! h264parse ! “video/x-h264, stream-format=byte-stream”! mux. audiotestsrc ! avenc_aac ! queue ! mux. avmux_mpegts name=mux ! “video/mpegts,systemstream=true” ! rtpmp2tpay ! udpsink name=sink host=172.16.23.27 port=7236