gstreamer-wfb-ng



IT OPEN LOW DELAY VIDEO:
gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264'  ! rtph264depay ! avdec_h264 ! clockoverlay valignment=bottom ! autovideosink  sync=false



gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264'  ! rtph264depay ! avdec_h264 ! clockoverlay valignment=bottom ! filesink location=xyz.avi


gst-launch-1.0 -v udpsrc port=5603 caps="application/x-rtp,media=(string)video,encoding-name=(string)H264,payload=(int)96" ! rtpjitterbuffer ! rtph264depay ! decodebin ! videoconvert ! autovideosink


With one connected to 5603 port and create huge file. I still dont know what this file is.
gst-launch-1.0 udpsrc port=5603 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264'  ! rtph264depay ! v4l2h264dec ! clockoverlay valignment=bottom ! filesink location=xyz.avi


According to the documentation of avdec_h264, his sink expects parsed format of h264 stream. And what h264parse does, it just parses bytes of h264 in a way that avdec_h264 could understand.

То есть сначала Gstreamer  берет уже  264 пакеты  у камеры, тотом 264й парсет преобразует их в формат которые умеет понимать rtph264pay 

pkg-config --modversion gstreamer-rtsp-server-1.0

https://developer.ridgerun.com/wiki/index.php/Using_UDP_Multicast_with_GStreamer

gst-launch-1.0 udpsrc port=5602 ! application/x-rtp, payload=96 ! rtph264depay ! h264parse ! v4l2h264dec ! decodebin ! videoconvert ! video/x-raw,format=(string)BGR ! videoconvert ! appsink emit-signals=true



buf = sample.get_buffer()
caps = sample.get_caps()
H, W, C = caps.get_structure(0).get_value('height'), caps.get_structure(0).get_value('width'), 3
arr = np.ndarray(
        (H, W, C),
        buffer=buf.extract_dup(0, buf.get_size()),
        dtype=np.uint8
)

g_object_set (data.udpsrc, "uri""udp://10.0.11.255:9001"NULL);

/* Start playing */
    if( gst_element_set_state (data.playbin2, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE )
    {
        g_printerr ("Unable to set the pipeline to the playing state.\n");
        gst_object_unref (data.playbin2);
        return( -1 );
    }


gst-launch-1.0  udpsrc port=5600 caps='application/x-rtp,media=video,  clock-rate=90000, encoding-name=H264' ! rtpjitterbuffer latency=5 ! rtph264depay ! h264parse config-interval=1 disable-passthrough=true ! avdec_h264 ! videoscale method=0 ! video/x-raw,width=1920,height=1080 ! videoconvert ! cairooverlay name=overlay ! videoconvert ! autovideosink sync=false

gst-launch-1.0  udpsrc port=5603 caps='application/x-rtp,media=video,  clock-rate=90000, encoding-name=H264' ! rtpjitterbuffer latency=5 ! rtph264depay ! h264parse config-interval=1 disable-passthrough=true ! avdec_h264 ! videoscale method=0 ! video/x-raw,width=1920,height=1080 ! videoconvert ! cairooverlay name=overlay ! videoconvert ! fakesink

erroneous pipeline: no element "avdec_h264"
Compilling Gstreamer

omxh264dec


gst-launch-1.0  udpsrc port=5603 caps='application/x-rtp,media=video,  clock-rate=90000, encoding-name=H264' ! rtpjitterbuffer latency=5 ! rtph264depay ! h264parse config-interval=1 disable-passthrough=true ! v4l2h264dec ! videoscale method=0 ! video/x-raw,width=1920,height=1080 ! videoconvert ! cairooverlay name=overlay ! videoconvert ! fakesink


C tutorial gstreamer:

vpuenc_h264 ! mp4mux ! filesink location=output.mp4

x264enc ! mp4mux ! filesink location=output.mp4

! mp4mux ! filesink location=file.mp4
gst-launch-1.0  udpsrc port=5603 caps='application/x-rtp,media=video,  clock-rate=90000, encoding-name=H264' ! rtpjitterbuffer latency=5 ! rtph264depay ! h264parse config-interval=1 disable-passthrough=true ! mp4mux ! filesink location=file.mp4


git clone --recurse-submodules -j8 https://github.com/svpcom/wfb-ng-osd.git

gst-launch-1.0 rtspsrc location=rtsp://ip/url ! rtph264depay ! h264parse ! mp4mux ! filesink location=file.mp4



Nice introduce Gstreamer, video and code


 video/x-h264,profile=high,width=320,height=240,framerate=30/1, stream-format=byte-stream

It work, but huge latency
./test-launch --gst-debug=3 "( udpsrc port=5603 ! application/x-rtp, media=video, clock-rate=90000, encoding-name=H264 ! rtpjitterbuffer latency=5 ! rtph264depay ! h264parse ! rtph264pay name=pay0 pt=96 )"


gst-launch-1.0 -v rtspsrc location=rtsp://192.168.0.104:8554/test latency=0 buffer-mode=auto ! decodebin ! videoconvert ! autovideosink sync=false




to install opencv-python we need (because wheel compilation) increase SWAP from 100 to 2048
Python scrips will get all modules or from venv, or from system, To install module to system use 
sudo pip3 install opencv-python



https://www.semicomplete.com/projects/xdotool/

https://unix.stackexchange.com/questions/137616/how-to-get-mouse-click-position

https://stackoverflow.com/questions/8480073/how-would-i-get-the-current-mouse-coordinates-in-bash

https://unix.stackexchange.com/questions/14159/how-do-i-find-the-window-dimensions-and-position-accurately-including-decoration

https://stackoverflow.com/questions/34207981/how-do-you-get-window-id-for-xdotool-automatically

когда будет id окна можно наверное заюзать getwindowgeometry

ивент клика мышки можно я так понял даже с пайтона читать и реагировать на на него:
- https://stackoverflow.com/questions/20629258/how-to-detect-mouse-click-in-python-3-on-linux
- https://stackoverflow.com/questions/1147653/python-xlib-catch-send-mouseclick?rq=1 (пример с while true конечно сожрет весь CPU)

как я вижу это:
- запуск пайтон скрипта
- получаем ID окна которое нам нужно (с видео потоком) (запускаем xdotool из под пайтона)
- сразу получаем его текущий размер, координаты и так же получаем информацию и размере экрана и тд (скорее всего пригодится) (запускаем xdotool из под пайтона)
- слушаем ивенты до момента пока не произошел клик мышки (2 ссылки на примеры с пайтоном)
- как только произошел клик мышки мы пытаемся получить координаты (или сразу из пайтона если возможно или сразу запустить xdotool и получить координаты мышки)
- проверяем куда так сказать попала мышка, если вне интересующего нас окна, то ничего не делаем, если в интересующее нас окно то умирает путин

semicomplete (https://www.semicomplete.com/projects/xdotool/)
xdotool  -  fake keyboard/mouse input, window management, and more …



apt-file update
sudo apt-get install libxcomposite-dev

gcc mouse_ev.c -lX11 -o mouse

Mavlink protocol for OSD should be on port 14550:
./osd -p14550

GStreamer is a complete Open Source multimedia framework, and it includes hundreds of plugins, including modern formats like DASH, HLS or the first ever RTSP 2.0 implementation. The whole framework is almost 150MB on my computer, but what if you only have 5 megs of flash available? Is it a viable choice? Yes it is, and I will show you how.













Комментарии