diff --git a/video/transcoder/create_job_from_ad_hoc.py b/video/transcoder/create_job_from_ad_hoc.py index 2e08c612c2fc..7fc6dce832e3 100644 --- a/video/transcoder/create_job_from_ad_hoc.py +++ b/video/transcoder/create_job_from_ad_hoc.py @@ -100,7 +100,9 @@ def create_job_from_ad_hoc(project_id, location, input_uri, output_uri): parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_uri", @@ -114,5 +116,8 @@ def create_job_from_ad_hoc(project_id, location, input_uri, output_uri): ) args = parser.parse_args() create_job_from_ad_hoc( - args.project_id, args.location, args.input_uri, args.output_uri, + args.project_id, + args.location, + args.input_uri, + args.output_uri, ) diff --git a/video/transcoder/create_job_from_preset.py b/video/transcoder/create_job_from_preset.py index 3539b32550e5..67c167241e07 100644 --- a/video/transcoder/create_job_from_preset.py +++ b/video/transcoder/create_job_from_preset.py @@ -59,7 +59,9 @@ def create_job_from_preset(project_id, location, input_uri, output_uri, preset): parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_uri", @@ -78,5 +80,9 @@ def create_job_from_preset(project_id, location, input_uri, output_uri, preset): ) args = parser.parse_args() create_job_from_preset( - args.project_id, args.location, args.input_uri, args.output_uri, args.preset, + args.project_id, + args.location, + args.input_uri, + args.output_uri, + args.preset, ) diff --git a/video/transcoder/create_job_from_template.py b/video/transcoder/create_job_from_template.py index 0a69704a440c..685c3f67999b 100644 --- a/video/transcoder/create_job_from_template.py +++ b/video/transcoder/create_job_from_template.py @@ -59,7 +59,9 @@ def create_job_from_template(project_id, location, input_uri, output_uri, templa parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_uri", diff --git a/video/transcoder/create_job_with_animated_overlay.py b/video/transcoder/create_job_with_animated_overlay.py index a90c542efa54..a3f3cbb36033 100644 --- a/video/transcoder/create_job_with_animated_overlay.py +++ b/video/transcoder/create_job_with_animated_overlay.py @@ -81,7 +81,8 @@ def create_job_with_animated_overlay( image=transcoder_v1.types.Overlay.Image( uri=overlay_image_uri, resolution=transcoder_v1.types.Overlay.NormalizedCoordinate( - x=0, y=0, + x=0, + y=0, ), alpha=1, ), @@ -90,20 +91,30 @@ def create_job_with_animated_overlay( animation_fade=transcoder_v1.types.Overlay.AnimationFade( fade_type=transcoder_v1.types.Overlay.FadeType.FADE_IN, xy=transcoder_v1.types.Overlay.NormalizedCoordinate( - x=0.5, y=0.5, + x=0.5, + y=0.5, + ), + start_time_offset=duration.Duration( + seconds=5, + ), + end_time_offset=duration.Duration( + seconds=10, ), - start_time_offset=duration.Duration(seconds=5,), - end_time_offset=duration.Duration(seconds=10,), ), ), transcoder_v1.types.Overlay.Animation( animation_fade=transcoder_v1.types.Overlay.AnimationFade( fade_type=transcoder_v1.types.Overlay.FadeType.FADE_OUT, xy=transcoder_v1.types.Overlay.NormalizedCoordinate( - x=0.5, y=0.5, + x=0.5, + y=0.5, + ), + start_time_offset=duration.Duration( + seconds=12, + ), + end_time_offset=duration.Duration( + seconds=15, ), - start_time_offset=duration.Duration(seconds=12,), - end_time_offset=duration.Duration(seconds=15,), ), ), ], @@ -121,7 +132,9 @@ def create_job_with_animated_overlay( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_uri", diff --git a/video/transcoder/create_job_with_concatenated_inputs.py b/video/transcoder/create_job_with_concatenated_inputs.py index 0a2d3ad8ba78..4a64f88e114e 100644 --- a/video/transcoder/create_job_with_concatenated_inputs.py +++ b/video/transcoder/create_job_with_concatenated_inputs.py @@ -80,8 +80,14 @@ def create_job_with_concatenated_inputs( job.output_uri = output_uri job.config = transcoder_v1.types.JobConfig( inputs=[ - transcoder_v1.types.Input(key="input1", uri=input1_uri,), - transcoder_v1.types.Input(key="input2", uri=input2_uri,), + transcoder_v1.types.Input( + key="input1", + uri=input1_uri, + ), + transcoder_v1.types.Input( + key="input2", + uri=input2_uri, + ), ], edit_list=[ transcoder_v1.types.EditAtom( @@ -135,7 +141,9 @@ def create_job_with_concatenated_inputs( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input1_uri", diff --git a/video/transcoder/create_job_with_embedded_captions.py b/video/transcoder/create_job_with_embedded_captions.py index c28a0668f01f..9943889635a8 100644 --- a/video/transcoder/create_job_with_embedded_captions.py +++ b/video/transcoder/create_job_with_embedded_captions.py @@ -32,7 +32,11 @@ def create_job_with_embedded_captions( - project_id, location, input_video_uri, input_captions_uri, output_uri, + project_id, + location, + input_video_uri, + input_captions_uri, + output_uri, ): """Creates a job based on an ad-hoc job configuration that embeds captions in the output video. @@ -53,12 +57,19 @@ def create_job_with_embedded_captions( job.output_uri = output_uri job.config = transcoder_v1.types.JobConfig( inputs=[ - transcoder_v1.types.Input(key="input0", uri=input_video_uri,), - transcoder_v1.types.Input(key="caption-input0", uri=input_captions_uri,), + transcoder_v1.types.Input( + key="input0", + uri=input_video_uri, + ), + transcoder_v1.types.Input( + key="caption-input0", + uri=input_captions_uri, + ), ], edit_list=[ transcoder_v1.types.EditAtom( - key="atom0", inputs=["input0", "caption-input0"], + key="atom0", + inputs=["input0", "caption-input0"], ), ], elementary_streams=[ @@ -85,7 +96,9 @@ def create_job_with_embedded_captions( codec="cea608", mapping_=[ transcoder_v1.types.TextStream.TextMapping( - atom_key="atom0", input_key="caption-input0", input_track=0, + atom_key="atom0", + input_key="caption-input0", + input_track=0, ), ], ), @@ -103,7 +116,9 @@ def create_job_with_embedded_captions( elementary_streams=["video-stream0", "audio-stream0"], ), transcoder_v1.types.MuxStream( - key="sd-dash", container="fmp4", elementary_streams=["video-stream0"], + key="sd-dash", + container="fmp4", + elementary_streams=["video-stream0"], ), transcoder_v1.types.MuxStream( key="audio-dash", @@ -113,7 +128,9 @@ def create_job_with_embedded_captions( ], manifests=[ transcoder_v1.types.Manifest( - file_name="manifest.m3u8", type_="HLS", mux_streams=["sd-hls"], + file_name="manifest.m3u8", + type_="HLS", + mux_streams=["sd-hls"], ), transcoder_v1.types.Manifest( file_name="manifest.mpd", @@ -133,7 +150,9 @@ def create_job_with_embedded_captions( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_video_uri", diff --git a/video/transcoder/create_job_with_periodic_images_spritesheet.py b/video/transcoder/create_job_with_periodic_images_spritesheet.py index 95621e2b9efd..1690ba6444fe 100644 --- a/video/transcoder/create_job_with_periodic_images_spritesheet.py +++ b/video/transcoder/create_job_with_periodic_images_spritesheet.py @@ -88,14 +88,18 @@ def create_job_with_periodic_images_spritesheet( file_prefix="small-sprite-sheet", sprite_width_pixels=64, sprite_height_pixels=32, - interval=duration.Duration(seconds=7,), + interval=duration.Duration( + seconds=7, + ), ), # Generate a sprite sheet with 128x72px images. An image is taken every 7 seconds from the video. transcoder_v1.types.SpriteSheet( file_prefix="large-sprite-sheet", sprite_width_pixels=128, sprite_height_pixels=72, - interval=duration.Duration(seconds=7,), + interval=duration.Duration( + seconds=7, + ), ), ], ) @@ -110,7 +114,9 @@ def create_job_with_periodic_images_spritesheet( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_uri", @@ -124,5 +130,8 @@ def create_job_with_periodic_images_spritesheet( ) args = parser.parse_args() create_job_with_periodic_images_spritesheet( - args.project_id, args.location, args.input_uri, args.output_uri, + args.project_id, + args.location, + args.input_uri, + args.output_uri, ) diff --git a/video/transcoder/create_job_with_set_number_images_spritesheet.py b/video/transcoder/create_job_with_set_number_images_spritesheet.py index b25c872dd240..bc196fb46cc6 100644 --- a/video/transcoder/create_job_with_set_number_images_spritesheet.py +++ b/video/transcoder/create_job_with_set_number_images_spritesheet.py @@ -113,7 +113,9 @@ def create_job_with_set_number_images_spritesheet( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_uri", @@ -127,5 +129,8 @@ def create_job_with_set_number_images_spritesheet( ) args = parser.parse_args() create_job_with_set_number_images_spritesheet( - args.project_id, args.location, args.input_uri, args.output_uri, + args.project_id, + args.location, + args.input_uri, + args.output_uri, ) diff --git a/video/transcoder/create_job_with_standalone_captions.py b/video/transcoder/create_job_with_standalone_captions.py index 49ccfc8b23f4..e8196602b73f 100644 --- a/video/transcoder/create_job_with_standalone_captions.py +++ b/video/transcoder/create_job_with_standalone_captions.py @@ -33,7 +33,11 @@ def create_job_with_standalone_captions( - project_id, location, input_video_uri, input_captions_uri, output_uri, + project_id, + location, + input_video_uri, + input_captions_uri, + output_uri, ): """Creates a job based on an ad-hoc job configuration that can use captions from a standalone file. @@ -54,12 +58,19 @@ def create_job_with_standalone_captions( job.output_uri = output_uri job.config = transcoder_v1.types.JobConfig( inputs=[ - transcoder_v1.types.Input(key="input0", uri=input_video_uri,), - transcoder_v1.types.Input(key="caption-input0", uri=input_captions_uri,), + transcoder_v1.types.Input( + key="input0", + uri=input_video_uri, + ), + transcoder_v1.types.Input( + key="caption-input0", + uri=input_captions_uri, + ), ], edit_list=[ transcoder_v1.types.EditAtom( - key="atom0", inputs=["input0", "caption-input0"], + key="atom0", + inputs=["input0", "caption-input0"], ), ], elementary_streams=[ @@ -86,7 +97,9 @@ def create_job_with_standalone_captions( codec="webvtt", mapping_=[ transcoder_v1.types.TextStream.TextMapping( - atom_key="atom0", input_key="caption-input0", input_track=0, + atom_key="atom0", + input_key="caption-input0", + input_track=0, ), ], ), @@ -108,7 +121,9 @@ def create_job_with_standalone_captions( container="vtt", elementary_streams=["vtt-stream0"], segment_settings=transcoder_v1.types.SegmentSettings( - segment_duration=duration.Duration(seconds=6,), + segment_duration=duration.Duration( + seconds=6, + ), individual_segments=True, ), ), @@ -132,7 +147,9 @@ def create_job_with_standalone_captions( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_video_uri", diff --git a/video/transcoder/create_job_with_static_overlay.py b/video/transcoder/create_job_with_static_overlay.py index 5386a8a79ef8..37ce26b670d8 100644 --- a/video/transcoder/create_job_with_static_overlay.py +++ b/video/transcoder/create_job_with_static_overlay.py @@ -81,7 +81,8 @@ def create_job_with_static_overlay( image=transcoder_v1.types.Overlay.Image( uri=overlay_image_uri, resolution=transcoder_v1.types.Overlay.NormalizedCoordinate( - x=1, y=0.5, + x=1, + y=0.5, ), alpha=1, ), @@ -89,14 +90,19 @@ def create_job_with_static_overlay( transcoder_v1.types.Overlay.Animation( animation_static=transcoder_v1.types.Overlay.AnimationStatic( xy=transcoder_v1.types.Overlay.NormalizedCoordinate( - x=0, y=0, + x=0, + y=0, + ), + start_time_offset=duration.Duration( + seconds=0, ), - start_time_offset=duration.Duration(seconds=0,), ), ), transcoder_v1.types.Overlay.Animation( animation_end=transcoder_v1.types.Overlay.AnimationEnd( - start_time_offset=duration.Duration(seconds=10,), + start_time_offset=duration.Duration( + seconds=10, + ), ), ), ], @@ -114,7 +120,9 @@ def create_job_with_static_overlay( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", help="The location to start this job in.", default="us-central1", + "--location", + help="The location to start this job in.", + default="us-central1", ) parser.add_argument( "--input_uri", diff --git a/video/transcoder/job_test.py b/video/transcoder/job_test.py index d924472c858d..3cc8e6ade121 100644 --- a/video/transcoder/job_test.py +++ b/video/transcoder/job_test.py @@ -271,7 +271,10 @@ def test_create_job_with_animated_overlay(capsys, test_bucket): def test_create_job_with_set_number_spritesheet(capsys, test_bucket): create_job_with_set_number_images_spritesheet.create_job_with_set_number_images_spritesheet( - project_id, location, input_uri, output_uri_for_set_number_spritesheet, + project_id, + location, + input_uri, + output_uri_for_set_number_spritesheet, ) out, _ = capsys.readouterr() job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" @@ -319,7 +322,10 @@ def test_create_job_with_set_number_spritesheet(capsys, test_bucket): def test_create_job_with_periodic_spritesheet(capsys, test_bucket): create_job_with_periodic_images_spritesheet.create_job_with_periodic_images_spritesheet( - project_id, location, input_uri, output_uri_for_periodic_spritesheet, + project_id, + location, + input_uri, + output_uri_for_periodic_spritesheet, ) out, _ = capsys.readouterr() job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" @@ -407,7 +413,11 @@ def test_create_job_with_concatenated_inputs(capsys, test_bucket): def test_create_job_with_embedded_captions(capsys, test_bucket): create_job_with_embedded_captions.create_job_with_embedded_captions( - project_id, location, input_uri, captions_uri, output_uri_for_embedded_captions, + project_id, + location, + input_uri, + captions_uri, + output_uri_for_embedded_captions, ) out, _ = capsys.readouterr() job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" diff --git a/video/transcoder/noxfile.py b/video/transcoder/noxfile.py index 85f5836dba3a..25f87a215d4c 100644 --- a/video/transcoder/noxfile.py +++ b/video/transcoder/noxfile.py @@ -29,7 +29,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -253,7 +253,7 @@ def py(session: nox.sessions.Session) -> None: def _get_repo_root() -> Optional[str]: - """ Returns the root folder of the project. """ + """Returns the root folder of the project.""" # Get root of this repository. Assume we don't have directories nested deeper than 10 items. p = Path(os.getcwd()) for i in range(10):