invalid cast from 'GstVideoTestSrc' to 'GstBin'

videotestsrc is just an element, not a bin container, so we must use round brackets to embrace the elements all, which means rtsp://127.0.0.1:8554/test is the default mount point.

1
2
test-launch.exe "( videotestsrc ! qsvh264enc ! rtph264pay name=pay0 pt=96 )"
gst-launch-1.0.exe playbin uri=rtsp://127.0.0.1:8554/test --gst-debug=d3d11window:5

Build GStreamer in Windows

1
2
3
4
5
6
7
8
9
10
11
12
python -m pip install meson
python -m pip install ninja
 
git clone https://gitlab.freedesktop.org/gstreamer/gstreamer.git
cd gstreamer
 
rd /S /Q build
meson -Dprefix=%CD%/installed -Dlibav=enabled -Dgst-plugins-ugly:x264=enabled build
 
meson compile -C build
 
meson install -C build

refer to:
https://gstreamer.freedesktop.org/documentation/installing/building-from-source-using-meson.html
http://dljz.nicethemes.cn/news/show-62582.html

GStreamer memo

https://gstreamer.freedesktop.org/documentation/tools/gst-launch.html

https://cloud.tencent.com/developer/article/1820526
https://blog.csdn.net/csdnhuaong/article/details/80026433
https://blog.csdn.net/qq_42711516/article/details/123921984
https://blog.csdn.net/han2529386161/article/details/102724856

https://blog.csdn.net/m0_51004308/article/details/121357638
https://blog.csdn.net/Aidam_Bo/article/details/109772430

gstreamer之RTSP Server一个进程提供多路不同视频
https://blog.51cto.com/u_13161667/3310768

全网首发:gstreamer如何接入RTSP流(IP摄像头)的代码范例
https://blog.51cto.com/u_13161667/3310521

GstMP4Mux caps
DeepStream/Gstreamer queue实现预缓存功能
https://blog.csdn.net/qq_41632852/article/details/124959601

gstreamer中tee如何实现动态增减支路(预览+截图+录像)
https://blog.csdn.net/qq_41563600/article/details/121343927

【gstreamer opencv::Mat】将opencv的cv::Mat数据转换成MP4视频
https://blog.csdn.net/weixin_44495869/article/details/121900517

#播放并存储为h264
gst-launch-1.0 -e -v  udpsrc port=10001 !  "application/x-rtp, media=video, clock-rate=90000, encoding-name=H264"  ! rtph264depay ! tee name=t  t. ! queue ! h264parse ! "video/x-h264, stream-format=byte-stream" ! filesink location=./aa.h264 t. !  queue ! avdec_h264 ! glimagesink

#混流+缩放
./gst-launch-1.0  intervideosrc !  video/x-raw,framerate=(fraction)10/1,width=3200,height=2400 ! videomixer name=mix sink_1::xpos=0 sink_2::xpos=1000 sink_2::width=100 sink_2::height=100 ! videoconvert ! glimagesink filesrc location=./ttt.mov ! decodebin ! video/x-raw,width=1280,height=720 ! videoscale ! video/x-raw,width=100  ! mix.  videotestsrc ! video/x-raw ! mix.

gst-launch-1.0.exe videotestsrc ! queue ! d3d11videosink

http://t.zoukankan.com/missmzt-p-10918216.html

https://gstreamer.freedesktop.org/documentation/tutorials/basic/debugging-tools.html
set GST_DEBUG_DUMP_DOT_DIR=D:\work\gstreamer\gstdot
http://www.graphviz.org/doc/info/command.html

1
2
3
4
push
	upstream element calls downstream sink pads' gst_pad_push
pull
	downstream element calls upstream source pads' gst_pad_pull_range

gst_rtspsrc_loop_interleaved
gst_rtspsrc_stream_configure_manager
gst_qt_mux_sink_event_pre_queue

rtp_session_process_sr
https://stackoverflow.com/questions/53169699/gstreamer-calculate-delay-in-received-video-frames-buffers-to-detect-communicat

Speed up pip install

1
2
3
4
5
6
7
python3 -m pip install opencv-python==4.5.3.56 -i https://pypi.tuna.tsinghua.edu.cn/simple
 
http://mirrors.aliyun.com/pypi/simple/ 
https://pypi.mirrors.ustc.edu.cn/simple/ 
https://pypi.douban.com/simple/ 
https://pypi.tuna.tsinghua.edu.cn/simple/ 
http://pypi.mirrors.ustc.edu.cn/simple/

