Forked from liviaerxin/gstreamer_pipeline_samples.md
Created
December 9, 2022 01:49
-
-
Save snowicepeng/2d088f456987aeb339fedc7720a39a8f to your computer and use it in GitHub Desktop.
Revisions
-
liviaerxin revised this gist
Oct 19, 2022 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -90,18 +90,22 @@ gst-launch-1.0 -vvv videotestsrc ! videoconvert ! fpsdisplaysink text-overlay=fa ### record to file ```sh gst-launch-1.0 -vv videotestsrc ! x264enc ! flvmux ! filesink location=xyz.flv gst-launch-1.0 -vv videotestsrc ! x264enc ! qtmux ! filesink location=xyz.mp4 -e ``` ### record and display at the same time(queue) [GStreamer Recording and Viewing Stream Simultaneously](https://stackoverflow.com/questions/37444615/gstreamer-recording-and-viewing-stream-simultaneously) ```sh gst-launch-1.0 -vvv videotestsrc \ ! tee name=t \ t. ! queue ! x264enc ! mp4mux ! filesink location=xyz.mp4 -e \ t. ! queue leaky=1 ! autovideosink sync=false ``` **tips:** @@ -111,21 +115,25 @@ t. ! queue leaky=1 ! autovideosink sync=false ### record webcam to `*.mp4`(jetson nano) ```sh gst-launch-1.0 nvarguscamerasrc ! fakesink gst-launch-1.0 nvarguscamerasrc num-buffers=2000 ! 'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1, format=NV12' ! omxh264enc ! qtmux ! filesink location=test.mp4 -e gst-launch-1.0 nvarguscamerasrc num-buffers=2000 ! 'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1, format=NV12' ! nvvidconv ! x264enc ! qtmux ! filesink location=test.mp4 -e ``` ### fps test ```sh gst-launch-1.0 -v videotestsrc ! videorate ! video/x-raw,framerate=30/1 ! videoconvert ! autovideosink gst-launch-1.0 -v videotestsrc ! videorate ! video/x-raw,framerate=30/1 ! x264enc tune=zerolatency bitrate=16000000 speed-preset=superfast ! rtph264pay ! udpsink port=5000 host=$HOST gst-launch-1.0 -v videotestsrc ! videorate ! video/x-raw,framerate=60/1 ! x264enc tune=zerolatency bitrate=16000000 speed-preset=superfast ! h264parse ! rtph264pay ! udpsink port=5000 host=$HOST gst-launch-1.0 -v videotestsrc ! video/x-raw,framerate=30/1 ! videorate ! video/x-raw,framerate=60/1 ! x264enc tune=zerolatency bitrate=16000000 speed-preset=superfast ! rtph264pay ! udpsink port=5000 host=$HOST ``` ## Audio -
liviaerxin revised this gist
Oct 19, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -496,7 +496,7 @@ gcc test-launch.c -o test-launch $(pkg-config --cflags --libs gstreamer-1.0 gstr ```sh # server ./test-launch "nvarguscamerasrc ! video/x-raw(memory:NVMM), format=NV12, width=1920, height=1080, framerate=30/1 ! nvvidconv ! video/x-raw, width=640, height=480, format=NV12, framerate=30/1 ! omxh265enc ! rtph265pay name=pay0 pt=96 config-interval=1" # client gst-launch-1.0 rtspsrc location=rtsp://jetson-desktop.local:8554/test ! decodebin ! videoconvert ! autovideosink -
liviaerxin revised this gist
Jul 28, 2022 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -236,7 +236,7 @@ HOST=192.168.31.175 [//]: # (destination receiving the stream) ### Video RTP Streaming - sender #### send a test video with h264 rtp stream @@ -303,6 +303,8 @@ gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM),width=19 t. ! queue ! qtmux ! filesink location=test.mp4 -e ``` - receiver #### receive h264 rtp stream(desktop host) ```sh -
liviaerxin revised this gist
Apr 19, 2022 . 1 changed file with 26 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,9 @@ # Gstreamer Pipeline Samples Table of Contents: - [Gstreamer Pipeline Samples](#gstreamer-pipeline-samples) - [Tips for Debug](#tips-for-debug) - [Video](#video) - [display test video](#display-test-video) - [record to file](#record-to-file) @@ -40,36 +45,38 @@ - [h264 encode/decode](#h264-encodedecode) - [python-opencv](#python-opencv) Get great help from below references: - [Stream H.264 video over rtp using gstreamer](https://stackoverflow.com/questions/17313985/stream-h-264-video-over-rtp-using-gstreamer) - [Implementing GStreamer Webcam(USB & Internal) Streaming[Mac & C++ & CLion]](https://medium.com/lifesjourneythroughalens/implementing-gstreamer-webcam-usb-internal-streaming-mac-c-clion-76de0fdb8b34) - [GStreamer command-line cheat sheet](https://github.com/matthew1000/gstreamer-cheat-sheet) - [Example GStreamer Pipelines](http://labs.isee.biz/index.php/Example_GStreamer_Pipelines#Decode_Audio_Files) - [Gstreamer real life examples](http://4youngpadawans.com/gstreamer-real-life-examples/) ## Tips for Debug - Set general debug level ```sh export GST_DEBUG=6 #5 export GST_DEBUG=GST_REGISTRY:6,GST_PLUGIN:6 ``` - Discover video file ```sh gst-discoverer-1.0 -v fat_bunny.ogg ``` - Inspect plugin ```sh gst-inspect-1.0 avdec_h264 ``` ## Video -
liviaerxin revised this gist
Apr 19, 2022 . 1 changed file with 81 additions and 81 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -497,92 +497,92 @@ gst-launch-1.0 rtspsrc location=rtsp://jetson-desktop.local:8554/test ! decodeb 1. video ```sh # server ./test-launch "filesrc location=/home/jetson/Videos/why_I_left_China_for_Good.mp4 \ ! qtdemux \ ! h264parse \ ! decodebin \ ! videoconvert \ ! omxh264enc insert-sps-pps=true bitrate=16000000 \ ! rtph264pay name=pay0" # client gst-launch-1.0 -v rtspsrc location=rtsp://jetson-desktop.local:8554/test \ ! rtph264depay \ ! h264parse \ ! decodebin \ ! videoconvert \ ! autovideosink sync=false ``` 2. audio ```sh # server ./test-launch "filesrc location=/home/jetson/Videos/why_I_left_China_for_Good.mp4 \ ! qtdemux \ ! aacparse \ ! decodebin \ ! audioconvert \ ! avenc_aac \ ! rtpmp4apay name=pay0" # client gst-launch-1.0 -v rtspsrc location=rtsp://jetson-desktop.local:8554/test \ ! rtpmp4adepay \ ! aacparse \ ! decodebin \ ! audioconvert \ ! autoaudiosink sync=false ``` 3. video + audio h264 + acc, ```sh # server ./test-launch "filesrc location=/home/jetson/Videos/why_I_left_China_for_Good.mp4 \ ! qtdemux name=demux \ demux. ! queue ! h264parse ! decodebin ! omxh264enc insert-sps-pps=true bitrate=16000000 ! rtph264pay name=pay0 \ demux. ! queue ! aacparse ! decodebin ! audioconvert ! avenc_aac ! rtpmp4apay name=pay1" # client gst-launch-1.0 -v rtspsrc location=rtsp://jetson-desktop.local:8554/test name=src \ src. ! rtph264depay ! h264parse ! decodebin ! videoconvert ! autovideosink sync=false \ src. ! rtpmp4adepay ! aacparse ! decodebin ! audioconvert ! autoaudiosink sync=false # client(short) gst-launch-1.0 -v rtspsrc location=rtsp://jetson-desktop.local:8554/test name=src \ src. ! decodebin ! videoconvert ! autovideosink sync=false \ src. ! decodebin ! audioconvert ! autoaudiosink sync=false ``` mpegts, ```sh # server ./test-launch "filesrc location=/home/jetson/Videos/why_I_left_China_for_Good.mp4 \ ! qtdemux name=demux mpegtsmux name=mux alignment=7 \ ! rtpmp2tpay name=pay0 demux. \ ! queue ! h264parse ! decodebin ! omxh264enc insert-sps-pps=true bitrate=16000000 ! mux. demux. \ ! queue ! aacparse ! decodebin ! audioconvert ! avenc_aac ! mux." # client gst-launch-1.0 -v rtspsrc location=rtsp://jetson-desktop.local:8554/test \ ! rtpmp2tdepay ! tsparse ! tsdemux name=demux \ demux. ! queue ! decodebin ! videoconvert ! fpsdisplaysink text-overlay=false sync=false \ demux. ! queue leaky=1 ! decodebin ! audioconvert ! autoaudiosink sync=false # client(only video) gst-launch-1.0 -v rtspsrc location=rtsp://jetson-desktop.local:8554/test name=src \ src. ! rtpmp2tdepay ! tsparse ! tsdemux name=demux ! h264parse ! avdec_h264 ! videoconvert ! autovideosink sync=false # client(only audio) gst-launch-1.0 -v rtspsrc location=rtsp://jetson-desktop.local:8554/test \ ! rtpmp2tdepay ! tsparse ! tsdemux name=demux ! aacparse ! decodebin ! audioconvert ! autoaudiosink sync=false ``` ## Mixing -
liviaerxin revised this gist
Apr 19, 2022 . No changes.There are no files selected for viewing
-
liviaerxin revised this gist
Apr 19, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ - [send a screen capture with h264 rtp stream(osx)](#send-a-screen-capture-with-h264-rtp-streamosx) - [send a `*.mp4` file with h264 rtp stream](#send-a-mp4-file-with-h264-rtp-stream) - [send a webcam with h264 rtp stream(jetson nano)](#send-a-webcam-with-h264-rtp-streamjetson-nano) - [send a webcam with h264 rtp stream while record (jetson nano)](#send-a-webcam-with-h264-rtp-stream-while-record-jetson-nano) - [receive h264 rtp stream(desktop host)](#receive-h264-rtp-streamdesktop-host) - [Audio RTP Streaming](#audio-rtp-streaming) - [raw audio](#raw-audio) @@ -287,7 +287,7 @@ gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1920, height=1 ``` #### send a webcam with h264 rtp stream while record (jetson nano) ```sh gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1, format=NV12' ! nvvidconv flip-method=2 ! omxh264enc insert-sps-pps=true bitrate=16000000 \ -
liviaerxin revised this gist
Apr 19, 2022 . No changes.There are no files selected for viewing
-
liviaerxin revised this gist
Apr 19, 2022 . No changes.There are no files selected for viewing
-
liviaerxin revised this gist
Apr 19, 2022 . No changes.There are no files selected for viewing
-
liviaerxin revised this gist
Apr 19, 2022 . No changes.There are no files selected for viewing
-
liviaerxin revised this gist
Apr 19, 2022 . 1 changed file with 11 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,8 @@ - [send a screen capture with h264 rtp stream(osx)](#send-a-screen-capture-with-h264-rtp-streamosx) - [send a `*.mp4` file with h264 rtp stream](#send-a-mp4-file-with-h264-rtp-stream) - [send a webcam with h264 rtp stream(jetson nano)](#send-a-webcam-with-h264-rtp-streamjetson-nano) - [send a webcam with h264 rtp stream while record (jetson nano)](#send-a-webcam-with-h264-rtp-stream-while-record-jetson-nano) - [receive h264 rtp stream(desktop host)](#receive-h264-rtp-streamdesktop-host) - [Audio RTP Streaming](#audio-rtp-streaming) - [raw audio](#raw-audio) - [encoded/decoded audio](#encodeddecoded-audio) @@ -286,9 +287,16 @@ gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1920, height=1 ``` ### send a webcam with h264 rtp stream while record (jetson nano) ```sh gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1, format=NV12' ! nvvidconv flip-method=2 ! omxh264enc insert-sps-pps=true bitrate=16000000 \ ! tee name=t \ t. ! queue ! rtph264pay ! udpsink port=5000 host=$OSX_HOST \ t. ! queue ! qtmux ! filesink location=test.mp4 -e ``` #### receive h264 rtp stream(desktop host) ```sh # display -
liviaerxin revised this gist
Apr 19, 2022 . 1 changed file with 6 additions and 20 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -51,7 +51,6 @@ [Gstreamer real life examples](http://4youngpadawans.com/gstreamer-real-life-examples/) Set general debug level, ```sh @@ -73,7 +72,6 @@ gst-inspect-1.0 avdec_h264 ## Video ### display test video ```sh @@ -100,10 +98,9 @@ t. ! queue leaky=1 ! autovideosink sync=false **tips:** 1. `-e (EOS signal)`: Pipelines for file saving require a reliable EOS(End of Stream) signal 2. `queue leaky=1 ! autovideosink sync=false`: prevent blocking 3. `drop=true`: drop frame if cannot read quickly enough ### record webcam to `*.mp4`(jetson nano) gst-launch-1.0 nvarguscamerasrc ! fakesink @@ -112,7 +109,6 @@ gst-launch-1.0 nvarguscamerasrc num-buffers=2000 ! 'video/x-raw(memory:NVMM),wid gst-launch-1.0 nvarguscamerasrc num-buffers=2000 ! 'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1, format=NV12' ! nvvidconv ! x264enc ! qtmux ! filesink location=test.mp4 -e ### fps test gst-launch-1.0 -v videotestsrc ! videorate ! video/x-raw,framerate=30/1 ! videoconvert ! autovideosink @@ -158,7 +154,7 @@ gst-launch-1.0 -v -e videotestsrc \ videotestsrc --> x264enc -----\ >---> mp4mux ---> filesink audiotestsrc --> lamemp3enc --/ ## Media File @@ -226,14 +222,12 @@ gst-launch-1.0 -v filesrc location=/Users/siyao/Movies/why_I_left_China_for_Good ``` ## Network streaming HOST=192.168.31.175 [//]: # (destination receiving the stream) ### Video RTP Streaming 1. sender #### send a test video with h264 rtp stream @@ -315,13 +309,14 @@ t. ! queue leaky=1 ! decodebin ! videoconvert ! autovideosink sync=false ``` > **tips**: > > 1. `sync=false`: remove dropped frame rate, lag and error message(`There may be a timestamping problem, or this computer is too slow`). see the [Streaming RTP/RTSP: sync/timestamp problems](https://stackoverflow.com/questions/11397655/streaming-rtp-rtsp-sync-timestamp-problems) for details. > 2. `udpsrc port=5000 cap='application/x-rtp'`: will set the remaining properties to default. ### Audio RTP Streaming #### raw audio ```sh # sender gst-launch-1.0 audiotestsrc \ @@ -358,7 +353,6 @@ gst-launch-1.0 -v udpsrc port=5001 \ ! autoaudiosink sync=false ``` ### Audio + Video RTP Streaming ```sh @@ -428,8 +422,6 @@ gst-launch-1.0 -v \ ! rtpac3depay ! decodebin ! audioconvert ! autoaudiosink sync=false ``` #### remux to MPEGST(best) It has several advantages like good re-synchronization after packet loss and that A/V always stays sync @@ -470,7 +462,6 @@ gst-launch-1.0 -v -e udpsrc port=5000 caps="application/x-rtp" \ > `tsdemux demux.video_0` not work, see the details belowing: > You're using a name (video_0) that doesn't exist. The pad names of demuxers vary from demuxer to demuxer, and might sometimes also differ from version to version. In this case that first video pad is called video_0031 as you can see at the end. It's generally best not to specify pad names unless you have a good reason to do so. ### RTSP Server #### install server(jetson nano) @@ -676,8 +667,7 @@ gst-launch-1.0 \ ``` > **tips** > for jetson nano, use `nvvidconv` instead of `videoconvert` because `decodebin` use `nvv4l2decoder` to decode H.264 in default. Otherwise, explictly decode H.264 with `omxh264dec`. receiver, @@ -692,8 +682,6 @@ gst-launch-1.0 -v udpsrc port=5000 caps="application/x-rtp" \ ## SHM(Shared Memory) ### raw video ```sh @@ -704,8 +692,8 @@ gst-launch-1.0 -v videotestsrc is-live=true ! 'video/x-raw,width=1280,height=720 gst-launch-1.0 -v shmsrc do-timestamp=true socket-path=/tmp/foo name=/tmp/shm ! 'video/x-raw,width=1280,height=720,format=(string)RGB,framerate=(fraction)60/1' ! videoconvert ! fpsdisplaysink text-overlay=false sync=false -e ``` **tips:** 1. `do-timestamp=true`: solve `gst_segment_to_stream_time: assertion 'segment->format == format' failed` error. Seeing at[Getting shmsink/shmsrc to work with videomixer](https://mazdermind.wordpress.com/2014/08/29/getting-shmsinkshmsrc-to-work-with-videomixer/) 2. In local host, use `raw video` faster than `h264` due to memory cheaper/faster that cpu 3. increase `shm-size` for large image @@ -722,8 +710,6 @@ gst-launch-1.0 -v videotestsrc ! 'video/x-raw,width=1280,height=720,format=NV12, gst-launch-1.0 -v shmsrc socket-path=/tmp/foo ! h264parse ! decodebin ! videoconvert ! fpsdisplaysink text-overlay=false sync=false ``` ## python-opencv ```py -
liviaerxin revised this gist
Aug 11, 2020 . No changes.There are no files selected for viewing
-
liviaerxin revised this gist
Aug 11, 2020 . 1 changed file with 16 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -52,15 +52,28 @@ [Gstreamer real life examples](http://4youngpadawans.com/gstreamer-real-life-examples/) Set general debug level, ```sh export GST_DEBUG=6 #5 export GST_DEBUG=GST_REGISTRY:6,GST_PLUGIN:6 ``` Discover video file, ```sh gst-discoverer-1.0 -v fat_bunny.ogg ``` Inpsect plugin, ```sh gst-inspect-1.0 avdec_h264 ``` ## Video ### display test video ```sh -
liviaerxin revised this gist
Jul 23, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -271,7 +271,7 @@ gst-launch-1.0 -v filesrc location=test.mp4 ! qtdemux ! h264parse ! rtph264pay ! gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1280, height=720, framerate=60/1, format=NV12' ! nvvidconv ! x264enc bitrate=16000000 speed-preset=superfast ! rtph264pay ! udpsink port=5000 host=$HOST !!fast gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1, format=NV12' ! nvvidconv flip-method=2 ! nvv4l2h264enc insert-sps-pps=true bitrate=16000000 ! rtph264pay ! udpsink port=5000 host=$HOST gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1, format=NV12' ! omxh264enc insert-sps-pps=true bitrate=16000000 ! rtph264pay ! udpsink port=5000 host=$HOST -
liviaerxin revised this gist
Jul 23, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -271,7 +271,7 @@ gst-launch-1.0 -v filesrc location=test.mp4 ! qtdemux ! h264parse ! rtph264pay ! gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1280, height=720, framerate=60/1, format=NV12' ! nvvidconv ! x264enc bitrate=16000000 speed-preset=superfast ! rtph264pay ! udpsink port=5000 host=$HOST !!fast gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1, format=NV12' ! nvv4l2h264enc insert-sps-pps=true bitrate=16000000 ! rtph264pay ! udpsink port=5000 host=$HOST gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1, format=NV12' ! omxh264enc insert-sps-pps=true bitrate=16000000 ! rtph264pay ! udpsink port=5000 host=$HOST -
liviaerxin revised this gist
Jul 23, 2020 . No changes.There are no files selected for viewing
-
liviaerxin revised this gist
Jul 23, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -271,7 +271,7 @@ gst-launch-1.0 -v filesrc location=test.mp4 ! qtdemux ! h264parse ! rtph264pay ! gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1280, height=720, framerate=60/1, format=NV12' ! nvvidconv ! x264enc bitrate=16000000 speed-preset=superfast ! rtph264pay ! udpsink port=5000 host=$HOST !!fast gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1280, height=720, framerate=60/1, format=NV12' ! nvv4l2h264enc insert-sps-pps=true bitrate=16000000 ! rtph264pay ! udpsink port=5000 host=$HOST gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1, format=NV12' ! omxh264enc insert-sps-pps=true bitrate=16000000 ! rtph264pay ! udpsink port=5000 host=$HOST -
liviaerxin revised this gist
Jul 23, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -271,7 +271,7 @@ gst-launch-1.0 -v filesrc location=test.mp4 ! qtdemux ! h264parse ! rtph264pay ! gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1280, height=720, framerate=60/1, format=NV12' ! nvvidconv ! x264enc bitrate=16000000 speed-preset=superfast ! rtph264pay ! udpsink port=5000 host=$HOST !!fast gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1280, height=720, framerate=60/1, format=I420' ! nvv4l2h264enc insert-sps-pps=true bitrate=16000000 ! rtph264pay ! udpsink port=5000 host=$HOST gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1, format=NV12' ! omxh264enc insert-sps-pps=true bitrate=16000000 ! rtph264pay ! udpsink port=5000 host=$HOST -
liviaerxin revised this gist
Jul 23, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -271,7 +271,7 @@ gst-launch-1.0 -v filesrc location=test.mp4 ! qtdemux ! h264parse ! rtph264pay ! gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1280, height=720, framerate=60/1, format=NV12' ! nvvidconv ! x264enc bitrate=16000000 speed-preset=superfast ! rtph264pay ! udpsink port=5000 host=$HOST !!fast gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1280, height=720, framerate=60/1, format=NV12' ! nvv4l2h264enc insert-sps-pps=true bitrate=16000000 ! rtph264pay ! udpsink port=5000 host=$HOST gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1, format=NV12' ! omxh264enc insert-sps-pps=true bitrate=16000000 ! rtph264pay ! udpsink port=5000 host=$HOST -
liviaerxin revised this gist
Jul 23, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -271,7 +271,7 @@ gst-launch-1.0 -v filesrc location=test.mp4 ! qtdemux ! h264parse ! rtph264pay ! gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1280, height=720, framerate=60/1, format=NV12' ! nvvidconv ! x264enc bitrate=16000000 speed-preset=superfast ! rtph264pay ! udpsink port=5000 host=$HOST !!fast gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1280, height=720, framerate=60/1, format=I420' ! nvv4l2h264enc insert-sps-pps=true bitrate=16000000 ! rtph264pay ! udpsink port=5000 host=$HOST gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1, format=NV12' ! omxh264enc insert-sps-pps=true bitrate=16000000 ! rtph264pay ! udpsink port=5000 host=$HOST -
liviaerxin revised this gist
Jul 23, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -271,7 +271,7 @@ gst-launch-1.0 -v filesrc location=test.mp4 ! qtdemux ! h264parse ! rtph264pay ! gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1280, height=720, framerate=60/1, format=NV12' ! nvvidconv ! x264enc bitrate=16000000 speed-preset=superfast ! rtph264pay ! udpsink port=5000 host=$HOST !!fast gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1280, height=720, framerate=60/1, format=I420' ! omxh264enc insert-sps-pps=true bitrate=16000000 ! rtph264pay ! udpsink port=5000 host=$HOST gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1, format=NV12' ! omxh264enc insert-sps-pps=true bitrate=16000000 ! rtph264pay ! udpsink port=5000 host=$HOST -
liviaerxin revised this gist
Jul 17, 2020 . 1 changed file with 13 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,7 @@ - [Audio + Video RTP Streaming](#audio--video-rtp-streaming) - [Media File RTP Streaming](#media-file-rtp-streaming) - [demux and split video and audio(not best)](#demux-and-split-video-and-audionot-best) - [remux to MPEGST(best)](#remux-to-mpegstbest) - [mpegts sender](#mpegts-sender) - [mpegts receiver](#mpegts-receiver) - [RTSP Server](#rtsp-server) @@ -417,7 +417,7 @@ gst-launch-1.0 -v \ #### remux to MPEGST(best) It has several advantages like good re-synchronization after packet loss and that A/V always stays sync @@ -468,14 +468,14 @@ sudo apt-get install libgstrtspserver-1.0 libgstreamer1.0-dev # install gst-rtsp-server test server(1.14 is your gst version, checked by gst-lanch-1.0 --version) wget https://raw.githubusercontent.com/GStreamer/gst-rtsp-server/1.14/examples/test-launch.c gcc test-launch.c -o test-launch $(pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0) ``` #### stream web-cam(jetson nano) ```sh # server ./test-launchh "nvarguscamerasrc ! video/x-raw(memory:NVMM), format=NV12, width=1920, height=1080, framerate=30/1 ! nvvidconv ! video/x-raw, width=640, height=480, format=NV12, framerate=30/1 ! omxh265enc ! rtph265pay name=pay0 pt=96 config-interval=1" # client gst-launch-1.0 rtspsrc location=rtsp://jetson-desktop.local:8554/test ! decodebin ! videoconvert ! autovideosink @@ -487,7 +487,7 @@ gst-launch-1.0 rtspsrc location=rtsp://jetson-desktop.local:8554/test ! decodeb ```sh # server ./test-launch "filesrc location=/home/jetson/Videos/why_I_left_China_for_Good.mp4 \ ! qtdemux \ ! h264parse \ ! decodebin \ @@ -508,7 +508,7 @@ gst-launch-1.0 -v rtspsrc location=rtsp://jetson-desktop.local:8554/test \ ```sh # server ./test-launch "filesrc location=/home/jetson/Videos/why_I_left_China_for_Good.mp4 \ ! qtdemux \ ! aacparse \ ! decodebin \ @@ -628,7 +628,7 @@ gst-launch-1.0 -v \ compositor name=videomix ! omxh264enc bitrate=16000000 ! queue2 ! mux. \ audiomixer name=audiomix ! audioconvert ! audioresample ! avenc_ac3 ! queue2 ! mux. \ filesrc location=$SRC ! qtdemux name=demux \ demux.video_0 ! queue2 ! h264parse ! omxh264dec ! videoconvert ! videomix. \ demux.audio_0 ! queue2 ! decodebin ! audioconvert ! audioresample ! audiomix. \ videotestsrc pattern=ball ! videoscale ! video/x-raw,width=100,height=100 ! videomix. \ audiotestsrc freq=600 volume=0.1 ! audiomix. @@ -639,10 +639,10 @@ gst-launch-1.0 \ ! udpsink port=5000 host=$HOST sync=false \ compositor name=videomix ! x264enc ! queue2 ! mux. \ audiomixer name=audiomix ! audioconvert ! audioresample ! avenc_ac3 ! queue2 ! mux. \ uridecodebin uri=file://$SRC name=dec \ dec. ! queue2 ! audioconvert ! audioresample ! audiomix. \ dec. ! queue2 ! nvvidconv ! videoconvert ! video/x-raw,width=640,height=360 ! videomix. \ videotestsrc pattern=ball ! video/x-raw,width=100,height=100 ! videomix. \ audiotestsrc freq=400 volume=0.2 ! audiomix. ``` @@ -663,7 +663,8 @@ gst-launch-1.0 \ ``` > **tips** > for jetson nano, use `nvvidconv` instead of `videoconvert` because `decodebin` use `nvv4l2decoder` to decode H.264 in default. Otherwise, explictly decode H.264 with `omxh264dec`. receiver, -
liviaerxin revised this gist
Jul 16, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -639,8 +639,8 @@ gst-launch-1.0 \ ! udpsink port=5000 host=$HOST sync=false \ compositor name=videomix ! x264enc ! queue2 ! mux. \ audiomixer name=audiomix ! audioconvert ! audioresample ! avenc_ac3 ! queue2 ! mux. \ uridecodebin uri=file://$SRC name=demux \ demux. ! queue2 ! audioconvert ! audioresample ! audiomix. \ demux. ! queue2 ! decodebin ! nvvidconv ! videoconvert ! videoscale ! video/x-raw,width=640,height=360 ! videomix. \ videotestsrc pattern=ball ! videoscale ! video/x-raw,width=100,height=100 ! videomix. \ audiotestsrc freq=400 volume=0.2 ! audiomix. -
liviaerxin revised this gist
Jul 16, 2020 . 1 changed file with 45 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -606,37 +606,67 @@ gst-launch-1.0 -e compositor name=comp sink_0::alpha=0.7 sink_1::alpha=0.5 \ ### Mixing video+audio sender(mpegts + rtp/udp), ```sh # sender(videotestsrc/audiotestsrc) gst-launch-1.0 -v \ mpegtsmux name=mux alignment=7 ! rtpmp2tpay \ ! udpsink port=5000 host=$HOST sync=false \ compositor name=videomix ! x264enc ! queue ! mux. \ audiomixer name=audiomix ! audioconvert ! audioresample ! avenc_ac3 ! queue ! mux. \ videotestsrc pattern=ball ! videomix. \ videotestsrc pattern=pinwheel ! videoscale ! video/x-raw,width=100 ! videomix. \ audiotestsrc freq=400 ! audiomix. \ audiotestsrc freq=600 ! audiomix. # sender(mp4 file) SRC=/home/jetson/Videos/why_I_left_China_for_Good.mp4 gst-launch-1.0 -v \ mpegtsmux name=mux alignment=7 ! rtpmp2tpay \ ! udpsink port=5000 host=$HOST sync=false \ compositor name=videomix ! omxh264enc bitrate=16000000 ! queue2 ! mux. \ audiomixer name=audiomix ! audioconvert ! audioresample ! avenc_ac3 ! queue2 ! mux. \ filesrc location=$SRC ! qtdemux name=demux \ demux.video_0 ! queue2 ! h264parse ! decodebin ! nvvidconv ! video/x-raw,width=640,height=360 ! videomix. \ demux.audio_0 ! queue2 ! decodebin ! audioconvert ! audioresample ! audiomix. \ videotestsrc pattern=ball ! videoscale ! video/x-raw,width=100,height=100 ! videomix. \ audiotestsrc freq=600 volume=0.1 ! audiomix. # sender(mp4 file) `uridecodebin` gst-launch-1.0 \ mpegtsmux name=mux ! rtpmp2tpay \ ! udpsink port=5000 host=$HOST sync=false \ compositor name=videomix ! x264enc ! queue2 ! mux. \ audiomixer name=audiomix ! audioconvert ! audioresample ! avenc_ac3 ! queue2 ! mux. \ uridecodebin uri=file://$SRC name=demux ! \ queue2 ! audioconvert ! audioresample ! audiomix. \ demux. ! queue2 ! decodebin ! nvvidconv ! videoconvert ! videoscale ! video/x-raw,width=640,height=360 ! videomix. \ videotestsrc pattern=ball ! videoscale ! video/x-raw,width=100,height=100 ! videomix. \ audiotestsrc freq=400 volume=0.2 ! audiomix. ``` tcp server, ```sh # View this in VLC with tcp://localhost:7001 gst-launch-1.0 \ mpegtsmux name=mux ! rtpmp2tpay ! \ tcpserversink port=7001 host=0.0.0.0 recover-policy=keyframe sync-method=latest-keyframe sync=false \ compositor name=videomix ! x264enc ! queue2 ! mux. \ audiomixer name=audiomix ! audioconvert ! audioresample ! avenc_ac3 ! queue2 ! mux. \ uridecodebin uri=file://$SRC name=demux ! \ queue2 ! audioconvert ! audioresample ! audiomix. \ demux. ! queue2 ! decodebin ! nvvidconv ! videoconvert ! videoscale ! video/x-raw,width=640,height=360 ! videomix. \ videotestsrc pattern=ball ! videoscale ! video/x-raw,width=100,height=100 ! videomix. \ audiotestsrc freq=400 volume=0.2 ! audiomix. ``` > **tips** > for jetson nano as sender, use `nvvidconv` instead of `videoconvert` receiver, ```sh # receiver [mpegts receiver](#mpegts-receiver) -
liviaerxin revised this gist
Jul 16, 2020 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -606,8 +606,7 @@ gst-launch-1.0 -e compositor name=comp sink_0::alpha=0.7 sink_1::alpha=0.5 \ ### Mixing video+audio videotestsrc/audiotestsrc + mpegts + rtp/udp, ```sh # sender # View this in VLC with udp://localhost:5000 -
liviaerxin revised this gist
Jul 16, 2020 . 1 changed file with 25 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -606,24 +606,46 @@ gst-launch-1.0 -e compositor name=comp sink_0::alpha=0.7 sink_1::alpha=0.5 \ ### Mixing video+audio videotestsrc/audiotestsrc + mpegts + rtp/udp, ```sh # sender # View this in VLC with udp://localhost:5000 gst-launch-1.0 -v \ mpegtsmux name=mux alignment=7 ! rtpmp2tpay \ ! udpsink port=5000 host=$HOST sync=false \ compositor name=videomix ! x264enc ! queue2 ! mux. \ audiomixer name=audiomix ! audioconvert ! audioresample ! avenc_ac3 ! queue2 ! mux. \ videotestsrc pattern=ball ! videomix. \ videotestsrc pattern=pinwheel ! videoscale ! video/x-raw,width=100 ! videomix. \ audiotestsrc freq=400 ! audiomix. \ audiotestsrc freq=600 ! audiomix. ``` mp4 + mpegts + rtp/udp, ```sh # sender # View this in VLC with udp://localhost:5000 gst-launch-1.0 -v \ mpegtsmux name=mux alignment=7 ! rtpmp2tpay \ ! udpsink port=5000 host=$HOST sync=false \ compositor name=videomix ! x264enc ! queue2 ! mux. \ audiomixer name=audiomix ! audioconvert ! audioresample ! avenc_ac3 ! queue2 ! mux. \ videotestsrc pattern=ball ! videomix. \ videotestsrc pattern=pinwheel ! videoscale ! video/x-raw,width=100 ! videomix. \ audiotestsrc freq=400 ! audiomix. \ audiotestsrc freq=600 ! audiomix. ``` receiver, ```sh # receiver [mpegts receiver](#mpegts-receiver) gst-launch-1.0 -v udpsrc port=5000 caps="application/x-rtp" \ ! rtpmp2tdepay ! tsparse ! tsdemux name=demux \ demux. ! queue ! decodebin ! videoconvert ! fpsdisplaysink text-overlay=false sync=false \ demux. ! queue leaky=1 ! decodebin ! audioconvert ! autoaudiosink sync=false ``` ## SHM(Shared Memory) -
liviaerxin revised this gist
Jul 16, 2020 . 1 changed file with 5 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,8 +25,8 @@ - [Media File RTP Streaming](#media-file-rtp-streaming) - [demux and split video and audio(not best)](#demux-and-split-video-and-audionot-best) - [remux to MPEG2(best)](#remux-to-mpeg2best) - [mpegts sender](#mpegts-sender) - [mpegts receiver](#mpegts-receiver) - [RTSP Server](#rtsp-server) - [install server(jetson nano)](#install-serverjetson-nano) - [stream web-cam(jetson nano)](#stream-web-camjetson-nano) @@ -421,7 +421,7 @@ gst-launch-1.0 -v \ It has several advantages like good re-synchronization after packet loss and that A/V always stays sync ##### mpegts sender ```sh # sender `mp4` file @@ -433,7 +433,7 @@ gst-launch-1.0 -v filesrc location=/home/jetson/Videos/why_I_left_China_for_Good ! queue ! aacparse ! mux. ``` ##### mpegts receiver ```sh # receiver @@ -621,10 +621,9 @@ gst-launch-1.0 -v \ audiotestsrc freq=400 ! audiomix. \ audiotestsrc freq=600 ! audiomix. ``` [mpegts receiver](#mpegts-receiver) ## SHM(Shared Memory) -
liviaerxin revised this gist
Jul 16, 2020 . 1 changed file with 65 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,10 +25,15 @@ - [Media File RTP Streaming](#media-file-rtp-streaming) - [demux and split video and audio(not best)](#demux-and-split-video-and-audionot-best) - [remux to MPEG2(best)](#remux-to-mpeg2best) - [sender](#sender) - [receiver](#receiver) - [RTSP Server](#rtsp-server) - [install server(jetson nano)](#install-serverjetson-nano) - [stream web-cam(jetson nano)](#stream-web-camjetson-nano) - [stream media file(*.mp4)](#stream-media-filemp4) - [Mixing](#mixing) - [Mixing videos](#mixing-videos) - [Mixing video+audio](#mixing-videoaudio) - [SHM(Shared Memory)](#shmshared-memory) - [raw video](#raw-video) - [h264 encode/decode](#h264-encodedecode) @@ -416,6 +421,8 @@ gst-launch-1.0 -v \ It has several advantages like good re-synchronization after packet loss and that A/V always stays sync ##### sender ```sh # sender `mp4` file gst-launch-1.0 -v filesrc location=/home/jetson/Videos/why_I_left_China_for_Good.mp4 \ @@ -424,7 +431,11 @@ gst-launch-1.0 -v filesrc location=/home/jetson/Videos/why_I_left_China_for_Good ! udpsink host=$HOST port=5000 demux. \ ! queue ! h264parse ! decodebin ! omxh264enc insert-sps-pps=true bitrate=16000000 ! mux. demux. \ ! queue ! aacparse ! mux. ``` ##### receiver ```sh # receiver gst-launch-1.0 -v udpsrc port=5000 \ ! 'application/x-rtp,clock-rate=(int)90000,media=(string)video,payload=(int)96,encoding-name=(string)MP2T' \ @@ -561,6 +572,60 @@ gst-launch-1.0 -v rtspsrc location=rtsp://jetson-desktop.local:8554/test \ ! rtpmp2tdepay ! tsparse ! tsdemux name=demux ! aacparse ! decodebin ! audioconvert ! autoaudiosink sync=false ``` ## Mixing ### Mixing videos ```sh # display gst-launch-1.0 -e compositor name=comp sink_0::alpha=0.7 sink_1::alpha=0.5 \ ! autovideosink \ videotestsrc \ ! video/x-raw, framerate=10/1, width=640, height=360 \ ! comp.sink_0 \ videotestsrc pattern="snow" \ ! video/x-raw, framerate=10/1, width=200, height=150 \ ! comp.sink_1 ``` video + rtp/udp, ```sh # sender gst-launch-1.0 -e compositor name=comp sink_0::alpha=0.7 sink_1::alpha=0.5 \ ! videoconvert ! omxh264enc insert-sps-pps=true bitrate=16000000 ! h264parse ! rtph264pay ! udpsink port=5000 host=$HOST \ videotestsrc \ ! video/x-raw, framerate=10/1, width=640, height=360 \ ! comp.sink_0 \ videotestsrc pattern="snow" \ ! video/x-raw, framerate=10/1, width=200, height=150 \ ! comp.sink_1 ``` [receiver](#receive-h264-rtp-stream) ### Mixing video+audio mpegts + rtp/udp, ```sh # sender # View this in VLC with tcp://localhost:7001 gst-launch-1.0 -v \ mpegtsmux name=mux \ ! udpsink port=5000 host=$HOST sync=false \ compositor name=videomix ! x264enc ! queue2 ! mux. \ audiomixer name=audiomix ! audioconvert ! audioresample ! avenc_ac3 ! queue2 ! mux. \ videotestsrc pattern=ball ! videomix. \ videotestsrc pattern=pinwheel ! videoscale ! video/x-raw,width=100 ! videomix. \ audiotestsrc freq=400 ! audiomix. \ audiotestsrc freq=600 ! audiomix. # receiver ``` ## SHM(Shared Memory)
NewerOlder