Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/core/media/ffmpeg_builders/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
from typing import Any

from .audio import AACCommandBuilder, M4ACommandBuilder, MP3CommandBuilder, WAVCommandBuilder, WMACommandBuilder
from .video import FLVCommandBuilder, MKVCommandBuilder, MOVCommandBuilder, MP4CommandBuilder, TSCommandBuilder
from .video import (
FLVCommandBuilder,
MKVCommandBuilder,
MOVCommandBuilder,
MP4CommandBuilder,
NUTCommandBuilder,
TSCommandBuilder,
)


def create_builder(format_type: str, *args: Any, **kwargs: Any) -> Any:
Expand All @@ -18,6 +25,7 @@ def create_builder(format_type: str, *args: Any, **kwargs: Any) -> Any:
"mkv": MKVCommandBuilder,
"mp4": MP4CommandBuilder,
"ts": TSCommandBuilder,
"nut": NUTCommandBuilder,
"flv": FLVCommandBuilder,
"mov": MOVCommandBuilder,
"mp3": MP3CommandBuilder,
Expand Down
1 change: 1 addition & 0 deletions app/core/media/ffmpeg_builders/video/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
from .mkv import MKVCommandBuilder
from .mov import MOVCommandBuilder
from .mp4 import MP4CommandBuilder
from .nut import NUTCommandBuilder
from .ts import TSCommandBuilder
32 changes: 32 additions & 0 deletions app/core/media/ffmpeg_builders/video/nut.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from ..base import FFmpegCommandBuilder


class NUTCommandBuilder(FFmpegCommandBuilder):
def build_command(self) -> list[str]:
command = self._get_basic_ffmpeg_command()
if self.segment_record:
additional_commands = [
"-c:v", "copy",
"-c:a", "copy",
"-map", "0",
"-f", "segment",
"-segment_time", str(self.segment_time),
"-segment_format", "nut",
"-reset_timestamps", "1",
"-muxdelay", "0",
"-muxpreload", "0",
self.full_path,
]
else:
additional_commands = [
"-c:v", "copy",
"-c:a", "copy",
"-map", "0",
"-f", "nut",
"-muxdelay", "0",
"-muxpreload", "0",
self.full_path,
]

command.extend(additional_commands)
return command
1 change: 1 addition & 0 deletions app/models/media/video_format_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class VideoFormat:
FLV = "FLV"
MKV = "MKV"
MOV = "MOV"
NUT = "NUT"

@classmethod
def get_formats(cls):
Expand Down
2 changes: 1 addition & 1 deletion app/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def get_startup_info(system_type: str | None = None):


def is_valid_video_file(source: str) -> bool:
video_extensions = ['.mp4', '.mov', '.mkv', '.ts', '.flv', '.mp3', '.m4a', '.wav', '.aac', '.wma']
video_extensions = ['.mp4', '.mov', '.mkv', '.nut', '.ts', '.flv', '.mp3', '.m4a', '.wav', '.aac', '.wma']
return Path(source).suffix.lower() in video_extensions


Expand Down