- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用树莓派Model 3和摄像头模块通过WiFi网络流式传输视频,但是遇到了一些与我在网上发现的其他示例不一致的情况。我正在尝试获得此视频中进行的第3次测试的结果:https://www.youtube.com/watch?v=sYGdge3T30o
我可以看到数据正在通过网络流传输到所创建的fifo264
文件中,并且我还有一个运行正常的python脚本,该脚本运行了几分钟之后,视频馈送无法再处理。
OS X计算机上显示的视频最终崩溃。我不确定我的问题是否存在于我如何生成和发送视频(从Raspberry Pi方面),或者我如何使用python处理视频并进行处理。
我试图确定可能导致我的问题的平台差异,该问题主要关注mkfifo
和netcat
权限以及这些程序在不同平台之间的行为方式之间的可能差异。
此bash脚本正在OS X 10.12.6上使用。我试图在端口777上侦听正在创建并发送到此计算机的提要。
#!/bin/bash
if [ -p fifo264 ]
then
rm fifo264
fi
mkfifo fifo264
nc -l -v 777 > fifo264
./makeFifo.sh
后,将在工作目录中创建管道
fifo264
,它继承了用户的用户权限。
sudo ./makeFifo.sh
导致
ls -l
为
prw-r--r-- 1 root staff 0 Feb 4 12:12 fifo264
./makeFifo.sh
导致
ls -l
为
prw-r--r-- 1 user staff 0 Feb 4 12:12 fifo264
-m 0777
和
mkfifo
结果
mkfifo -m 0777 fifo264
。使用适当的权限创建管道,但是netcat无法建立打开的
777/tcp open multiling-http
。我正在运行
nmap -sS -O localhost
进行测试。如果使用机器的IP地址,结果是相同的。
sudo nc -l -v 777 > fifo264
来使netcat在OS X 10.12.6上创建开放的777端口。
777/tcp open multiling-http
,但不会创建管道。
ls -l
输出:
-rw-r--r-- 1 user staff 0 Feb 4 12:26 fifo264
请注意权限字符串中缺少的
p
。
mkfifo fifo264
创建管道,然后继续执行
sudo nc -l -v 777 > fifo264
,则会创建管道,但netcat不会在端口777上进行侦听。
videoFeed.py
如下:
import cv2
import subprocess as sp
import numpy
FFMPEG_BIN = "ffmpeg"
command = [ FFMPEG_BIN,
'-i', 'fifo264', # fifo is the named pipe
'-pix_fmt', 'bgr24', # opencv requires bgr24 pixel format.
'-vcodec', 'rawvideo',
'-an','-sn', # we want to disable audio processing (there is no audio)
'-f', 'image2pipe', '-']
pipe = sp.Popen(command, stdout = sp.PIPE, bufsize=10**8)
while True:
# Capture frame-by-frame
raw_image = pipe.stdout.read(640*480*3)
# transform the byte read into a numpy array
image = numpy.fromstring(raw_image, dtype='uint8')
image = image.reshape((480,640,3)) # Notice how height is specified first and then width
if image is not None:
cv2.imshow('Video', image)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
pipe.stdout.flush()
cv2.destroyAllWindows()
streamVideo.sh
。
#!/bin/bash
raspivid -vf -n -w 640 -h 480 -o - -t 0 -b 1200000 | nc -v 10.0.0.3 777
sudo nc -l -v 777 > fifo264
,从而导致以下nmap扫描:
Host is up (0.00015s latency).
Not shown: 993 closed ports
PORT STATE SERVICE
80/tcp open http
445/tcp open microsoft-ds
548/tcp open afp
777/tcp open multiling-http
streamVideo.sh
:
Connection to 10.0.0.3 777 port [tcp/moira-update] succeeded!
python3 videoFeed.py
fifo264
提要。如果我在几秒钟后开始
videoFeed.py
,尽管质量还可以,但python脚本会从头开始显着延迟显示视频供稿。
videoFeed.py
脚本后立即启动
streamVideo.sh
,则延迟不存在,但是图像质量太差了。此屏幕快照是我在镜头前移动手的镜头。
videoFeed.py
python脚本的整个输出。
ffmpeg version N-78264-g9079e99-tessus Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --as=yasm --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-version3 --disable-ffplay --disable-indev=qtkit --disable-indev=x11grab_xcb
libavutil 55. 15.100 / 55. 15.100
libavcodec 57. 22.102 / 57. 22.102
libavformat 57. 23.100 / 57. 23.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 27.100 / 6. 27.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, h264, from 'fifo264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p, 640x480, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Output #0, image2pipe, to 'pipe:':
Metadata:
encoder : Lavf57.23.100
Stream #0:0: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 640x480, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc57.22.102 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[h264 @ 0x7f813c831800] error while decoding MB 6 6, bytestream -5
[h264 @ 0x7f813c831800] concealing 1003 DC, 1003 AC, 1003 MV errors in P frame
[h264 @ 0x7f813c873200] error while decoding MB 30 20, bytestream -2884320.0kbits/s speed=1.43x
[h264 @ 0x7f813c873200] concealing 419 DC, 419 AC, 419 MV errors in P frame
[NULL @ 0x7f813c808000] missing picture in access unit with size 919
[h264 @ 0x7f813c866000] no frame!
[h264 @ 0x7f813c824600] error while decoding MB 7 15, bytestream -7
[h264 @ 0x7f813c824600] concealing 642 DC, 642 AC, 642 MV errors in P frame
Error while decoding stream #0:0: Invalid data found when processing input.0kbits/s dup=2 drop=0 speed=1.42x
[h264 @ 0x7f813c858e00] error while decoding MB 39 17, bytestream -6
[h264 @ 0x7f813c858e00] concealing 530 DC, 530 AC, 530 MV errors in P frame
[h264 @ 0x7f813c821600] error while decoding MB 17 28, bytestream -6
[h264 @ 0x7f813c821600] concealing 112 DC, 112 AC, 112 MV errors in P frame
[h264 @ 0x7f813c880400] error while decoding MB 31 21, bytestream -5
[h264 @ 0x7f813c880400] concealing 378 DC, 378 AC, 378 MV errors in P frame
[h264 @ 0x7f813c83ea00] error while decoding MB 38 18, bytestream -5
[h264 @ 0x7f813c83ea00] concealing 491 DC, 491 AC, 491 MV errors in P frame
[h264 @ 0x7f813c880400] error while decoding MB 20 24, bytestream -5184320.0kbits/s dup=7 drop=0 speed=1.43x
[h264 @ 0x7f813c880400] concealing 269 DC, 269 AC, 269 MV errors in P frame
[h264 @ 0x7f813c84bc00] error while decoding MB 29 27, bytestream -6
[h264 @ 0x7f813c84bc00] concealing 140 DC, 140 AC, 140 MV errors in P frame
[h264 @ 0x7f813c83ea00] error while decoding MB 36 0, bytestream -10
[h264 @ 0x7f813c83ea00] concealing 1200 DC, 1200 AC, 1200 MV errors in P frame
[h264 @ 0x7f813c873200] error while decoding MB 15 7, bytestream -9=184320.0kbits/s dup=9 drop=0 speed=1.42x
[h264 @ 0x7f813c873200] concealing 954 DC, 954 AC, 954 MV errors in P frame
[h264 @ 0x7f813c824600] error while decoding MB 39 0, bytestream -25
[h264 @ 0x7f813c824600] concealing 1200 DC, 1200 AC, 1200 MV errors in P frame
[h264 @ 0x7f813c84bc00] error while decoding MB 34 24, bytestream -6
[h264 @ 0x7f813c84bc00] concealing 255 DC, 255 AC, 255 MV errors in P frame
[h264 @ 0x7f813c821600] error while decoding MB 32 21, bytestream -6184320.0kbits/s dup=15 drop=0 speed=1.44x
[h264 @ 0x7f813c821600] concealing 377 DC, 377 AC, 377 MV errors in P frame
[h264 @ 0x7f813c858e00] error while decoding MB 28 22, bytestream -6
[h264 @ 0x7f813c858e00] concealing 341 DC, 341 AC, 341 MV errors in P frame
[h264 @ 0x7f813c880400] error while decoding MB 4 29, bytestream -8
[h264 @ 0x7f813c880400] concealing 85 DC, 85 AC, 85 MV errors in P frame
[h264 @ 0x7f813c873200] error while decoding MB 7 18, bytestream -6=184320.0kbits/s dup=17 drop=0 speed=1.44x
[h264 @ 0x7f813c873200] concealing 522 DC, 522 AC, 522 MV errors in P frame
[h264 @ 0x7f813c866000] error while decoding MB 31 24, bytestream -10
[h264 @ 0x7f813c866000] concealing 258 DC, 258 AC, 258 MV errors in P frame
[h264 @ 0x7f813c84bc00] error while decoding MB 23 28, bytestream -30
[h264 @ 0x7f813c84bc00] concealing 106 DC, 106 AC, 106 MV errors in P frame
[h264 @ 0x7f813c880400] error while decoding MB 15 29, bytestream -9184320.0kbits/s dup=21 drop=0 speed=1.44x
[h264 @ 0x7f813c880400] concealing 74 DC, 74 AC, 74 MV errors in P frame
[h264 @ 0x7f813c84bc00] error while decoding MB 26 26, bytestream -5
[h264 @ 0x7f813c84bc00] concealing 183 DC, 183 AC, 183 MV errors in P frame
[h264 @ 0x7f813c880400] error while decoding MB 37 14, bytestream -5
[h264 @ 0x7f813c880400] concealing 652 DC, 652 AC, 652 MV errors in P frame
[h264 @ 0x7f813c831800] error while decoding MB 36 24, bytestream -6
[h264 @ 0x7f813c831800] concealing 253 DC, 253 AC, 253 MV errors in P frame
[h264 @ 0x7f813c880400] error while decoding MB 25 26, bytestream -5184320.0kbits/s dup=23 drop=0 speed=1.44x
[h264 @ 0x7f813c880400] concealing 184 DC, 184 AC, 184 MV errors in P frame
[h264 @ 0x7f813c824600] error while decoding MB 37 2, bytestream -6
[h264 @ 0x7f813c824600] concealing 1132 DC, 1132 AC, 1132 MV errors in P frame
[h264 @ 0x7f813c84bc00] error while decoding MB 33 23, bytestream -7
[h264 @ 0x7f813c84bc00] concealing 296 DC, 296 AC, 296 MV errors in P frame
[h264 @ 0x7f813c821600] error while decoding MB 32 16, bytestream -5184320.0kbits/s dup=26 drop=0 speed=1.44x
[h264 @ 0x7f813c821600] concealing 577 DC, 577 AC, 577 MV errors in P frame
[h264 @ 0x7f813c880400] error while decoding MB 1 26, bytestream -6
[h264 @ 0x7f813c880400] concealing 208 DC, 208 AC, 208 MV errors in P frame
[h264 @ 0x7f813c84bc00] error while decoding MB 32 12, bytestream -6184320.0kbits/s dup=28 drop=0 speed=1.43x
[h264 @ 0x7f813c84bc00] concealing 737 DC, 737 AC, 737 MV errors in P frame
[h264 @ 0x7f813c880400] error while decoding MB 27 26, bytestream -8
[h264 @ 0x7f813c880400] concealing 182 DC, 182 AC, 182 MV errors in P frame
[h264 @ 0x7f813c84bc00] error while decoding MB 27 27, bytestream -5
[h264 @ 0x7f813c84bc00] concealing 142 DC, 142 AC, 142 MV errors in P frame
[h264 @ 0x7f813c831800] error while decoding MB 23 20, bytestream -7
[h264 @ 0x7f813c831800] concealing 426 DC, 426 AC, 426 MV errors in P frame
[h264 @ 0x7f813c858e00] error while decoding MB 29 26, bytestream -5184320.0kbits/s dup=31 drop=0 speed=1.43x
[h264 @ 0x7f813c858e00] concealing 180 DC, 180 AC, 180 MV errors in P frame
[h264 @ 0x7f813c821600] error while decoding MB 26 26, bytestream -5
[h264 @ 0x7f813c821600] concealing 183 DC, 183 AC, 183 MV errors in P frame
[h264 @ 0x7f813c858e00] error while decoding MB 27 27, bytestream -9
[h264 @ 0x7f813c858e00] concealing 142 DC, 142 AC, 142 MV errors in P frame
[h264 @ 0x7f813c824600] error while decoding MB 30 4, bytestream -8
[h264 @ 0x7f813c824600] concealing 1059 DC, 1059 AC, 1059 MV errors in P frame
[h264 @ 0x7f813c858e00] error while decoding MB 9 22, bytestream -5=184320.0kbits/s dup=33 drop=0 speed=1.42x
[h264 @ 0x7f813c858e00] concealing 360 DC, 360 AC, 360 MV errors in P frame
[h264 @ 0x7f813c873200] error while decoding MB 25 13, bytestream -12
[h264 @ 0x7f813c873200] concealing 704 DC, 704 AC, 704 MV errors in P frame
[h264 @ 0x7f813c880400] error while decoding MB 14 1, bytestream -9
[h264 @ 0x7f813c880400] concealing 1195 DC, 1195 AC, 1195 MV errors in P frame
[h264 @ 0x7f813c821600] error while decoding MB 29 23, bytestream -9
[h264 @ 0x7f813c821600] concealing 300 DC, 300 AC, 300 MV errors in P frame
[h264 @ 0x7f813c824600] error while decoding MB 30 25, bytestream -10
[h264 @ 0x7f813c824600] concealing 219 DC, 219 AC, 219 MV errors in P frame
[h264 @ 0x7f813c831800] error while decoding MB 27 27, bytestream -8
[h264 @ 0x7f813c831800] concealing 142 DC, 142 AC, 142 MV errors in P frame
[h264 @ 0x7f813c83ea00] error while decoding MB 13 23, bytestream -6184320.0kbits/s dup=34 drop=0 speed=1.42x
[h264 @ 0x7f813c83ea00] concealing 316 DC, 316 AC, 316 MV errors in P frame
[h264 @ 0x7f813c84bc00] error while decoding MB 37 12, bytestream -5
[h264 @ 0x7f813c84bc00] concealing 732 DC, 732 AC, 732 MV errors in P frame
[h264 @ 0x7f813c866000] error while decoding MB 27 2, bytestream -6
[h264 @ 0x7f813c866000] concealing 1142 DC, 1142 AC, 1142 MV errors in P frame
[h264 @ 0x7f813c873200] error while decoding MB 22 25, bytestream -10
[h264 @ 0x7f813c873200] concealing 227 DC, 227 AC, 227 MV errors in P frame
[h264 @ 0x7f813c880400] error while decoding MB 5 15, bytestream -6
[h264 @ 0x7f813c880400] concealing 644 DC, 644 AC, 644 MV errors in P frame
[h264 @ 0x7f813c84bc00] error while decoding MB 27 13, bytestream -8
[h264 @ 0x7f813c84bc00] concealing 702 DC, 702 AC, 702 MV errors in P frame
[h264 @ 0x7f813c858e00] error while decoding MB 33 15, bytestream -12
[h264 @ 0x7f813c858e00] concealing 616 DC, 616 AC, 616 MV errors in P frame
[h264 @ 0x7f813c866000] error while decoding MB 39 16, bytestream -5
[h264 @ 0x7f813c866000] concealing 570 DC, 570 AC, 570 MV errors in P frame
[h264 @ 0x7f813c831800] error while decoding MB 27 29, bytestream -8
[h264 @ 0x7f813c831800] concealing 62 DC, 62 AC, 62 MV errors in P frame
[h264 @ 0x7f813c873200] error while decoding MB 35 29, bytestream -5184320.0kbits/s dup=38 drop=0 speed=1.42x
[h264 @ 0x7f813c873200] concealing 54 DC, 54 AC, 54 MV errors in P frame
[h264 @ 0x7f813c821600] error while decoding MB 32 14, bytestream -14
[h264 @ 0x7f813c821600] concealing 657 DC, 657 AC, 657 MV errors in P frame
[h264 @ 0x7f813c824600] error while decoding MB 29 22, bytestream -7
[h264 @ 0x7f813c824600] concealing 340 DC, 340 AC, 340 MV errors in P frame
[h264 @ 0x7f813c831800] error while decoding MB 8 13, bytestream -7
[h264 @ 0x7f813c831800] concealing 721 DC, 721 AC, 721 MV errors in P frame
[NULL @ 0x7f813c808000] missing picture in access unit with size 1448
[h264 @ 0x7f813c83ea00] no frame!
[h264 @ 0x7f813c84bc00] error while decoding MB 9 16, bytestream -19
[h264 @ 0x7f813c84bc00] concealing 600 DC, 600 AC, 600 MV errors in P frame
[h264 @ 0x7f813c858e00] error while decoding MB 24 18, bytestream -16
[h264 @ 0x7f813c858e00] concealing 505 DC, 505 AC, 505 MV errors in P frame
Error while decoding stream #0:0: Invalid data found when processing input
[h264 @ 0x7f813c866000] error while decoding MB 22 13, bytestream -5
[h264 @ 0x7f813c866000] concealing 707 DC, 707 AC, 707 MV errors in P frame
[h264 @ 0x7f813c880400] error while decoding MB 11 29, bytestream -6
[h264 @ 0x7f813c880400] concealing 78 DC, 78 AC, 78 MV errors in P frame
[h264 @ 0x7f813c821600] error while decoding MB 38 14, bytestream -6
[h264 @ 0x7f813c821600] concealing 651 DC, 651 AC, 651 MV errors in P frame
[h264 @ 0x7f813c824600] error while decoding MB 6 17, bytestream -6
[h264 @ 0x7f813c824600] concealing 563 DC, 563 AC, 563 MV errors in P frame
[h264 @ 0x7f813c83ea00] error while decoding MB 19 27, bytestream -5
[h264 @ 0x7f813c83ea00] concealing 150 DC, 150 AC, 150 MV errors in P frame
[h264 @ 0x7f813c84bc00] error while decoding MB 18 17, bytestream -9
[h264 @ 0x7f813c84bc00] concealing 551 DC, 551 AC, 551 MV errors in P frame
[h264 @ 0x7f813c858e00] error while decoding MB 38 9, bytestream -16
[h264 @ 0x7f813c858e00] concealing 851 DC, 851 AC, 851 MV errors in P frame
[h264 @ 0x7f813c880400] error while decoding MB 8 19, bytestream -7=184320.0kbits/s dup=41 drop=0 speed=1.42x
[h264 @ 0x7f813c880400] concealing 481 DC, 481 AC, 481 MV errors in P frame
[h264 @ 0x7f813c821600] error while decoding MB 24 21, bytestream -14
[h264 @ 0x7f813c821600] concealing 385 DC, 385 AC, 385 MV errors in P frame
[h264 @ 0x7f813c873200] error while decoding MB 26 23, bytestream -5
[h264 @ 0x7f813c873200] concealing 303 DC, 303 AC, 303 MV errors in P frame
[h264 @ 0x7f813c83ea00] error while decoding MB 31 26, bytestream -25
[h264 @ 0x7f813c83ea00] concealing 178 DC, 178 AC, 178 MV errors in P frame
[h264 @ 0x7f813c866000] error while decoding MB 25 28, bytestream -6
[h264 @ 0x7f813c866000] concealing 104 DC, 104 AC, 104 MV errors in P frame
[h264 @ 0x7f813c821600] error while decoding MB 23 29, bytestream -1284320.0kbits/s dup=44 drop=0 speed=1.42x
[h264 @ 0x7f813c821600] concealing 66 DC, 66 AC, 66 MV errors in P frame
[h264 @ 0x7f813c831800] error while decoding MB 23 20, bytestream -19
[h264 @ 0x7f813c831800] concealing 426 DC, 426 AC, 426 MV errors in P frame
[h264 @ 0x7f813c84bc00] error while decoding MB 27 26, bytestream -10
[h264 @ 0x7f813c84bc00] concealing 182 DC, 182 AC, 182 MV errors in P frame
[h264 @ 0x7f813c858e00] error while decoding MB 31 26, bytestream -10
[h264 @ 0x7f813c858e00] concealing 178 DC, 178 AC, 178 MV errors in P frame
[h264 @ 0x7f813c866000] error while decoding MB 8 25, bytestream -8
[h264 @ 0x7f813c866000] concealing 241 DC, 241 AC, 241 MV errors in P frame
[h264 @ 0x7f813c873200] error while decoding MB 39 27, bytestream -8
[h264 @ 0x7f813c873200] concealing 130 DC, 130 AC, 130 MV errors in P frame
[h264 @ 0x7f813c83ea00] error while decoding MB 26 13, bytestream -10
[h264 @ 0x7f813c83ea00] concealing 703 DC, 703 AC, 703 MV errors in P frame
[h264 @ 0x7f813c866000] error while decoding MB 5 23, bytestream -6
[h264 @ 0x7f813c866000] concealing 324 DC, 324 AC, 324 MV errors in P frame
[h264 @ 0x7f813c880400] error while decoding MB 39 4, bytestream -9=184320.0kbits/s dup=47 drop=0 speed=1.41x
[h264 @ 0x7f813c880400] concealing 1050 DC, 1050 AC, 1050 MV errors in P frame
[h264 @ 0x7f813c821600] error while decoding MB 27 27, bytestream -5
[h264 @ 0x7f813c821600] concealing 142 DC, 142 AC, 142 MV errors in P frame
[h264 @ 0x7f813c84bc00] error while decoding MB 18 3, bytestream -7
[h264 @ 0x7f813c84bc00] concealing 1111 DC, 1111 AC, 1111 MV errors in P frame
[h264 @ 0x7f813c873200] error while decoding MB 39 19, bytestream -8
[h264 @ 0x7f813c873200] concealing 450 DC, 450 AC, 450 MV errors in P frame
[h264 @ 0x7f813c866000] error while decoding MB 28 23, bytestream -6
[h264 @ 0x7f813c866000] concealing 301 DC, 301 AC, 301 MV errors in P frame
[h264 @ 0x7f813c824600] error while decoding MB 35 7, bytestream -5=184320.0kbits/s dup=51 drop=0 speed=1.41x
[h264 @ 0x7f813c824600] concealing 934 DC, 934 AC, 934 MV errors in P frame
[h264 @ 0x7f813c83ea00] error while decoding MB 19 29, bytestream -7
[h264 @ 0x7f813c83ea00] concealing 70 DC, 70 AC, 70 MV errors in P frame
[h264 @ 0x7f813c873200] error while decoding MB 37 16, bytestream -6
[h264 @ 0x7f813c873200] concealing 572 DC, 572 AC, 572 MV errors in P frame
[h264 @ 0x7f813c831800] error while decoding MB 16 12, bytestream -5
[h264 @ 0x7f813c831800] concealing 753 DC, 753 AC, 753 MV errors in P frame
[h264 @ 0x7f813c866000] error while decoding MB 29 13, bytestream -6
[h264 @ 0x7f813c866000] concealing 700 DC, 700 AC, 700 MV errors in P frame
[h264 @ 0x7f813c821600] error while decoding MB 31 8, bytestream -6=184320.0kbits/s dup=55 drop=0 speed=1.42x
[h264 @ 0x7f813c821600] concealing 898 DC, 898 AC, 898 MV errors in P frame
[h264 @ 0x7f813c84bc00] error while decoding MB 11 22, bytestream -6
[h264 @ 0x7f813c84bc00] concealing 358 DC, 358 AC, 358 MV errors in P frame
frame= 400 fps= 35 q=-0.0 Lsize= 360000kB time=00:00:16.00 bitrate=184320.0kbits/s dup=56 drop=0 speed=1.41x
video:360000kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
Traceback (most recent call last):
File "videoFeed.py", line 19, in <module>
image = image.reshape((480,640,3)) # Notice how height is specified first and then width
ValueError: cannot reshape array of size 0 into shape (480,640,3)
sudo nc -l 777 | mplayer -fps 200 -demuxer h264es -
import cv2
import sys
video_capture = cv2.VideoCapture(r'fifo264')
video_capture.set(cv2.CAP_PROP_FRAME_WIDTH, 640);
video_capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 480);
while True:
# Capture frame-by-frame
ret, frame = video_capture.read()
if ret == False:
pass
cv2.imshow('Video', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything is done, release the capture
video_capture.release()
cv2.destroyAllWindows()
#!/bin/bash
raspivid -ih -vs -vf -n -w 640 -h 480 -o - -t 0 -b 2000000 | nc -v 10.0.0.3 777
[h264 @ 0x7fb25005d400] error while decoding MB 22 28, bytestream -8
[h264 @ 0x7fb250068c00] error while decoding MB 8 24, bytestream -9
[h264 @ 0x7fb25005d400] error while decoding MB 2 18, bytestream -5
[h264 @ 0x7fb250060400] error while decoding MB 23 11, bytestream -7
[h264 @ 0x7fb250073000] error while decoding MB 22 18, bytestream -11
[h264 @ 0x7fb250073600] error while decoding MB 36 9, bytestream -5
[h264 @ 0x7fb250067a00] error while decoding MB 29 23, bytestream -8
[NULL @ 0x7fb251155a00] missing picture in access unit with size 1448
[h264 @ 0x7fb251155400] Got unexpected packet size after a partial decode
[h264 @ 0x7fb251155400] Got unexpected packet size after a partial decode
[h264 @ 0x7fb251155400] Got unexpected packet size after a partial decode
[NULL @ 0x7fb251155a00] missing picture in access unit with size 1448
[h264 @ 0x7fb251155400] Got unexpected packet size after a partial decode
[h264 @ 0x7fb25005d400] error while decoding MB 35 2, bytestream -6
[NULL @ 0x7fb251155a00] missing picture in access unit with size 1200
[h264 @ 0x7fb25005d400] No start code is found.
[h264 @ 0x7fb25005d400] Error splitting the input into NAL units.
OpenCV(3.4.0-dev) Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /Users/jamie/opencv/modules/highgui/src/window.cpp, line 356
Traceback (most recent call last):
File "video3.py", line 14, in <module>
cv2.imshow('Video', frame)
cv2.error: OpenCV(3.4.0-dev) /Users/jamie/opencv/modules/highgui/src/window.cpp:356: error: (-215) size.width>0 && size.height>0 in function imshow
最佳答案
最终,这不是管道,平台或权限的结果。在Raspberry Pi上生成并通过管道传输到python脚本的视频未得到正确处理。
我最终适应了这个picamera python recipe
在Raspberry Pi上:(createStream.py)
import io
import socket
import struct
import time
import picamera
# Connect a client socket to my_server:8000 (change my_server to the
# hostname of your server)
client_socket = socket.socket()
client_socket.connect(('10.0.0.3', 777))
# Make a file-like object out of the connection
connection = client_socket.makefile('wb')
try:
with picamera.PiCamera() as camera:
camera.resolution = (1024, 768)
# Start a preview and let the camera warm up for 2 seconds
camera.start_preview()
time.sleep(2)
# Note the start time and construct a stream to hold image data
# temporarily (we could write it directly to connection but in this
# case we want to find out the size of each capture first to keep
# our protocol simple)
start = time.time()
stream = io.BytesIO()
for foo in camera.capture_continuous(stream, 'jpeg', use_video_port=True):
# Write the length of the capture to the stream and flush to
# ensure it actually gets sent
connection.write(struct.pack('<L', stream.tell()))
connection.flush()
# Rewind the stream and send the image data over the wire
stream.seek(0)
connection.write(stream.read())
# Reset the stream for the next capture
stream.seek(0)
stream.truncate()
# Write a length of zero to the stream to signal we're done
connection.write(struct.pack('<L', 0))
finally:
connection.close()
client_socket.close()
import io
import socket
import struct
import cv2
import numpy as np
# Start a socket listening for connections on 0.0.0.0:8000 (0.0.0.0 means
# all interfaces)
server_socket = socket.socket()
server_socket.bind(('0.0.0.0', 777))
server_socket.listen(0)
# Accept a single connection and make a file-like object out of it
connection = server_socket.accept()[0].makefile('rb')
try:
while True:
# Read the length of the image as a 32-bit unsigned int. If the
# length is zero, quit the loop
image_len = struct.unpack('<L', connection.read(struct.calcsize('<L')))[0]
if not image_len:
break
# Construct a stream to hold the image data and read the image
# data from the connection
image_stream = io.BytesIO()
image_stream.write(connection.read(image_len))
# Rewind the stream, open it as an image with opencv and do some
# processing on it
image_stream.seek(0)
image = Image.open(image_stream)
data = np.fromstring(image_stream.getvalue(), dtype=np.uint8)
imagedisp = cv2.imdecode(data, 1)
cv2.imshow("Frame",imagedisp)
cv2.waitKey(1) #imshow will not output an image if you do not use waitKey
cv2.destroyAllWindows() #cleanup windows
finally:
connection.close()
server_socket.close()
关于python - 网络摄像机流中的Raspberry Pi 3 Python和OpenCV人脸识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48611517/
我正在处理一组标记为 160 个组的 173k 点。我想通过合并最接近的(到 9 或 10 个组)来减少组/集群的数量。我搜索过 sklearn 或类似的库,但没有成功。 我猜它只是通过 knn 聚类
我有一个扁平数字列表,这些数字逻辑上以 3 为一组,其中每个三元组是 (number, __ignored, flag[0 or 1]),例如: [7,56,1, 8,0,0, 2,0,0, 6,1,
我正在使用 pipenv 来管理我的包。我想编写一个 python 脚本来调用另一个使用不同虚拟环境(VE)的 python 脚本。 如何运行使用 VE1 的 python 脚本 1 并调用另一个 p
假设我有一个文件 script.py 位于 path = "foo/bar/script.py"。我正在寻找一种在 Python 中通过函数 execute_script() 从我的主要 Python
这听起来像是谜语或笑话,但实际上我还没有找到这个问题的答案。 问题到底是什么? 我想运行 2 个脚本。在第一个脚本中,我调用另一个脚本,但我希望它们继续并行,而不是在两个单独的线程中。主要是我不希望第
我有一个带有 python 2.5.5 的软件。我想发送一个命令,该命令将在 python 2.7.5 中启动一个脚本,然后继续执行该脚本。 我试过用 #!python2.7.5 和http://re
我在 python 命令行(使用 python 2.7)中,并尝试运行 Python 脚本。我的操作系统是 Windows 7。我已将我的目录设置为包含我所有脚本的文件夹,使用: os.chdir("
剧透:部分解决(见最后)。 以下是使用 Python 嵌入的代码示例: #include int main(int argc, char** argv) { Py_SetPythonHome
假设我有以下列表,对应于及时的股票价格: prices = [1, 3, 7, 10, 9, 8, 5, 3, 6, 8, 12, 9, 6, 10, 13, 8, 4, 11] 我想确定以下总体上最
所以我试图在选择某个单选按钮时更改此框架的背景。 我的框架位于一个类中,并且单选按钮的功能位于该类之外。 (这样我就可以在所有其他框架上调用它们。) 问题是每当我选择单选按钮时都会出现以下错误: co
我正在尝试将字符串与 python 中的正则表达式进行比较,如下所示, #!/usr/bin/env python3 import re str1 = "Expecting property name
考虑以下原型(prototype) Boost.Python 模块,该模块从单独的 C++ 头文件中引入类“D”。 /* file: a/b.cpp */ BOOST_PYTHON_MODULE(c)
如何编写一个程序来“识别函数调用的行号?” python 检查模块提供了定位行号的选项,但是, def di(): return inspect.currentframe().f_back.f_l
我已经使用 macports 安装了 Python 2.7,并且由于我的 $PATH 变量,这就是我输入 $ python 时得到的变量。然而,virtualenv 默认使用 Python 2.6,除
我只想问如何加快 python 上的 re.search 速度。 我有一个很长的字符串行,长度为 176861(即带有一些符号的字母数字字符),我使用此函数测试了该行以进行研究: def getExe
list1= [u'%app%%General%%Council%', u'%people%', u'%people%%Regional%%Council%%Mandate%', u'%ppp%%Ge
这个问题在这里已经有了答案: Is it Pythonic to use list comprehensions for just side effects? (7 个答案) 关闭 4 个月前。 告
我想用 Python 将两个列表组合成一个列表,方法如下: a = [1,1,1,2,2,2,3,3,3,3] b= ["Sun", "is", "bright", "June","and" ,"Ju
我正在运行带有最新 Boost 发行版 (1.55.0) 的 Mac OS X 10.8.4 (Darwin 12.4.0)。我正在按照说明 here构建包含在我的发行版中的教程 Boost-Pyth
学习 Python,我正在尝试制作一个没有任何第 3 方库的网络抓取工具,这样过程对我来说并没有简化,而且我知道我在做什么。我浏览了一些在线资源,但所有这些都让我对某些事情感到困惑。 html 看起来
我是一名优秀的程序员,十分优秀!