저는 라즈베리파이 보드와 포함된 USB 카메라를 사용하고 있습니다. 저는 avconv 도구를 사용하여 카메라에서 라이브 비디오를 캡처하고 rtp 프로토콜을 사용하여 네트워크를 통해 스트리밍합니다.
서버(Raspberry Pi 보드)에서의 내 명령은 다음과 같습니다.
avconv -f video4linux2 -s 160x120 -i /dev/video0 -vcodec mpeg2video -r 25 -pix_fmt yuv420p -me_method epzs -b 2600k -bt 256k -f rtp rtp://192.168.1.141:8554
이 명령을 사용하면 스트리밍이 성공합니다. 여기서 IP 주소 192.168.1.141은 내 클라이언트 컴퓨터의 IP 주소입니다. vlc를 사용하여 클라이언트에서 라이브 스트리밍을 성공적으로 재생할 수 있습니다.
하지만 문제는 일정 시간이 지나면 서버의 인코딩 및 스트리밍이 자동으로 중지된다는 것입니다. 명령이 거기에 걸려 있습니다.
서버의 출력은 다음과 같습니다.
$ avconv -f video4linux2 -s 160x120 -v debug -i /dev/video0 -vcodec mpeg2video -r 25 -pix_fmt yuv420p -me_method epzs -b 2600k -bt 256k -f rtp rtp://192.168.1.141:8554
avconv version 0.8.10-6:0.8.10-1+rpi1, Copyright (c) 2000-2013 the Libav developers
built on Mar 22 2014 02:13:15 with gcc 4.6.3
configuration: --arch=arm --enable-pthreads --enable-runtime-cpudetect --extra-version='6:0.8.10-1+rpi1' --libdir=/usr/lib/arm-linux-gnueabihf --prefix=/usr --disable-yasm --enable-bzlib --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-swscale --enable-libcdio --enable-x11grab --enable-libx264 --enable-libxvid --shlibdir=/usr/lib/arm-linux-gnueabihf --enable-shared --disable-static
libavutil 51. 22. 2 / 51. 22. 2
libavcodec 53. 35. 0 / 53. 35. 0
libavformat 53. 21. 1 / 53. 21. 1
libavdevice 53. 2. 0 / 53. 2. 0
libavfilter 2. 15. 0 / 2. 15. 0
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 52. 0. 0 / 52. 0. 0
[video4linux2 @ 0x54d7a0] [4]Capabilities: 84000001
[video4linux2 @ 0x54d7a0] The V4L2 driver changed the pixel format from 0x32315559 to 0x56595559
Last message repeated 1 times
[video4linux2 @ 0x54d7a0] The V4L2 driver changed the pixel format from 0x50323234 to 0x56595559
[video4linux2 @ 0x54d7a0] The V4L2 driver set input_id: 0, input: Camera 1
[rawvideo @ 0x54f860] err{or,}_recognition separate: 1; 1
[rawvideo @ 0x54f860] err{or,}_recognition combined: 1; 1
[video4linux2 @ 0x54d7a0] All info found
[video4linux2 @ 0x54d7a0] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2, from '/dev/video0':
Duration: N/A, start: 21891.364784, bitrate: 9216 kb/s
Stream #0.0, 1, 1/1000000: Video: rawvideo, yuyv422, 160x120, 1/30, 9216 kb/s, 30 tbr, 1000k tbn, 30 tbc
[buffer @ 0x54f220] w:160 h:120 pixfmt:yuyv422
[avsink @ 0x54d740] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0x54f7e0] w:160 h:120 fmt:yuyv422 -> w:160 h:120 fmt:yuv420p flags:0x4
[mpeg2video @ 0x54ea60] err{or,}_recognition separate: 1; 1
[mpeg2video @ 0x54ea60] err{or,}_recognition combined: 1; 1
[mpeg2video @ 0x54ea60] detected 1 logical cores
[mpeg2video @ 0x54ea60] Unsupported bit depth: 0
[rawvideo @ 0x54f860] err{or,}_recognition separate: 1; 1
[rawvideo @ 0x54f860] err{or,}_recognition combined: 1; 1
Output #0, rtp, to 'rtp://192.168.1.141:8554':
Metadata:
encoder : Lavf53.21.1
Stream #0.0, 0, 1/90000: Video: mpeg2video, yuv420p, 160x120, 1/25, q=2-31, 2600 kb/s, 90k tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo -> mpeg2video)
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.1.141
t=0 0
a=tool:libavformat 53.21.1
m=video 8554 RTP/AVP 32
b=AS:2600
Press ctrl-c to stop encoding
*** drop!
Last message repeated 1 times
*** 1 dup!
*** 16 dup! fps= 25 q=2.0 size= 1027kB time=5.24 bitrate=1605.2kbits/s dup=1 drop=2
*** drop!
Last message repeated 11 times
*** drop!49 fps= 26 q=2.0 size= 1059kB time=5.92 bitrate=1464.9kbits/s dup=17 drop=14
Last message repeated 2 times
*** drop!76 fps= 25 q=2.0 size= 2022kB time=11.00 bitrate=1505.7kbits/s dup=17 drop=17
*** drop!48 fps= 25 q=2.0 size= 4086kB time=21.88 bitrate=1529.8kbits/s dup=17 drop=18
*** 1 dup!
*** 1 dup!0 fps= 25 q=2.0 size= 4171kB time=22.36 bitrate=1528.2kbits/s dup=18 drop=19
*** 1 dup!1 fps= 25 q=2.0 size= 4859kB time=26.00 bitrate=1530.8kbits/s dup=19 drop=19
*** 1 dup!0 fps= 25 q=2.0 size= 5152kB time=27.56 bitrate=1531.5kbits/s dup=20 drop=19
*** 1 dup!3 fps= 25 q=2.0 size= 5250kB time=28.08 bitrate=1531.7kbits/s dup=21 drop=19
*** drop!64 fps= 25 q=2.0 size= 7215kB time=38.52 bitrate=1534.5kbits/s dup=22 drop=19
*** 1 dup!6 fps= 25 q=2.0 size= 7306kB time=39.00 bitrate=1534.6kbits/s dup=22 drop=20
*** drop!07 fps= 25 q=2.0 size= 8288kB time=44.24 bitrate=1534.7kbits/s dup=23 drop=20
*** 1 dup!0 fps= 25 q=2.0 size= 10054kB time=53.56 bitrate=1537.8kbits/s dup=23 drop=21
*** 1 dup!9 fps= 25 q=2.0 size= 10342kB time=55.12 bitrate=1537.1kbits/s dup=24 drop=21
Last message repeated 1 times
*** drop!93 fps= 25 q=1.6 size= 10445kB time=55.68 bitrate=1536.7kbits/s dup=26 drop=21
*** 1 dup!
*** 7036829 dup! 25 q=2.0 size= 10630kB time=56.68 bitrate=1536.4kbits/s dup=27 drop=22
어떤 아이디어가 있나요?
미리 감사드립니다.
편집하다:
산출v4l2-ctl --list-formats-ext명령은 다음과 같습니다.
pi@raspberrypi ~ $ v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUV 4:2:2 (YUYV)
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Size: Discrete 352x288
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Size: Discrete 320x240
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Size: Discrete 176x144
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Size: Discrete 160x120
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)