from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from tbc_video_export.config.json import JsonConfig

DEFAULT_CONFIG: JsonConfig = {
    "profiles": [
        {
            "name": "ffv1",
            "default": True,
            "video_profile": "ffv1",
            "audio_profile": "flac",
        },
        {
            "name": "prores_hq",
            "video_profile": [
                "prores_422_hq",
                "prores_422_hq_videotoolbox",
            ],
            "audio_profile": "pcm_24",
        },
        {
            "name": "prores_4444xq",
            "video_profile": [
                "prores_4444_xq",
                "prores_4444_xq_videotoolbox",
            ],
            "audio_profile": "pcm_24",
        },
        {
            "name": "v210",
            "video_profile": "v210",
            "audio_profile": "pcm_24",
        },
        {
            "name": "v410",
            "video_profile": "v410",
            "audio_profile": "pcm_24",
        },
        {
            "name": "d10",
            "video_profile": [
                "d10_mpeg2_pal",
                "d10_mpeg2_ntsc",
            ],
            "include_vbi": True,
            "audio_profile": "pcm_24",
        },
        {
            "name": "x264",
            "video_profile": [
                "x264",
                "x264_vaapi",
                "x264_nvenc",
                "x264_quicksync",
                "x264_amf",
                "x264_videotoolbox",
            ],
            "audio_profile": "aac",
        },
        {
            "name": "x264_lossless",
            "video_profile": "x264_lossless",
            "audio_profile": "aac",
        },
        {
            "name": "x264_web",
            "video_profile": [
                "x264",
                "x264_vaapi",
                "x264_nvenc",
                "x264_quicksync",
                "x264_amf",
                "x264_videotoolbox",
            ],
            "audio_profile": "aac",
            "filter_profiles": [
                "bwdif",
            ],
        },
        {
            "name": "x265",
            "video_profile": [
                "x265",
                "x265_vaapi",
                "x265_nvenc",
                "x265_quicksync",
                "x265_amf",
                "x265_videotoolbox",
            ],
            "audio_profile": "aac",
        },
        {
            "name": "x265_lossless",
            "video_profile": "x265_lossless",
            "audio_profile": "aac",
        },
        {
            "name": "x265_web",
            "video_profile": [
                "x265",
                "x265_vaapi",
                "x265_nvenc",
                "x265_quicksync",
                "x265_amf",
                "x265_videotoolbox",
            ],
            "audio_profile": "aac",
            "filter_profiles": [
                "bwdif",
            ],
        },
        {
            "name": "av1",
            "video_profile": [
                "av1",
            ],
            "audio_profile": "aac",
        },
        {
            "name": "av1_lossless",
            "video_profile": "av1_lossless",
            "audio_profile": "aac",
        },
        {
            "name": "av1_web",
            "video_profile": [
                "av1",
            ],
            "audio_profile": "aac",
            "filter_profiles": [
                "bwdif",
            ],
        },
    ],
    "video_profiles": [
        {
            "name": "ffv1",
            "description": "FFV1",
            "codec": "ffv1",
            "video_format": "yuv422p10le",
            "container": "mkv",
            "opts": [
                "-coder",
                1,
                "-level",
                3,
                "-context",
                1,
                "-slices",
                24,
                "-slicecrc",
                1,
                "-g",
                1,
            ],
        },
        {
            "name": "prores_422_hq",
            "description": "ProRes 422 HQ",
            "codec": "prores",
            "video_format": "yuv422p10le",
            "container": "mov",
            "opts": [
                "-profile:v",
                "hq",
                "-vendor",
                "apl0",
            ],
        },
        {
            "name": "prores_422_hq_videotoolbox",
            "description": "ProRes 422 HQ - Apple Video Toolbox",
            "codec": "prores_videotoolbox",
            "video_format": "uyvy422",
            "container": "mov",
            "opts": [
                "-profile:v",
                "hq",
            ],
            "hardware_accel": "videotoolbox",
        },
        {
            "name": "prores_4444_xq",
            "description": "ProRes 4444 XQ",
            "codec": "prores",
            "video_format": "yuv444p10le",
            "container": "mov",
            "opts": [
                "-profile:v",
                "xq",
                "-vendor",
                "apl0",
            ],
        },
        {
            "name": "prores_4444_xq_videotoolbox",
            "description": "ProRes 4444 XQ - Apple Video Toolbox",
            "codec": "prores_videotoolbox",
            "video_format": "p416le",
            "container": "mov",
            "opts": [
                "-profile:v",
                "xq",
            ],
            "hardware_accel": "videotoolbox",
        },
        {
            "name": "v210",
            "description": "V210",
            "codec": "v210",
            "video_format": "yuv422p10le",
            "container": "mov",
        },
        {
            "name": "v410",
            "description": "V410",
            "codec": "v410",
            "video_format": "yuv422p10le",
            "container": "mov",
        },
        {
            "name": "d10_mpeg2_pal",
            "description": "D10 (Sony IMX/XDCAM)",
            "codec": "mpeg2video",
            "video_format": "yuv422p",
            "container": "mxf",
            "output_format": "mxf_d10",
            "opts": [
                "-minrate",
                "50000000",
                "-maxrate",
                "50000000",
                "-b:v",
                "50000000",
                "-g",
                1,
                "-flags",
                "ildct+ilme+low_delay",
                "-intra_vlc",
                1,
                "-non_linear_quant",
                1,
                "-dc",
                10,
                "-ps",
                1,
                "-qmin",
                1,
                "-qmax",
                3,
                "-bufsize",
                "2000000",
                "-rc_init_occupancy",
                "2000000",
            ],
            "video_system": "pal",
            "filter_profiles_additions": [
                "resize_pal_d10",
            ],
        },
        {
            "name": "d10_mpeg2_ntsc",
            "description": "D10 (Sony IMX/XDCAM) *BROKEN*",
            "codec": "mpeg2video",
            "video_format": "yuv422p",
            "container": "mxf",
            "output_format": "mxf_d10",
            "opts": [
                "-minrate",
                "49999840",
                "-maxrate",
                "49999840",
                "-b:v",
                "49999840",
                "-g",
                1,
                "-flags",
                "ildct+ilme+low_delay",
                "-intra_vlc",
                1,
                "-non_linear_quant",
                1,
                "-dc",
                10,
                "-ps",
                1,
                "-qmin",
                1,
                "-qmax",
                3,
                "-bufsize",
                "1668328",
                "-rc_init_occupancy",
                "1668328",
            ],
            "video_system": "ntsc",
            "filter_profiles_additions": [
                "resize_ntsc_d10",
            ],
        },
        {
            "name": "x264",
            "description": "H.264 AVC",
            "codec": "libx264",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-crf",
                18,
                "-preset",
                "slow",
                "-x264opts",
                "interlaced=1",
                "-movflags",
                "+faststart",
            ],
            "filter_profiles_override": [],
        },
        {
            "name": "x264_lossless",
            "description": "H.264 AVC - Lossless",
            "codec": "libx264",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-qp",
                0,
                "-preset",
                "veryslow",
            ],
            "filter_profiles_override": [],
        },
        {
            "name": "x264_vaapi",
            "description": "H.264 AVC - VA-API",
            "codec": "h264_vaapi",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-rc_mode",
                "CQP",
                "-global_quality",
                24,
                "-movflags",
                "+faststart",
            ],
            "hardware_accel": "vaapi",
        },
        {
            "name": "x264_nvenc",
            "description": "H.264 AVC - Nvidia NVENC - Web",
            "codec": "h264_nvenc",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-rc",
                "constqp",
                "-qp",
                22,
                "-movflags",
                "+faststart",
            ],
            "hardware_accel": "nvenc",
        },
        {
            "name": "x264_quicksync",
            "description": "H.264 AVC - Intel QuickSync - Web",
            "codec": "h264_qsv",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-global_quality",
                19,
                "-movflags",
                "+faststart",
            ],
            "hardware_accel": "quicksync",
        },
        {
            "name": "x264_amf",
            "description": "H.264 AVC - AMD AMF - Web",
            "codec": "h264_amf",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-quality",
                2,
                "-rc",
                "cqp",
                "-qp_i",
                28,
                "-qp_p",
                28,
                "-movflags",
                "+faststart",
            ],
            "hardware_accel": "amf",
        },
        {
            "name": "x264_videotoolbox",
            "description": "H.264 AVC - Apple Video Toolbox - Web",
            "codec": "h264_videotoolbox",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-profile:v",
                "main",
                "-q:v",
                60,
                "-tag:v",
                "hvc1",
            ],
            "hardware_accel": "videotoolbox",
        },
        {
            "name": "x265",
            "description": "H.265 HEVC",
            "codec": "libx265",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-crf",
                23,
                "-preset",
                "slow",
                "-movflags",
                "+faststart",
                "-x265-params",
                "interlace=true",
            ],
        },
        {
            "name": "x265_lossless",
            "description": "H.265 HEVC - Lossless",
            "codec": "libx265",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-crf",
                20,
                "-preset",
                "slow",
                "-movflags",
                "+faststart",
                "-x265-params",
                "lossless=1",
            ],
        },
        {
            "name": "x265_vaapi",
            "description": "H.265 HEVC - VA-API - Web",
            "codec": "hevc_vaapi",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-rc_mode",
                "CQP",
                "-global_quality",
                24,
                "-movflags",
                "+faststart",
            ],
            "hardware_accel": "vaapi",
        },
        {
            "name": "x265_nvenc",
            "description": "H.265 HEVC - Nvidia NVENC - Web",
            "codec": "hevc_nvenc",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-rc",
                "constqp",
                "-qp",
                24,
                "-b_ref_mode",
                0,
                "-movflags",
                "+faststart",
            ],
            "hardware_accel": "nvenc",
        },
        {
            "name": "x265_quicksync",
            "description": "H.265 HEVC - Intel QuickSync - Web",
            "codec": "hevc_qsv",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-global_quality",
                19,
                "-movflags",
                "+faststart",
            ],
            "hardware_accel": "quicksync",
        },
        {
            "name": "x265_amf",
            "description": "H.265 HEVC - AMD AMF - Web",
            "codec": "hevc_amf",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-quality",
                2,
                "-rc",
                "cqp",
                "-qp_i",
                28,
                "-qp_p",
                28,
                "-movflags",
                "+faststart",
            ],
            "hardware_accel": "amf",
        },
        {
            "name": "x265_videotoolbox",
            "description": "H.265 HEVC - Apple Video Toolbox - Web",
            "codec": "hevc_videotoolbox",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-profile:v",
                "main",
                "-q:v",
                60,
                "-tag:v",
                "hvc1",
                "-movflags",
                "+faststart",
            ],
            "hardware_accel": "videotoolbox",
        },
        {
            "name": "av1",
            "description": "AV1",
            "codec": "libsvtav1",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-crf",
                24,
                "-cpu-used",
                6,
                "-row-mt",
                1,
                "-movflags",
                "+faststart",
            ],
        },
        {
            "name": "av1_lossless",
            "description": "AV1 - Lossless",
            "codec": "libaom-av1",
            "video_format": "yuv420p",
            "container": "mov",
            "opts": [
                "-crf",
                0,
                "-cpu-used",
                6,
                "-row-mt",
                1,
                "-error-resilience",
                1,
                "-aom-params",
                "lossless=1",
            ],
        },
    ],
    "audio_profiles": [
        {
            "name": "flac",
            "description": "FLAC",
            "codec": "flac",
            "opts": [
                "-compression_level",
                12,
            ],
        },
        {
            "name": "pcm_16",
            "description": "PCM 16-bits",
            "codec": "pcm_s16le",
        },
        {
            "name": "pcm_24",
            "description": "PCM 24-bits",
            "codec": "pcm_s24le",
        },
        {
            "name": "aac",
            "description": "AAC",
            "codec": "aac",
            "opts": [
                "-ar",
                48000,
                "-b:a",
                "320K",
            ],
        },
    ],
    "filter_profiles": [
        {
            "name": "bwdif",
            "description": "BWDIF",
            "video_filter": "bwdif",
        },
        {
            "name": "colorlevels32",
            "description": "Colorlevels (32)",
            "video_filter": "colorlevels=rimin=32/255:gimin=32/255:bimin=32/255",
        },
        {
            "name": "map_l_to_lr",
            "description": "Map L to L+R",
            "other_filter": "[2:a]pan=stereo|FL=FL|FR=FL",
        },
        {
            "name": "map_r_to_lr",
            "description": "Map R to L+R",
            "other_filter": "[2:a]pan=stereo|FR=FR|FL=FR",
        },
        {
            "name": "resize_pal_standard",
            "description": "Resize to PAL standard SD resoluton (720x576)",
            "video_filter": "scale=720x576:flags=lanczos,setdar=4/3",
        },
        {
            "name": "resize_ntsc_standard",
            "description": "Resize to NTSC standard SD resoluton (720x480)",
            "video_filter": "scale=720x480:flags=lanczos,setdar=4/3",
        },
        {
            "name": "resize_pal_d10",
            "description": "Resize and pad to D10 (Sony IMX/XDCAM) resoluton (720x608)",  # noqa: E501
            "video_filter": "scale=720x608:flags=lanczos",
        },
        {
            "name": "resize_ntsc_d10",
            "description": "Resize and pad to D10 (Sony IMX/XDCAM) resoluton (720x512)",  # noqa: E501
            "video_filter": "scale=720x512:flags=lanczos",
        },
    ],
}
