KonradIT / GoProStream

Tools for handling/displaying GoPro HTTP/UDP stream (Python/Ruby)
376 stars 100 forks source link

Stream quality, delay and artifacting #40

Open Niproblema opened 5 years ago

Niproblema commented 5 years ago

Hello, I am struggling with very poor stream quality on hero 6

With max bitrate and resolution from this page it is still looking just like low res preview rather than actual stream

Audio is sightly delayed, but video is even way worse.

Video also has significant artifacting, with errors in ffmpeg stream, [h264 @ 0x7f5bfc06e540] error while decoding MB 60 20, bytestream 7140 [h264 @ 0x7f5bfc06e540] concealing 1989 DC, 1989 AC, 1989 MV errors in P frame [h264 @ 0x7f5bfc0185c0] left block unavailable for requested intra4x4 mode -1 [h264 @ 0x7f5bfc0185c0] error while decoding MB 0 42, bytestream 501 [h264 @ 0x7f5bfc0185c0] concealing 289 DC, 289 AC, 289 MV errors in P frame [h264 @ 0x7f5bfc1ff800] left block unavailable for requested intra mode [h264 @ 0x7f5bfc1ff800] error while decoding MB 0 44, bytestream 692 [h264 @ 0x7f5bfc1ff800] concealing 129 DC, 129 AC, 129 MV errors in P frame [h264 @ 0x7f5bfc21bd00] error while decoding MB 64 43, bytestream -6 [h264 @ 0x7f5bfc21bd00] concealing 145 DC, 145 AC, 145 MV errors in P frame [h264 @ 0x7f5bfc2385c0] concealing 1896 DC, 1896 AC, 1896 MV errors in P frame [h264 @ 0x7f5bfc254e80] cabac decode of qscale diff failed at 48 8 I tried both 5ghz and 2.4 and different bitrate settings and it seems the same.

I tried same camera with smartphone, which works much better, so I guess ffplay is causing the issue.

Is everyone else experiencing this, or am I missing some obvious setting?? This makes gopro completely useless for streaming.

noname77 commented 4 years ago

i experience similar frame drops / artifacts when the camera is in video mode. hero 6, camera on 5g connected directly to my mac's wifi card, and within 50 cm, so i doubt many packets are lost in the air.

i can get smooth preview if i switch to photo mode, however, the aspect ratio is 4:3 there vs 16:9 in video mode.

anyone else faced this and managed to get smooth preview in video mode?

KonradIT commented 4 years ago

That's weird, I don't get any difference in quality or drops when switching modes.

noname77 commented 4 years ago

thanks for quick response

just did some more tests and played around with different settings, as you mentioned in this post

i can get a smooth stream with the following settings: http://10.5.5.9/gp/gpControl/setting/64/0 <- default resolution, i believe 480p http://10.5.5.9/gp/gpControl/setting/62/1000000 <- 1 Mbps stream bitrate

if i try to go any higher (bitrate or resolution) im getting errors in ffplay

i also believe, that the bitrate needs to be set after the script is started, otherwise a default value must be used as im getting errors and artifacts

(env) user@Mac GoProStream (master) $ python GoProStream.py 
branch HD4
HERO6 Black
HD6.01.02.10.00
UDP target IP: 10.5.5.9
UDP target port: 8554
message: _GPHD_:0:0:2:0.000000

Recording on camera: False
Press ctrl+C to quit this application.

ffplay version 4.2.2 Copyright (c) 2003-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 --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-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[mpegts @ 0x7f8ee1006600] Unable to seek back to the start
    Last message repeated 1 times
