KonradIT / gopro-py-api

Unofficial GoPro API Library for Python - connect to GoPro via WiFi.
MIT License
1.38k stars 211 forks source link

GoPro Hero 8 Black | Getting "Packet corrupt" errors when calling "gopro.stream()" and "gopro.overview()" throws error too. #171

Open simspace-dev opened 3 years ago

simspace-dev commented 3 years ago

Hi @KonradIT,

I am trying to stream GoPro Hero 8 Black video to MPV as shown in this video called "GoPro HERO7 with Python API": https://www.youtube.com/watch?v=i-X4fPVfoW0

I am on Mac OS Catalina running Python 3.9 and I installed gopro-py-api as follows: pip install goprocam

I can ...

Error 1 | gopro.stream("udp://127.0.0.1:10000") displays "packet corrupt" messages See the command line output at the bottom of this post.

Error 2 | gopro.overview() throws this error:

camera overview
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/my.user.name/.pyenv/versions/3.9.2/lib/python3.9/site-packages/goprocam/GoProCamera.py", line 1472, in overview
    print("current mode: " + "" + self.parse_value("mode",
TypeError: can only concatenate str (not "NoneType") to str
>>> gopro.overview()
camera overview
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/my.user.name/.pyenv/versions/3.9.2/lib/python3.9/site-packages/goprocam/GoProCamera.py", line 1473, in overview
    self.getStatus(constants.Status.Status, constants.Status.STATUS.Mode)))
  File "/Users/my.user.name/.pyenv/versions/3.9.2/lib/python3.9/site-packages/goprocam/GoProCamera.py", line 292, in getStatus
    return json.loads(data)[param][value]
KeyError: '43'

I did set a breakpoint() in the overview() method in "GoProCamera.py" and found there is no STATUS.mode with a key of "43" in the raw status data, but I do see a key with "43" in the settings json object. Should this be getting settings data instead of status data?

Do you have any suggestions or ideas how I can resolve these issues?

Thanks, Chris

[CLI log of "Packet corrupt" messages]

>>> gopro.stream("udp://127.0.0.1:10000")
ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers
  built with Apple clang version 12.0.0 (clang-1200.0.32.29)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.2_3 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 0).
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 24024).
[h264 @ 0x7fe80b011800] left block unavailable for requested intra4x4 mode -1
[h264 @ 0x7fe80b011800] error while decoding MB 0 2, bytestream 13821
[h264 @ 0x7fe80b011800] concealing 1533 DC, 1533 AC, 1533 MV errors in I frame
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 159159).
[h264 @ 0x7fe80b011800] concealing 146 DC, 146 AC, 146 MV errors in P frame
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 414414).
[h264 @ 0x7fe80b011800] concealing 394 DC, 394 AC, 394 MV errors in P frame
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 441441).
[h264 @ 0x7fe80b011800] cabac decode of qscale diff failed at 27 27
[h264 @ 0x7fe80b011800] error while decoding MB 27 27, bytestream 13961
[h264 @ 0x7fe80b011800] concealing 181 DC, 181 AC, 181 MV errors in P frame
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 585585).
[h264 @ 0x7fe80b011800] concealing 52 DC, 52 AC, 52 MV errors in P frame
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 630630).
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 717717).
[h264 @ 0x7fe80b011800] left block unavailable for requested intra4x4 mode -1
[h264 @ 0x7fe80b011800] error while decoding MB 0 2, bytestream 36961
[h264 @ 0x7fe80b011800] concealing 1533 DC, 1533 AC, 1533 MV errors in I frame
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 801801).
[h264 @ 0x7fe80b011800] concealing 351 DC, 351 AC, 351 MV errors in P frame
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 1021020).
[h264 @ 0x7fe80b011800] concealing 315 DC, 315 AC, 315 MV errors in P frame
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 1174173).
[h264 @ 0x7fe80b011800] concealing 1401 DC, 1401 AC, 1401 MV errors in I frame
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = NOPTS).
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 1888887).
[h264 @ 0x7fe80b011800] concealing 846 DC, 846 AC, 846 MV errors in P frame
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 2054052).
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 2156154).
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 2351349).
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 2408406).
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 2573571).
[mpegts @ 0x7fe80a810a00] Packet corrupt (stream = 0, dts = 2729727).
simspace-dev commented 3 years ago

Hi @KonradIT, any chance you might know what's happening here and how I might be able to resolve this problem? I'm a developer. My Python skills are so-so, but I'd be happy to help if you can point me in the right direction of handling the "Packet corrupt" errors. Seems like it may be an ffmpeg thing, but I'm not sure.

RolandSireyjol commented 3 years ago

Hi @simspace-dev , I had a bit of a look since I had the same error on my end, with a GoPro Hero 8. In the "stream" function, calling for "self.KeepAlive()" was causing the error. By using the loop given in the example opencv_gopro/ffmpegless-preview.py, I could recreate the same effect as we want from KeepAlive, but without the error. I also thing that it probably comes from ffmpeg itself.

RolandSireyjol commented 3 years ago

@simspace-dev following on the overview() issue: I did get different errors depending on the kind of gopro I was setting up. Here are some various options:

gopro = GoProCamera.GoPro(constants.gpcontrol) gopro = GoProCamera.GoPro(constants.auth) gopro = GoProCamera.GoPro() Best would be to make this function more resilient, but in the meantime what I did was making my own local overview function, which is almost a copypaste of the lib"s version, without the crashing parts.