refer to:
https://www.cnblogs.com/huangguifeng/p/12002049.html

pragma pack vs. cplusplus align

TAlignedBytes definition is picked from ue4,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
typedef unsigned char uint8;
typedef int int32;
typedef unsigned int uint32;
 
template<int32 Size, uint32 Alignment>
struct TAlignedBytes; // this intentionally won't compile, we don't support the requested alignment
 
/** Unaligned storage. */
template<int32 Size>
struct TAlignedBytes<Size, 1>
{
	uint8 Pad[Size];
};
 
#define GCC_ALIGN(_align)
#define MS_ALIGN(n) __declspec(align(n))
 
// C++/CLI doesn't support alignment of native types in managed code, so we enforce that the element
// size is a multiple of the desired alignment
#ifdef __cplusplus_cli
#define IMPLEMENT_ALIGNED_STORAGE(Align) \
		template<int32 Size>        \
		struct TAlignedBytes<Size,Align> \
		{ \
			uint8 Pad[Size]; \
			static_assert(Size % Align == 0, "CLR interop types must not be aligned."); \
		};
#else
/** A macro that implements TAlignedBytes for a specific alignment. */
#define IMPLEMENT_ALIGNED_STORAGE(Align) \
	template<int32 Size>        \
	struct TAlignedBytes<Size,Align> \
	{ \
		struct MS_ALIGN(Align) TPadding \
		{ \
			uint8 Pad[Size]; \
		} GCC_ALIGN(Align); \
		TPadding Padding; \
	};
#endif
 
// Implement TAlignedBytes for these alignments.
IMPLEMENT_ALIGNED_STORAGE(16);
IMPLEMENT_ALIGNED_STORAGE(8);
IMPLEMENT_ALIGNED_STORAGE(4);
IMPLEMENT_ALIGNED_STORAGE(2);
 
#undef IMPLEMENT_ALIGNED_STORAGE

My test code is in vc2019 x64,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
struct TTask
{
	char ch2;
	char ch3;
	double d4;
	__int64 i64;
};
 
#pragma pack(push, 1)
struct TTaskB
{
	char ch2;
	alignas(16) char ch3;
	double d4;
	__int64 i64;
};
struct AAa
{
	char ch1;
	TAlignedBytes<sizeof(TTask), alignof(TTask)> TaskStorage;
};
struct AAb
{
	char ch1;
	TTask TaskStorage;
};
#pragma pack(pop)
 
void CMFCApplication1Dlg::OnBnClickedButton1()
{
	__int64 sizeTTask = alignof(TTask);			// sizeTTask is 8
	__int64 sizeTTaskB = alignof(TTaskB);			// sizeTTaskB is 16
 
	AAa aa;
	TTask& Task = *(TTask*)&aa.TaskStorage;
	__int64 gapAAa = (char*)&Task - (char*)&aa;		// gapAAa is 8
 
	AAb bb;
	TTask& TaskB = *(TTask*)&bb.TaskStorage;
	__int64 gapAAb = (char*)&TaskB - (char*)&bb;		// gapAAb is 1
}

Let cpu fans be quiet when UE4 Editor is in front

Two methods to solve this,

  • Modify source code,
    D:\ue\Engine\Source\Runtime\ApplicationCore\Private\Windows\WindowsPlatformApplicationMisc.cpp

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    #include <io.h>
    int doesFileExist(const char* filePath)
    {
    	int result = _access(filePath, 0);
    	if (result < 0)
    		return 0;
    	return 1;
    }
     
    bool FWindowsPlatformApplicationMisc::IsThisApplicationForeground()
    {
    	if (doesFileExist("d:/ue/not_focus.txt"))
    	{
    		return false;
    	}
     
    	uint32 ForegroundProcess;
    	::GetWindowThreadProcessId(GetForegroundWindow(), (::DWORD *)&ForegroundProcess);
    	return (ForegroundProcess == GetCurrentProcessId());
    }

    If d:\ue\not_focus.txt exists, whether UE4 Editor is active, UE4 will not occupy a cpu kernel thoroughly.

  • In D:\ue\Engine\Config\ConsoleVariables.ini, or in console, type

    1
    
    t.MaxFPS 5

refer to:
なんとなく日誌

Navigate to source location by writing code

UE4 has a functionality of "Goto Definition",

1
FSourceCodeNavigationImpl::NavigateToFunctionSource

which uses two apis from dbghelp.dll,

1
2
SymGetSymFromName64
SymGetLineFromAddr64