[NULL @ 0x7f8edf8b9e00] non-existing PPS 0 referenced
[h264 @ 0x7f8edf8b9e00] non-existing PPS 0 referenced
[h264 @ 0x7f8edf8b9e00] decode_slice_header error
[h264 @ 0x7f8edf8b9e00] no frame!
[mpegts @ 0x7f8ee1006600] Stream #1: not enough frames to estimate rate; consider increasing probesize
[mpegts @ 0x7f8ee1006600] decoding for stream 1 failed
Input #0, mpegts, from 'udp://10.5.5.102:8554':
  Duration: N/A, start: 0.277333, bitrate: N/A
    Stream #0:0[0x1100]: Audio: aac (LC), 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:1[0x1011]: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 848x480 [SAR 1:1 DAR 53:30], 29.97 tbr, 90k tbn, 59.94 tbc
[swscaler @ 0x1114ae000] deprecated pixel format used, make sure you did set range correctly
[h264 @ 0x7f8edf8d7a00] concealing 313 DC, 313 AC, 313 MV errors in P frame
[h264 @ 0x7f8edf8d7a00] left block unavailable for requested intra mode
[h264 @ 0x7f8edf8d7a00] error while decoding MB 0 15, bytestream 1166
[h264 @ 0x7f8edf8d7a00] concealing 844 DC, 844 AC, 844 MV errors in P frame
[h264 @ 0x7f8edf8d7a00] concealing 104 DC, 104 AC, 104 MV errors in P frame
[h264 @ 0x7f8edf8d7a00] concealing 1035 DC, 1035 AC, 1035 MV errors in P frame
[h264 @ 0x7f8edf8d7a00] cabac decode of qscale diff failed at 12 10 
[h264 @ 0x7f8edf8d7a00] error while decoding MB 12 10, bytestream 2573
[h264 @ 0x7f8edf8d7a00] concealing 1097 DC, 1097 AC, 1097 MV errors in P frame
[h264 @ 0x7f8edf8d7a00] cabac decode of qscale diff failed at 38 21 
[h264 @ 0x7f8edf8d7a00] error while decoding MB 38 21, bytestream 751
[h264 @ 0x7f8edf8d7a00] concealing 488 DC, 488 AC, 488 MV errors in P frame
[h264 @ 0x7f8edf8d7400] concealing 694 DC, 694 AC, 694 MV errors in P frame
[h264 @ 0x7f8edf8dc600] concealing 1179 DC, 1179 AC, 1179 MV errors in P frame
[h264 @ 0x7f8edf8d7a00] concealing 476 DC, 476 AC, 476 MV errors in P frame
[h264 @ 0x7f8edf8d7a00] concealing 871 DC, 871 AC, 871 MV errors in P frame
[h264 @ 0x7f8edf8d7400] error while decoding MB 18 9, bytestream -17
[h264 @ 0x7f8edf8d7400] concealing 1144 DC, 1144 AC, 1144 MV errors in P frame
[h264 @ 0x7f8edf8d7400] concealing 391 DC, 391 AC, 391 MV errors in P frame
[h264 @ 0x7f8edf8d7400] concealing 617 DC, 617 AC, 617 MV errors in P frame
[h264 @ 0x7f8edf8d7400] cabac decode of qscale diff failed at 15 14 
[h264 @ 0x7f8edf8d7400] error while decoding MB 15 14, bytestream 2403
[h264 @ 0x7f8edf8d7400] concealing 882 DC, 882 AC, 882 MV errors in P frame
[h264 @ 0x7f8edf8d7400] concealing 1328 DC, 1328 AC, 1328 MV errors in P frame
[h264 @ 0x7f8edf8dc000] cabac decode of qscale diff failed at 2 5   
[h264 @ 0x7f8edf8dc000] error while decoding MB 2 5, bytestream 3302
[h264 @ 0x7f8edf8dc000] concealing 1372 DC, 1372 AC, 1372 MV errors in P frame
[h264 @ 0x7f8edf8dc000] concealing 860 DC, 860 AC, 860 MV errors in P frame
[h264 @ 0x7f8edf8dba00] cabac decode of qscale diff failed at 20 6  
[h264 @ 0x7f8edf8dba00] error while decoding MB 20 6, bytestream 2881
[h264 @ 0x7f8edf8dba00] concealing 1301 DC, 1301 AC, 1301 MV errors in P frame
[h264 @ 0x7f8edf8dba00] concealing 1157 DC, 1157 AC, 1157 MV errors in P frame
[h264 @ 0x7f8edf8dba00] concealing 1131 DC, 1131 AC, 1131 MV errors in P frame
[h264 @ 0x7f8edf8dc000] cabac decode of qscale diff failed at 25 4  
[h264 @ 0x7f8edf8dc000] error while decoding MB 25 4, bytestream 16052
[h264 @ 0x7f8edf8dc000] concealing 1402 DC, 1402 AC, 1402 MV errors in P frame

