55
66import argparse
77import asyncio
8+ import logging
89import sys
910
1011from returns .pipeline import is_successful
1516from open_gopro .gopro_base import GoProBase
1617from open_gopro .models .streaming import StreamType , WebcamProtocol , WebcamStreamOptions
1718from 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
1920from open_gopro .util .util import ainput
2021
2122console = Console ()
@@ -40,6 +41,7 @@ async def main(args: argparse.Namespace) -> int:
4041 if wireless_interfaces
4142 else WiredGoPro (args .identifier )
4243 ) as gopro :
44+ set_stream_logging_level (logging .WARNING )
4345 with console .status (f"Starting webcam stream with protocol { args .protocol } ..." ):
4446 if not is_successful (
4547 result := (
@@ -52,23 +54,23 @@ async def main(args: argparse.Namespace) -> int:
5254 console .print (f"[red]Failed to start webcam stream: { result .failure ()} " )
5355 return 1
5456
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 ()
7274 return 0
7375
7476 except Exception as e : # pylint: disable = broad-except
0 commit comments