Gstreamer cmd

Gstreamer cmd

社蕙 735 2022-10-10

Ubuntu下编译

# generate executable file
aarch64-linux-gnu-gcc  -Igstupsamplingfilter@sha -I. -I.. -I/usr/include/gstreamer-1.0 -I/usr/lib/x86_64-linux-gnu/gstreamer-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -fPIC -pthread -DHAVE_CONFIG_H -MMD -MQ 'gstupsamplingfilter@sha/gstupsamplingfilter.c.o' -MF 'gstupsamplingfilter@sha/gstupsamplingfilter.c.o.d' -o 'gstupsamplingfilter@sha/gstupsamplingfilter.c.o' -c ../gstupsamplingfilter.c

# generate dynamic link library
aarch64-linux-gnu-gcc  --sysroot=/home/riscv/Desktop/gst-lib-aarch64 -o libgstupsamplingfilter.so 'gstupsamplingfilter@sha/gstupsamplingfilter.c.o' -Wl,--no-undefined -Wl,--as-needed -shared -fPIC -Wl,--start-group -Wl,-soname,libgstupsamplingfilter.so -Lsysroot/usr/lib   -lgstvideo-1.0 -lgstbase-1.0 -lgstreamer-1.0 -lgobject-2.0  -lglib-2.0 -Wl,--end-group '-Wl,-rpath,$ORIGIN/' -Wl,-rpath-link,/home/riscv/Desktop/gst-plugin-upsampling-master/build/ 

# delete previous dynamic link library
sudo rm /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstupsamplingfilter.so 

# copy new dynamic link library to file library
sudo cp ./libgstupsamplingfilter.so  /usr/lib/x86_64-linux-gnu/gstreamer-1.0/ 

片上测试

# gst pipeline application

gst-launch-1.0 filesrc location=./output/video/test_1k.mp4  ! decodebin ! videoconvert ! capsfilter caps=video/x-raw,format=BGR,width=960,height=540 ! upsamplingfilter ! capsfilter caps=video/x-raw,format=BGR ! videoconvert ! autovideosink

GST_DEBUG_FILE=pipeline.log GST_DEBUG=2 gst-launch-1.0 filesrc location=./output/video/test_1k.mp4  ! decodebin ! videoconvert ! capsfilter caps=video/x-raw,format=BGR,width=960,height=540 ! upsamplingfilter ! capsfilter caps=video/x-raw,format=BGR !  videoconvert ! xvimagesink

gst-launch-1.0 filesrc location=./output/video/test_1k.mp4  ! decodebin ! videoconvert ! videorate ! capsfilter caps=video/x-raw,framerate=1/10 ! upsamplingfilter ! capsfilter caps=video/x-raw,format=BGR ! videoconvert ! autovideosink

实际使用

# 片上初始化

. /media/card/init.sh
insmod ./driver/axidma.ko
GST_PLUGIN_PATH=./lib/
export GST_PLUGIN_PATH

gst-launch-1.0 filesrc location=/media/usb/apex_1k.mp4  \
! decodebin ! videoconvert \
! capsfilter caps=video/x-raw,format=BGR,width=960,height=540,framerate=30/1 \
! upsamplingfilter \
! capsfilter caps=video/x-raw,format=BGR,framerate=30/1 ! videoconvert \
! omxh264enc target-bitrate=10000 control-rate=low-latency \
! filesink location=/media/usb/apex_2k_up.mp4

gst-launch-1.0 filesrc location=/media/usb/apex_1k.mp4  \
! decodebin ! videoconvert \
! capsfilter caps=video/x-raw,format=BGR,width=960,height=540,framerate=30/1 \
! upsamplingfilter \
! capsfilter caps=video/x-raw,format=BGR,framerate=30/1 ! videoconvert \
! jpegenc ! multifilesink location=/media/usb/frames/apex-%04d.jpg

gst-launch-1.0 filesrc location=/media/usb/film_1k.mp4  \
! decodebin ! videoconvert \
! capsfilter caps=video/x-raw,format=BGR,width=960,height=540,framerate=30/1 \
! upsamplingfilter \
! capsfilter caps=video/x-raw,format=BGR,framerate=30/1 ! videoconvert \
! jpegenc ! multifilesink location=/media/usb/frames/film-%04d.jpg

# 后处理

gst-launch-1.0 multifilesrc location=~/gst_tutorial/frames/apex-%04d.jpg caps="image/jpeg,framerate=30/1" \
! jpegdec ! videoconvert ! x264enc ! mp4mux \
! filesink location=~/gst_tutorial/apex_up.mp4

其他Ubuntu下的命令

# 1 mp4 to jpg
gst-launch-1.0 filesrc location=~/Desktop/gstreamer/test_video/test_1k.mp4  ! decodebin ! videoconvert ! jpegenc ! multifilesink location=~/Desktop/gstreamer/mp4tojpg/%05d.jpg

# 2 mp4 to bgr to jpeg

gst-launch-1.0 filesrc location=~/Desktop/gstreamer/test_video/test_1k.mp4  ! decodebin ! videoconvert ! video/x-raw,format=BGR,width=960,height=540 ! jpegenc ! multifilesink location=~/Desktop/gstreamer/mp4tobgrtojpg/%05d.jpg

# 3 mp4 to bgr to jpeg to mp4

gst-launch-1.0 filesrc location=~/Desktop/gstreamer/test_video/test_1k.mp4  ! decodebin ! videoconvert ! capsfilter caps=video/x-raw,format=BGR ! jpegenc ! jpegdec ! videoconvert ! x264enc ! mp4mux ! filesink location=~/Desktop/gstreamer/mp4tobgrtojpgtomp4/test_out_3.mp4

# 4 mp4 to bgr to mp4

gst-launch-1.0 filesrc location=~/Desktop/gstreamer/test_video/test_1k.mp4  ! decodebin ! videoconvert ! capsfilter caps=video/x-raw,format=BGR,width=960,height=540 !  capsfilter caps=video/x-raw,format=BGR,width=960,height=540 ! videoconvert ! x264enc ! mp4mux ! filesink location=~/Desktop/gstreamer/mp4tobgrtomp4/test_out_4.mp4

# 5 mp4 to bgr to upsampling_official to bgr to mp4

gst-launch-1.0 filesrc location=~/Desktop/gstreamer/test_video/test_1k.mp4  ! decodebin ! videoconvert ! capsfilter caps=video/x-raw,format=BGR,width=960,height=540 ! videoscale !  capsfilter caps=video/x-raw,format=BGR,width=1920,height=1080 ! videoconvert ! x264enc ! mp4mux ! filesink location=~/Desktop/gstreamer/mp4tobgrtoupscaletomp4/test_out_5.mp4


# 6 mp4 to bgr to upsampling_official to bgr to display

gst-launch-1.0 filesrc location=~/Desktop/gstreamer/test_video/test_1k.mp4  ! decodebin ! videoconvert ! capsfilter caps=video/x-raw,format=BGR,width=960,height=540 ! videoscale !  capsfilter caps=video/x-raw,format=BGR,width=960,height=540 ! videoconvert ! autovideosink

gst-launch-1.0 filesrc location=~/Desktop/gstreamer/test_video/test_1k.mp4  ! decodebin ! videoconvert ! capsfilter caps=video/x-raw,format=BGR,width=960,height=540 !  MyFilter ! videoconvert ! autovideosink

# 7. replace the videoscale with the upsampling_filter