5
5
6
6
import argparse
7
7
import asyncio
8
+ import logging
8
9
import sys
9
10
10
11
from returns .pipeline import is_successful
15
16
from open_gopro .gopro_base import GoProBase
16
17
from open_gopro .models .streaming import StreamType , WebcamProtocol , WebcamStreamOptions
17
18
from open_gopro .util import add_cli_args_and_parse
18
- from open_gopro .util .logger import setup_logging
19
+ from open_gopro .util .logger import set_stream_logging_level , setup_logging
19
20
from open_gopro .util .util import ainput
20
21
21
22
console = Console ()
@@ -40,6 +41,7 @@ async def main(args: argparse.Namespace) -> int:
40
41
if wireless_interfaces
41
42
else WiredGoPro (args .identifier )
42
43
) as gopro :
44
+ set_stream_logging_level (logging .WARNING )
43
45
with console .status (f"Starting webcam stream with protocol { args .protocol } ..." ):
44
46
if not is_successful (
45
47
result := (
@@ -52,23 +54,23 @@ async def main(args: argparse.Namespace) -> int:
52
54
console .print (f"[red]Failed to start webcam stream: { result .failure ()} " )
53
55
return 1
54
56
55
- url = gopro .streaming .url if args .protocol == WebcamProtocol .RTSP else "udp://@:8554"
56
- console .print (f"Preview stream started. It can be viewed in VLC at [yellow]{ url } " )
57
- console .print (
58
- "Press Enter to view the preview stream using Python CV2. Once started, it won't be viewable in VLC."
59
- )
60
- await ainput ("" )
61
-
62
- with console .status ("Displaying the preview stream..." ):
63
- assert gopro .streaming .url
64
- BufferlessVideoCapture (
65
- source = gopro .streaming .url ,
66
- protocol = BufferlessVideoCapture .Protocol (args .protocol .name ),
67
- printer = console .print ,
68
- ).display_blocking ()
69
-
70
- with console .status ("Stopping preview stream..." ):
71
- await gopro .streaming .stop_active_stream ()
57
+ url = gopro .streaming .url if args .protocol == WebcamProtocol .RTSP else "udp://@:8554"
58
+ console .print (f"Preview stream started. It can be viewed in VLC at [yellow]{ url } " )
59
+ console .print (
60
+ "Press Enter to view the preview stream using Python CV2. Once started, it won't be viewable in VLC."
61
+ )
62
+ await ainput ("" )
63
+
64
+ with console .status ("Displaying the preview stream..." ):
65
+ assert gopro .streaming .url
66
+ BufferlessVideoCapture (
67
+ source = gopro .streaming .url ,
68
+ protocol = BufferlessVideoCapture .Protocol (args .protocol .name ),
69
+ printer = console .print ,
70
+ ).display_blocking ()
71
+
72
+ with console .status ("Stopping preview stream..." ):
73
+ await gopro .streaming .stop_active_stream ()
72
74
return 0
73
75
74
76
except Exception as e : # pylint: disable = broad-except
0 commit comments