Hi,
我用的是DM8127,IPNC RDK 3.8。我修改了ENC_A8_DEC usecase,想保存H264流文件到本地。结果大约保存了2500帧左右,线程会阻塞很久,然后才会继续执行,请问是什么原因?
代码如下:
Void *MultiCh_ipcBitsMain(Void *prm) {UInt32 i;OSA_DmaCopy1D copy1D;Bitstream_BufList fullBitsBufList;Bitstream_BufList emptyBitsBufList;IpcBitsOutLinkHLOS_BitstreamBufReqInfo ipcReqInfo;OSA_printf("Entered IPC Bits Handler function\n");gIpcBitsThObj.exitTh= FALSE;gIpcBitsThObj.exitDone = FALSE;//unsigned char const start_code[4] = { 0x00, 0x00, 0x00, 0x01 };FILE *outFile = NULL;FILE *outFile2 = NULL;UInt8 *buf = NULL;UInt32 n= 0;if(outFile == NULL){ outFile = fopen("8127Test.h264", "w");if (outFile == NULL) { OSA_printf("Failed to open file for writing\n");exit(0);}}if(outFile2 == NULL){ outFile2 = fopen("8127Test.hdr", "w");if (outFile2 == NULL) { OSA_printf("Failed to open file for writing\n");exit(0);}}while(gIpcBitsThObj.exitTh == FALSE){OSA_semWait(&gIpcBitsNotifySem,OSA_TIMEOUT_FOREVER);IpcBitsInLink_getFullVideoBitStreamBufs(gIpcBitsInHLOSId,&fullBitsBufList);if(fullBitsBufList.numBufs > 0){for(i = 0;i < fullBitsBufList.numBufs;i++){ipcReqInfo.numBufs= 1;ipcReqInfo.minBufSize[0] = DEC_MIN_BUF_SIZE;/* Wait till empty buffer is got from IPC Bits Out link */do{IpcBitsOutLink_getEmptyVideoBitStreamBufs(gIpcBitsOutHLOSId,&emptyBitsBufList,&ipcReqInfo);OSA_waitMsecs(10);}while(emptyBitsBufList.numBufs == 0);/* Copy bitstream */emptyBitsBufList.numBufs = 1;emptyBitsBufList.bufs[0]->channelNum = fullBitsBufList.bufs[i]->channelNum;emptyBitsBufList.bufs[0]->fillLength = fullBitsBufList.bufs[i]->fillLength;emptyBitsBufList.bufs[0]->timeStamp = fullBitsBufList.bufs[i]->timeStamp;if(gDmaHndl.chId == 0xFF){memcpy(emptyBitsBufList.bufs[0]->addr,(fullBitsBufList.bufs[i]->addr + fullBitsBufList.bufs[i]->startOffset),fullBitsBufList.bufs[i]->fillLength);}else{copy1D.srcPhysAddr = (unsigned long)CMEM_getPhys(fullBitsBufList.bufs[i]->addr + fullBitsBufList.bufs[i]->startOffset);copy1D.dstPhysAddr = (unsigned long)CMEM_getPhys(emptyBitsBufList.bufs[0]->addr);copy1D.size= fullBitsBufList.bufs[i]->fillLength;OSA_dmaCopy1D(&gDmaHndl,©1D,1);} #if 1 buf = fullBitsBufList.bufs[i]->addr + fullBitsBufList.bufs[i]->startOffset; if (fwrite(buf, fullBitsBufList.bufs[i]->fillLength, 1, outFile) != 1) { OSA_printf("Failed to write data to file\n"); exit(0);} #endif fprintf(outFile2, "%d, ", fullBitsBufList.bufs[i]->fillLength); n++; if(n % 100 == 0) OSA_printf("received %d frames.\n", n); if(n == 3000) { fclose(outFile); fclose(outFile2); exit(0); }IpcBitsOutLink_putFullVideoBitStreamBufs(gIpcBitsOutHLOSId,&emptyBitsBufList);}}IpcBitsInLink_putEmptyVideoBitStreamBufs(gIpcBitsInHLOSId,&fullBitsBufList);}gIpcBitsThObj.exitDone = TRUE;OSA_printf("Exiting IPC Bits Handler function\n");return NULL; }
log如下:
Starting syslogd/klogd: done
_____ _____ _ _| _ |___ ___ ___ ___ | _ |___ ___ |_|___ ___| |_| | _| .'| . | . | | __| _| . | | | -_| _| _|
|__|__|_| |__,|_ |___| |__| |_| |___|_| |___|___|_| |___| |___|
Arago Project http://arago-project.org DM8127_IPNC ttyO0
Arago 2011.09 DM8127_IPNC ttyO0
DM8127_IPNC login: root (automatic login)
root@DM8127_IPNC:~# mkdosfs 3.0.12 (29 Oct 2011)
unable to get drive geometry, using default 255/63
/dev/sbulla has 255 heads and 63 sectors per track,
logical sector size is 512,
using 0xf8 media descriptor, with 1024 sectors;
file system has 2 12-bit FATs and 4 sectors per cluster.
FAT size is 1 sector, and provides 247 clusters.
There is 1 reserved sector.
Root directory contains 512 slots and uses 32 sectors.
Volume ID is 63107077, no volume label.
g_file_storage gadget: No serial-number string provided!
g_file_storage gadget: File-backed Storage Gadget, version: 1 September 2010
g_file_storage gadget: Number of LUNs=1
g_file_storage gadget-lun0: ro=0, nofua=0, file: /dev/sbulla
[m3vpss ] CT: 5592, 3dlut index:2Simple mixer control 'PGA',0
Capabilities: cvolume cswitch penum
Capture channels: Front Left – Front Right
Limits: Capture 0 – 119
Front Left: Capture 80 [67%] [40.00dB] [on]
Front Right: Capture 80 [67%] [40.00dB] [on]
queue id:0
[m3vpss ] CT: 6091, 3dlut index:3
[host] received 100 frames.
./boa: /usr/lib/libssl.so.1.0.0: no version information available (required by ./boa)
./boa: /usr/lib/libcrypto.so.1.0.0: no version information available (required by ./boa)
ApproDrvInit: 3
queue id:163845
queue id:0
queue id:32769
queue id:0
[host] received 200 frames.
[host] received 300 frames.
[host] received 400 frames.
[host] received 500 frames.
[host] received 600 frames.
TimeOut occure in boot_proc.
Program exit.
[host] received 700 frames.
TimeOut occure in boot_proc.
Program exit.
[host] received 800 frames.
[host]Usecase is Active !!!
[host] received 900 frames.
[host] received 1000 frames.
[host] received 1100 frames.
[host] received 1200 frames.
[host] received 1300 frames.
[host] received 1400 frames.
[host] received 1500 frames.
[host] received 1600 frames.
[host] received 1700 frames.
[m3vpss ] 66182: CAMERA: Fields = 1801 (fps = 30), Total Resets = 0 (Avg 0 ms per reset)
[m3video] ==================== EncLink_PrintDetails ==================== [m3video] 67020: HDVICP-ID:0
[m3video] totalAcquire2wait in msec: 1125
[m3video] totalWait2Isr in msec: 45929
[m3video] totalIsr2Done in msec: 65
[m3video] totalWait2Done in msec: 45994
[m3video] totalDone2Release in msec: 0
[m3video] totalAcquire2Release in msec: 47715
[m3video] totalAcq2acqDelay in msec: 13053
[m3video] totalElapsedTime in msec: 60767
[m3video] numAccessCnt: 3567
[m3video] IVA-FPS : 59
[m3video] [m3video] *** ENCODE Statistics *** [m3video] [m3video] Elasped Time : 60 secs
[m3video] [m3video] [m3video] CH | In Recv In Skip In User Out Latency [m3video] Num | FPS FPS Skip FPS FPS Min / Max
[m3video] ——————————————–
[m3video] 0 | 30 0 0 29.67 14 / 56
[m3video] [m3video] Multi Channel Encode Average Submit Batch Size [m3video] Max Submit Batch Size : 24
[m3video] IVAHD_0 Average Batch Size : 1
[m3video] IVAHD_0 Max achieved Batch Size : 1
[m3video] ==============================================================
[host]Usecase is Active !!!
[host] received 1800 frames.
[host] received 1900 frames.
ApproDrvExit: 7
Error: WaitStreamReady Fail.
Error: SemWait: Invalid Semaphore handler
Error: SemRelease: Invalid Semaphore handler
Error: SemWait: Invalid Semaphore handler
[host]Force IDR on Channel: 0
[host]Force IDR on Channel: 1Error: SemRelease: Invalid Semaphore handler
SystemInit success
Schedule manager init success
Dmva Schedule manager init success
umount: can't umount /mnt/mmc: Invalid argument
killall: dhcpcd: no process killed
rm: cannot remove '/var/run/dhcpcd-eth0.pid': No such file or directory
[host] received 2000 frames.
[host] received 2100 frames.
[host] received 2200 frames.
[host] received 2300 frames.
[host] received 2400 frames.
[host] received 2500 frames.
[host]Usecase is Active !!! [m3vpss ] ==================== CameraLink_PrintDetails ==================== [m3vpss ] 126123: CAMERA: Fields = 3601 (fps = 30, CPU Load = 27)
[m3vpss ] 126123: CAMERA: Num Resets = 0 (Avg 0 ms per reset)
[m3vpss ] ================================================================= [m3vpss ] 126189: CAMERA: Fields = 1801 (fps = 30), Total Resets = 0 (Avg 0 ms per reset)
[host]Usecase is Active !!!
[host]Usecase is Active !!! [m3video] ==================== EncLink_PrintDetails ==================== [m3video] 161645: HDVICP-ID:0
[m3video] totalAcquire2wait in msec: 1618
[m3video] totalWait2Isr in msec: 65598
[m3video] totalIsr2Done in msec: 80
[m3video] totalWait2Done in msec: 65678
[m3video] totalDone2Release in msec: 0
[m3video] totalAcquire2Release in msec: 68152
[m3video] totalAcq2acqDelay in msec: 18103
[m3video] totalElapsedTime in msec: 86242
[m3video] numAccessCnt: 5095
[m3video] IVA-FPS : 59
[m3video] [m3video] *** ENCODE Statistics *** [m3video] [m3video] Elasped Time : 94 secs
[m3video] [m3video] [m3video] CH | In Recv In Skip In User Out Latency [m3video] Num | FPS FPS Skip FPS FPS Min / Max
[m3video] ——————————————–
[m3video] 0 | 30 22 0 8.14 14 / 29
[m3video] [m3video] Multi Channel Encode Average Submit Batch Size [m3video] Max Submit Batch Size : 24
[m3video] IVAHD_0 Average Batch Size : 1
[m3video] IVAHD_0 Max achieved Batch Size : 1
[m3video] ==============================================================net_search_gateway:eth0, 1A8C0, 0, 1
dns=192.168.1.1
net_search_gateway:eth0, 1A8C0, 0, 1
net_search_gateway:eth0, 0, FE01A8C0, 3
dns=192.168.1.1
g_file_storage gadget: No serial-number string provided!
g_file_storage gadget: File-backed Storage Gadget, version: 1 September 2010
g_file_storage gadget: Number of LUNs=1
g_file_storage gadget-lun0: ro=0, nofua=0, file: /dev/sbulla
[09/Nov/2012:12:25:24 +0000] boa: server version Boa/0.94.13
[09/Nov/2012:12:25:24 +0000] boa: server built Aug 19 2014 at 09:27:37.
[09/Nov/2012:12:25:24 +0000] boa: starting server pid=549, port 80
queue id:0
<UDN>uuid:Upnp-TVEmulator-1_0-00_0095591997</UDN>
Upnp port is 0
UPnP Initialized OK ip=192.168.1.224, port=0
desc_doc_url = http://192.168.1.224/tvdevicedesc.xml
error code = 0
device advertisement succeed.
queue id:131076
ApproDrvInit: 10
queue id:163845
Initializing…
…done initializing
Play this stream using the URL:
rtsp://192.168.1.224:8557/PSIA/Streaming/channels/2?videoCodecType=H.264
(We use port 8304 for optional RTSP-over-HTTP tunneling.)
ApproDrvInit: 6
queue id:163845
Initializing…
…done initializing
Play this stream using the URL:
rtsp://192.168.1.224:8554/PSIA/Streaming/channels/1?videoCodecType=MPEG4
(We use port 8301 for optional RTSP-over-HTTP tunneling.)
ApproDrvInit: 2
ApproDrvInit: 8
queue id:163845
Initializing…
…done initializing
Play this stream using the URL:
rtsp://192.168.1.224:8555/PSIA/Streaming/channels/0?videoCodecType=MJPEG
(We use port 8302 for optional RTSP-over-HTTP tunneling.)
ApproDrvInit: 9
queue id:163845
Initializing…
…done initializing
Play this stream using the URL:
rtsp://192.168.1.224:8553/PSIA/Streaming/channels/1?videoCodecType=MPEG4
(We use port 8300 for optional RTSP-over-HTTP tunneling.)
queue id:163845
Initializing…
…done initializing
Play this stream using the URL:
rtsp://192.168.1.224:8556/PSIA/Streaming/channels/2?videoCodecType=H.264
(We use port 8303 for optional RTSP-over-HTTP tunneling.)
[host] received 2600 frames.
[host] received 2700 frames.
[host] received 2800 frames.
[host] received 2900 frames.
[host] received 3000 frames.
[m3vpss ] 186197: CAMERA: Fields = 1801 (fps = 30), Total Resets = 0 (Avg 0 ms per reset)
comeback:
我尝试改小每次写入文件的数据,程序运行就没问题了。相关代码如下:
buf = fullBitsBufList.bufs[i]->addr + fullBitsBufList.bufs[i]->startOffset; if (fwrite(buf, 10000, 1, outFile) != 1) {OSA_printf("Failed to write data to file\n");exit(0);}我怀疑是不是fwrite的耗时太长了,于是又改了一下代码,注释掉fwrite,用延时代替,
buf = fullBitsBufList.bufs[i]->addr + fullBitsBufList.bufs[i]->startOffset; //if (fwrite(buf, 10000, 1, outFile) != 1) { //OSA_printf("Failed to write data to file\n"); //exit(0); //} OSA_waitMsecs(50);从打印结果看,程序执行比之前慢了,但好歹正常执行完了。我实在想不出问题在哪里了。
comeback:
我在fwrite调用前后加打印信息,发现中间是fwrite发生了阻塞。经过十几二十分钟后,程序又会恢复正常,但诡异的是,系统的IP竟然发生了变化,比如阻塞前IP是192.168.1.168,恢复正常后,IP变成了192.168.1.224。怎么这么奇怪?
kooking:
回复 comeback:
是不是有可能存储空间不够了啊,IP地址变化是和路由器的配置也可能有关系,有些路由器配置是过一段时间后重新分配dhcp设置的IP地址的
另外,没有看懂outFile2的作用啊
comeback:
回复 kooking:
kooking,你好!
先谢谢你的回复。
应该不是空间不够。因为阻塞一段时间后程序还是有可能会继续执行的,3000帧还是会保存完整的。我还特意删掉了很多东西,确保空间足够。
outFile2是用来保存每一帧的大小,因为后面我想要测试读本地的H264文件让8127解码。
我再说一下我的环境吧。其实我是用NFS启动系统的。虽然8127和电脑是通过路由器相连接的,但路由器是关掉了DHCP服务的。另外,如果我不改动原来的usecase,程序正常执行的话,即使长时间执行也不会发生IP变化的情况。只有在我改动程序,造成程序阻塞时,才有可能出现这种情况。我也确认了程序运行一段时间后,是fwrite造成程序阻塞,但是想不通fwrite在什么情况下才会block住这么长时间。
我另外还做了一个实验。就是sys_server和其他程序都不运行,只加载几个M3的固件和IPNC_MCFW那个可执行文件,结果程序不再阻塞,顺利执行完毕。现在我估计是fwrite和其他什么操作起了冲突,造成线程block。
comeback:
回复 kooking:
经过多次试验,终于定位到了原因,问题跟/opt/ipnc路径下的脚本autorun_ipnc.sh有关。脚本中包含下列指令:
cd /opt/ipnc ./boot_proc 1& sleep 2 ./boa -C /etc & sleep 2 ./boot_proc 2& sleep 2如果将第一个boot_proc指令的参数改大一点,比如从1改成5,问题就消失了。
我看了boot_proc程序的源代码,但没看懂其作用。所以我现在的新问题是,boot_proc进程是干什么用的?
Grace huang:
回复 comeback:
请问你的那个IP会改变的问题解决了吗?我也遇到了相同的问题,不知道可都告知解决方法。
comeback:
回复 Grace huang:
Grace
我后来没做这个了,所以这些问题我也没有继续跟。
dazhi zhao:
回复 comeback:
您好!我刚接触这块,也遇到了和您类似的问题。我也是用NFS启动的,但是到一定地方就出错了。就是这里之后:
umount: can't umount /mnt/mmc: Invalid argumentkillall: dhcpcd: no process killedrm: cannot remove '/var/run/dhcpcd-eth0.pid': No such file or directory
然后就和你不一样了。我用的是IPNC_RDK 3.5 DM8127……!!相机中的内核,文件系统都是烧好的。
然后我也没法打开boot_proc,没法运行./boot_proc 1&操作
dazhi zhao:
回复 comeback:
请问怎样可以不运行sys_server和其他程序,,只加载几个M3的固件和IPNC_MCFW那个可执行文件喃???
dazhi zhao:
回复 comeback:
请问怎样可以不运行sys_server和其他程序,,只加载几个M3的固件和IPNC_MCFW那个可执行文件喃???