diff --git a/examples/basics/parse.py b/examples/basics/parse.py index 04f4528ef..5d052449f 100644 --- a/examples/basics/parse.py +++ b/examples/basics/parse.py @@ -4,7 +4,6 @@ import av import av.datasets - # We want an H.264 stream in the Annex B byte-stream format. # We haven't exposed bitstream filters yet, so we're gonna use the `ffmpeg` CLI. h264_path = "night-sky.h264" @@ -29,14 +28,12 @@ codec = av.CodecContext.create("h264", "r") while True: - chunk = fh.read(1 << 16) packets = codec.parse(chunk) print(f"Parsed {len(packets)} packets from {len(chunk)} bytes:") for packet in packets: - print(" ", packet) frames = codec.decode(packet) diff --git a/examples/basics/remux.py b/examples/basics/remux.py index c4779f4e9..befc24f8a 100644 --- a/examples/basics/remux.py +++ b/examples/basics/remux.py @@ -1,7 +1,6 @@ import av import av.datasets - input_ = av.open(av.datasets.curated("pexels/time-lapse-video-of-night-sky-857195.mp4")) output = av.open("remuxed.mkv", "w") @@ -11,7 +10,6 @@ out_stream = output.add_stream(template=in_stream) for packet in input_.demux(in_stream): - print(packet) # We need to skip the "flushing" packets that `demux` generates. diff --git a/examples/basics/save_keyframes.py b/examples/basics/save_keyframes.py index 3de25f84a..98c7c0be3 100644 --- a/examples/basics/save_keyframes.py +++ b/examples/basics/save_keyframes.py @@ -1,7 +1,6 @@ import av import av.datasets - content = av.datasets.curated("pexels/time-lapse-video-of-night-sky-857195.mp4") with av.open(content) as container: # Signal that we only want to look at keyframes. @@ -9,7 +8,6 @@ stream.codec_context.skip_frame = "NONKEY" for frame in container.decode(stream): - print(frame) # We use `frame.pts` as `frame.index` won't make must sense with the `skip_frame`. diff --git a/examples/basics/thread_type.py b/examples/basics/thread_type.py index 51c23a79e..fab539b26 100644 --- a/examples/basics/thread_type.py +++ b/examples/basics/thread_type.py @@ -3,7 +3,6 @@ import av import av.datasets - print("Decoding with default (slice) threading...") container = av.open( diff --git a/examples/numpy/barcode.py b/examples/numpy/barcode.py index 64c13e198..bd40f17a3 100644 --- a/examples/numpy/barcode.py +++ b/examples/numpy/barcode.py @@ -1,10 +1,9 @@ -from PIL import Image import numpy as np +from PIL import Image import av import av.datasets - container = av.open( av.datasets.curated("pexels/time-lapse-video-of-sunset-by-the-sea-854400.mp4") ) @@ -12,7 +11,6 @@ columns = [] for frame in container.decode(video=0): - print(frame) array = frame.to_ndarray(format="rgb24") diff --git a/examples/numpy/generate_video.py b/examples/numpy/generate_video.py index 80145d514..8b490ea1f 100644 --- a/examples/numpy/generate_video.py +++ b/examples/numpy/generate_video.py @@ -2,7 +2,6 @@ import av - duration = 4 fps = 24 total_frames = duration * fps @@ -15,7 +14,6 @@ stream.pix_fmt = "yuv420p" for frame_i in range(total_frames): - img = np.empty((480, 320, 3)) img[:, :, 0] = 0.5 + 0.5 * np.sin(2 * np.pi * (0 / 3 + frame_i / total_frames)) img[:, :, 1] = 0.5 + 0.5 * np.sin(2 * np.pi * (1 / 3 + frame_i / total_frames)) diff --git a/examples/numpy/generate_video_with_pts.py b/examples/numpy/generate_video_with_pts.py index 58ca547e2..d6cdca80d 100644 --- a/examples/numpy/generate_video_with_pts.py +++ b/examples/numpy/generate_video_with_pts.py @@ -1,13 +1,12 @@ #!/usr/bin/env python3 -from fractions import Fraction import colorsys +from fractions import Fraction import numpy as np import av - (width, height) = (640, 360) total_frames = 20 fps = 30 @@ -43,7 +42,6 @@ block_h2 = int(0.5 * height / 4) for frame_i in range(total_frames): - # move around the color wheel (hue) nice_color = colorsys.hsv_to_rgb(frame_i / total_frames, 1.0, 1.0) nice_color = (np.array(nice_color) * 255).astype(np.uint8) diff --git a/tests/common.py b/tests/common.py index 38ee0a0fb..4e5930c08 100644 --- a/tests/common.py +++ b/tests/common.py @@ -1,13 +1,12 @@ -from unittest import TestCase as _Base import datetime import errno import functools import os import types +from unittest import TestCase as _Base from av.datasets import fate as fate_suite - try: import PIL.Image as Image import PIL.ImageFilter as ImageFilter diff --git a/tests/test_audioformat.py b/tests/test_audioformat.py index 5d4eb7871..5334b37d6 100644 --- a/tests/test_audioformat.py +++ b/tests/test_audioformat.py @@ -4,7 +4,6 @@ from .common import TestCase - postfix = "le" if sys.byteorder == "little" else "be" diff --git a/tests/test_codec.py b/tests/test_codec.py index b7af5eedf..cbd7a06df 100644 --- a/tests/test_codec.py +++ b/tests/test_codec.py @@ -5,7 +5,6 @@ from .common import TestCase - # some older ffmpeg versions have no native opus encoder try: opus_c = Codec("opus", "w") diff --git a/tests/test_codec_context.py b/tests/test_codec_context.py index 946f26cc8..95b2b2000 100644 --- a/tests/test_codec_context.py +++ b/tests/test_codec_context.py @@ -1,12 +1,12 @@ -from fractions import Fraction -from unittest import SkipTest import os import warnings +from fractions import Fraction +from unittest import SkipTest +import av from av import AudioResampler, Codec, Packet from av.codec.codec import UnknownCodecError from av.video.frame import PictureType -import av from .common import TestCase, fate_suite diff --git a/tests/test_encode.py b/tests/test_encode.py index a293cbf83..bb1a67a03 100644 --- a/tests/test_encode.py +++ b/tests/test_encode.py @@ -1,15 +1,14 @@ +import math from fractions import Fraction from unittest import SkipTest -import math +import av from av import AudioFrame, VideoFrame from av.audio.stream import AudioStream from av.video.stream import VideoStream -import av from .common import Image, TestCase, fate_suite - WIDTH = 320 HEIGHT = 240 DURATION = 48 diff --git a/tests/test_enums.py b/tests/test_enums.py index bc8385f5e..39bf856ad 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -4,7 +4,6 @@ from .common import TestCase - # This must be at the top-level. PickleableFooBar = define_enum("PickleableFooBar", __name__, [("FOO", 1)]) diff --git a/tests/test_filters.py b/tests/test_filters.py index f6f727866..88ac36ffc 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -1,13 +1,13 @@ +import errno from fractions import Fraction from unittest import SkipTest -import errno import numpy as np +import av from av import AudioFrame, VideoFrame from av.audio.frame import format_dtypes from av.filter import Filter, Graph -import av from .common import Image, TestCase, fate_suite diff --git a/tests/test_subtitles.py b/tests/test_subtitles.py index 04e613203..fc0bf9d8e 100644 --- a/tests/test_subtitles.py +++ b/tests/test_subtitles.py @@ -1,5 +1,5 @@ -from av.subtitles.subtitle import AssSubtitle, BitmapSubtitle import av +from av.subtitles.subtitle import AssSubtitle, BitmapSubtitle from .common import TestCase, fate_suite diff --git a/tests/test_timeout.py b/tests/test_timeout.py index 7463c0b18..cf6e7f0f8 100644 --- a/tests/test_timeout.py +++ b/tests/test_timeout.py @@ -1,13 +1,12 @@ -from http.server import BaseHTTPRequestHandler -from socketserver import TCPServer import threading import time +from http.server import BaseHTTPRequestHandler +from socketserver import TCPServer import av from .common import TestCase, fate_suite - PORT = 8002 CONTENT = open(fate_suite("mpeg2/mpeg2_field_encoding.ts"), "rb").read() # Needs to be long enough for all host OSes to deal.