[Live-devel] Run openrtsp from another program

Nicolas Julien nicolas.julien at cdvi.com
Tue Oct 20 03:34:20 PDT 2020


I found the solution.
For those who would need to do the same:

SECURITY_ATTRIBUTES sa;
char filename[MAX_PATH];
char errfile[MAX_PATH];
char szCdeLine[1024];
DWORD dwErr, dwFlags;

ZeroMemory(&sa, sizeof(sa));
sa.nLength = sizeof(sa);
sa.bInheritHandle = true;
sa.lpSecurityDescriptor = NULL;

strcpy(filename, "e:\\tmp\\video.tmp");
HANDLE hStdOut = CreateFileA(filename, GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

strcpy(errfile, "e:\\tmp\\stderr.txt");
HANDLE hStdErr = CreateFile(errfile, GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

PROCESS_INFORMATION pi;
STARTUPINFOA si;

ZeroMemory(&pi, sizeof(pi));
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags |= STARTF_USESTDHANDLES;
si.hStdInput = NULL;
si.hStdOutput = hStdOut;
si.hStdError = hStdErr;

strcpy(szCdeLine, "openrtsp ");
strcat(szCdeLine, "-b 400000 ");
strcat(szCdeLine, "-u admin admin1234 ");
strcat(szCdeLine, "-v ");
strcat(szCdeLine, "-d 40 ");
strcat(szCdeLine, "-U 20201015T162020Z ");
strcat(szCdeLine, "\"rtsp://192.168.1.174:554/Streaming/Tracks/101\<http://192.168.1.174:554/Streaming/Tracks/101%5C>" ");

dwFlags = CREATE_NO_WINDOW;
CreateProcessA(NULL, szCdeLine, NULL, NULL, TRUE, dwFlags, NULL, NULL, &si, &pi);
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
CloseHandle(hStdOut);
CloseHandle(hStdErr);


Once this code has been executed, you get a .tmp file which contains the record of the rtsp stream and a .txt file which contains the result of StdErr.
Thanks to Kyle for getting me on the good way.

________________________________
De : live-devel [live-devel-bounces at us.live555.com] de la part de Nicolas Julien [nicolas.julien at cdvi.com]
Envoyé : lundi 19 octobre 2020 17:14
À : LIVE555 Streaming Media - development & use
Objet : Re: [Live-devel] Run openrtsp from another program

Hi Kyle,

Thanks for your answer.
I updated my code, following the example given.
Still nothing on the stdout output.
However, I get the following message on the stderr output:

Usage: E:\cdvi\dev\rad_atrium_video\Win32\Debug\openRTSP.exe [-p <startPortNum>] [-r|-q|-4|-i] [-a|-v] [-V]

As if the syntax of my command was not good, while this same command launched manually works perfectly.


________________________________
De : live-devel [live-devel-bounces at us.live555.com] de la part de Kyle Sebion [ksebion at digitalforces.com]
Envoyé : lundi 19 octobre 2020 14:59
À : LIVE555 Streaming Media - development & use
Objet : Re: [Live-devel] Run openrtsp from another program

https://stackoverflow.com/questions/7018228/how-do-i-redirect-output-to-a-file-with-createprocess might be helpful for you. Probably not a problem with openrtsp.

On Mon, Oct 19, 2020 at 6:43 AM Nicolas Julien <nicolas.julien at cdvi.com<mailto:nicolas.julien at cdvi.com>> wrote:
Hi Ross,

When I run manually openRTSP from a windows console, all is fine.
Now, I'm trying to launch it from a C++ Windows program, but it does not work.
No error, but video file is not generated.

The command line is :
openrtsp.exe -b 400000 -u admin admin1234 -v -d 40 -U 20201015T162020Z "rtsp://192.168.1.174:554/Streaming/Tracks/101<http://192.168.1.174:554/Streaming/Tracks/101>" > e:\tmp\video.tmp

The C code is :

STARTUPINFOA si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof si;
ZeroMemory(&pi, sizeof(pi));

GetStartupInfoA(&si);

strcpy(szCdeLine, "-b 400000 ");
strcat(szCdeLine, "-u admin admin1234 ");
strcat(szCdeLine, "-v ");
strcat(szCdeLine, "-d 40 ");
strcat(szCdeLine, "-U 20201015T162020Z ");
strcat(szCdeLine, "\"rtsp://192.168.1.174:554/Streaming/Tracks/101\<http://192.168.1.174:554/Streaming/Tracks/101%5C>" ");
strcat(szCdeLine, "> e:\\tmp\\video.tmp");

if (!CreateProcessA("openRTSP.exe", szCdeLine, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi))
{
err = GetLastError();
throw Exception("openrtsp error";
}

WaitForSingleObject(pi.hProcess, 40000);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);


The C program and openrtsp.exe are in the same directory.

Do you have any idea why it does not work ?

Thanks in advance,
Nicolas
_______________________________________________
live-devel mailing list
live-devel at lists.live555.com<mailto:live-devel at lists.live555.com>
http://lists.live555.com/mailman/listinfo/live-devel


--

If you have any additional problems or questions, or if this case needs to be handled more urgently, please see below for contact information.


Thank you.


Kyle Sebion, Digital Forces Corp.



Urgent support: 630-978-2000 X 1.

Normal support: help at digitalforces.com<mailto:help at digitalforces.com> (faster and better than my personal email; reaches multiple people)

Voice: 630-299-4971 (same as x804). Text: (avoid) 630-447-0804.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20201020/92688d39/attachment.htm>


More information about the live-devel mailing list