another weird behaviour: if i set the stream to 720 (gpControl/setting/64/7), the aspect seems to be 2:1, see black bars on the top and bottom

image

if i try to set the resolution settings to 8 or 9, im getting internal server error:

{
"version": "6.00",
"path_info": "setting/64/9",
"query_string": "",
"error_code":-1,
"error_msg": 
Error: Parse error on line 6:
...e":-1,"error_msg": "500 Internal Server
----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
"500 Internal Server Error
",
"function": "gpcontrol_cgi_handler",
"line": 190
}

even though those seem to be valid in the gpControl:

{
    path_segment: "stream_window_size",
    display_name: "Secondary Stream Window Size",
    id: 64,
    options: [
        {
            name: "DEFAULT",
            display_name: "Default",
            value: 0
        },
        {
            name: "240",
            display_name: "240",
            value: 1
        },
        {
            name: "240_3BY4_SUBSAMPLE",
            display_name: "240 3:4 Subsample",
            value: 2
        },
        {
            name: "240_1BY2_SUBSAMPLE",
            display_name: "240 1:2 Subsample",
            value: 3
        },
        {
            name: "480",
            display_name: "480",
            value: 4
        },
        {
            name: "480_3BY4_SUBSAMPLE",
            display_name: "480 3:4 Subsample",
            value: 5
        },
        {
            name: "480_1BY2_SUBSAMPLE",
            display_name: "480 1:2 Subsample",
            value: 6
        },
        {
            name: "720",
            display_name: "720",
            value: 7
        },
        {
            name: "720_3BY4_SUBSAMPLE",
            display_name: "720 3:4 Subsample",
            value: 8
        },
        {
            name: "720_1BY2_SUBSAMPLE",
            display_name: "720 1:2 Subsample",
            value: 9
        }
    ]
}

can it be that this is because the setting is for "Secondary Stream Window Size", and the GoProStream script (ffplay) actually uses primary stream?

noname77 commented 4 years ago

tried with 2.4 GHz with same results, i need to go to 800 kbps to get fully smooth stream, but the quality at 480p is slightly too low. with 1 Mbps the stream is acceptable, however some decoding errors show up

i am not sure if its the hero 6 that cannot cope with higher bitrates or my network environment. maybe something to do with other settings on the camera? i only have ~5 other wifi APs around and they all seem to be in the 2.4 range, so i would be leaning towards the gopro settings case.

maybe its possible to disable the audio stream?

it would be great if anyone managed to get proper 720p stream on hero 6, please share if so

in the meantime, i added this to the script for anyone interested:

        ##
        ## HTTP GETs the URL that tells the GoPro to start streaming.
        ##
        urlopen("http://10.5.5.9/gp/gpControl/execute?p1=gpStream&a1=proto_v2&c1=restart").read()

        if "HD6" in response:
            # change to default resolution (480p) and 1 Mbps bitrate
            sleep(0.1)
            urlopen("http://10.5.5.9/gp/gpControl/setting/64/0").read()
            sleep(0.1)
            urlopen("http://10.5.5.9/gp/gpControl/setting/62/1000000").read()

        if RECORD: