Browse Source

adjust

master
Gitea 5 years ago
parent
commit
2ee2f9e515
4 changed files with 43 additions and 82 deletions
  1. +17
    -57
      TestMediaRealPlay.cpp
  2. +2
    -1
      XNetSDKTest.cpp
  3. +1
    -1
      XNetSDKTest.h
  4. +23
    -23
      video.py

+ 17
- 57
TestMediaRealPlay.cpp View File

@@ -38,72 +38,32 @@ int CALLBACK Test_MediaCallBack(XSDK_HANDLE hMedia, const unsigned char *pData,
}
int TestMediaRealPlay()
int TestMediaRealPlay(XSDK_HANDLE hDevice,int dPos)
{
printf("MediaRealPlay %s\r\n", __FUNCTION__);
XSDK_HANDLE hPlayer[6] ;
XSDK_HANDLE hPlayer ;
bool bPause = false;
int nSpeed = 0;
char c = 0;
int size = sizeof(hDeviceArr) / sizeof(hDeviceArr[0]);
//while((c = getchar()) != 'q')
//{
// switch(c)
// {
// case 's':
if(size==6)
if (hDevice)
{
for (int i = 0; i < size; i++)
{
if (hPlayer[i])
{
XSDK_MediaStop(hPlayer[i]);
hPlayer[i] = 0;
}
}
for (int i = 0; i < size; i++)
{
SXMediaRealPlayReq param = { 0 };
param.nChannel = 0;
param.nStreamType = 0;
param.nRequestType = EXSDK_DATA_FORMATE_FRAME;
param.pMediaCallback = Test_MediaCallBack;
param.pUserData = (void *)DeviceIdArr[i];
hPlayer[i] = XSDK_MediaRealPlay(hDeviceArr[i], &param);
bPause = false;
nSpeed = 0;
printf("play hMedia:: %x\r\n", hDeviceArr[i]);
XSDK_DevSynTime(hDeviceArr[i], "", 1);
}
XSDK_MediaStop(hDevice);
}
// break;
// case 't':
// {
// for (int i = 0; i < size; i++)
// {
// if (hPlayer[i])
// {
// XSDK_MediaStop(hPlayer[i]);
// hPlayer[i] = 0;
// }
// }
//
// }
// break;
// }
//}
//for (int i = 0; i < size; i++)
//{
// if (hPlayer[i])
// {
// XSDK_MediaStop(hPlayer[i]);
// hPlayer[i] = 0;
// }
//}
SXMediaRealPlayReq param = { 0 };
param.nChannel = 0;
param.nStreamType = 0;
param.nRequestType = EXSDK_DATA_FORMATE_FRAME;
param.pMediaCallback = Test_MediaCallBack;
param.pUserData = (void *)DeviceIdArr[dPos];
hPlayer= XSDK_MediaRealPlay(hDevice, &param);
bPause = false;
nSpeed = 0;
printf("play hMedia:: %x\r\n", hDevice);
XSDK_DevSynTime(hDevice, "", 1);
return 0;
}

+ 2
- 1
XNetSDKTest.cpp View File

@@ -73,6 +73,7 @@ int CALLBACK Main_MessageCallBack(XSDK_HANDLE hDevice, int nMsgId, int nParam1,
{
OnDASDeviceReg(hDevice, (SXSDKDASDeviceInfo *)pObject,dPos);
dPos++;
TestMediaRealPlay(hDevice,dPos);
}
}
break;
@@ -157,7 +158,7 @@ int main(int argc, char *argv[])
//TestDevAlarmCallback();
//// 测试实时视频
TestMediaRealPlay();
//TestMediaRealPlay();
//// 设备录像回放
// TestMediaRecordPlay();


+ 1
- 1
XNetSDKTest.h View File

@@ -42,7 +42,7 @@ int TestDevAlarmCallback();
void OnDevAlarmCallback(XSDK_HANDLE hDevice, const char *szAlarm);
// 测试实时视频
int TestMediaRealPlay();
int TestMediaRealPlay(XSDK_HANDLE hDevice,int dPos);
// 设备录像回放
int TestMediaRecordPlay();


+ 23
- 23
video.py View File

@@ -31,29 +31,29 @@ def convert(origin, target):
cmd = 'ffmpeg -i {0} -c copy {1}'.format(origin, target)
print("cmd:: {0}".format(cmd))
args = shlex.split(cmd)
#status, output = sp.getstatusoutput(cmd)
#print("status:: {0}, output {1}".format(status, output))
#if status ==0:
# print("{0} convert {1} Success, origin dat will remove!".format(origin, target))
# os.remove(origin)
#else:
# print("{0} convert fail".format(origin))
proc = sp.Popen(args, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE)
answer = b'Overwrite ? [y/N]'
try:
outs, errs = proc.communicate()
print(outs, errs)
print("answer in outs : {0}".format(answer in errs))
if answer in errs:
print('write y')
# proc.stdin.write(b'y')
if proc.returncode == 0:
print("{0} convert {1} Success, origin dat will remove!".format(origin, target))
os.remove(origin)
else:
print("{0} convert fail".format(origin))
except sp.TimeoutExpired:
proc.kill()
status, output = sp.getstatusoutput(cmd)
print("status:: {0}, output {1}".format(status, output))
if status ==0:
print("{0} convert {1} Success, origin dat will remove!".format(origin, target))
os.remove(origin)
else:
print("{0} convert fail".format(origin))
# proc = sp.Popen(args, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE)
# answer = b'Overwrite ? [y/N]'
# try:
# outs, errs = proc.communicate()
# print(outs, errs)
# print("answer in outs : {0}".format(answer in errs))
# if answer in errs:
# print('write y')
# # proc.stdin.write(b'y')
# if proc.returncode == 0:
# print("{0} convert {1} Success, origin dat will remove!".format(origin, target))
# os.remove(origin)
# else:
# print("{0} convert fail".format(origin))
# except sp.TimeoutExpired:
# proc.kill()
if __name__ == "__main__":


Loading…
Cancel
Save