|
| 1 | +# Soothe - testing framework for encoders quality |
| 2 | +# Copyright (C) 2020, Fluendo, S.A. |
| 3 | +# Author: Pablo Marcos Oltra <[email protected]>, Fluendo, S.A. |
| 4 | +# Copyright (C) 2025, Igalia, S.L. |
| 5 | +# Author: Stéphane Cerveau <[email protected]> |
| 6 | +# |
| 7 | +# This library is free software; you can redistribute it and/or |
| 8 | +# modify it under the terms of the GNU Lesser General Public License |
| 9 | +# as published by the Free Software Foundation, either version 3 |
| 10 | +# of the License, or (at your option) any later version. |
| 11 | +# |
| 12 | +# This library is distributed in the hope that it will be useful, |
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | +# Lesser General Public License for more details. |
| 16 | +# |
| 17 | +# You should have received a copy of the GNU Lesser General Public |
| 18 | +# License along with this library. If not, see <https://www.gnu.org/licenses/>. |
| 19 | + |
| 20 | +"""Module for VP9 reference encoder""" |
| 21 | + |
| 22 | +from ..codec import Codec |
| 23 | +from ..encoder import Encoder, register_encoder |
| 24 | +from ..utils import run_command |
| 25 | + |
| 26 | + |
| 27 | +@register_encoder |
| 28 | +class VP9VPXEncoder(Encoder): |
| 29 | + """libvpx VP9 reference encoder implementation""" |
| 30 | + encoder_name = "libvpx-VP9" |
| 31 | + codec = Codec.VP9 |
| 32 | + description = "libvpx VP9 reference encoder" |
| 33 | + binary = "vpxenc" |
| 34 | + is_reference = True |
| 35 | + file_extension = ".webm" |
| 36 | + |
| 37 | + def encode( |
| 38 | + self, |
| 39 | + input_file: str, |
| 40 | + output_file: str, |
| 41 | + timeout: int, |
| 42 | + verbose: bool, |
| 43 | + ): |
| 44 | + """Encodes input_file in output_file""" |
| 45 | + |
| 46 | + cmd = [ |
| 47 | + self.binary, |
| 48 | + "--codec=vp9", # Use VP9 codec |
| 49 | + "--good", # Good quality mode |
| 50 | + "--cpu-used=4", # Speed vs quality trade-off |
| 51 | + "--end-usage=q", # Constant quality mode |
| 52 | + "--cq-level=30", # Quality level |
| 53 | + "--threads=4", # Number of threads |
| 54 | + "--webm", |
| 55 | + "-o", |
| 56 | + output_file, |
| 57 | + input_file, |
| 58 | + ] |
| 59 | + |
| 60 | + run_command(cmd, timeout=timeout, verbose=verbose) |
0 commit comments