Skip to content

Commit 2d74c74

Browse files
committed
add nut container format
1 parent 491c059 commit 2d74c74

File tree

5 files changed

+37
-2
lines changed

5 files changed

+37
-2
lines changed

app/core/media/ffmpeg_builders/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Any
22

33
from .audio import AACCommandBuilder, M4ACommandBuilder, MP3CommandBuilder, WAVCommandBuilder, WMACommandBuilder
4-
from .video import FLVCommandBuilder, MKVCommandBuilder, MOVCommandBuilder, MP4CommandBuilder, TSCommandBuilder
4+
from .video import FLVCommandBuilder, MKVCommandBuilder, MOVCommandBuilder, MP4CommandBuilder, TSCommandBuilder, NUTCommandBuilder
55

66

77
def create_builder(format_type: str, *args: Any, **kwargs: Any) -> Any:
@@ -18,6 +18,7 @@ def create_builder(format_type: str, *args: Any, **kwargs: Any) -> Any:
1818
"mkv": MKVCommandBuilder,
1919
"mp4": MP4CommandBuilder,
2020
"ts": TSCommandBuilder,
21+
"nut": NUTCommandBuilder,
2122
"flv": FLVCommandBuilder,
2223
"mov": MOVCommandBuilder,
2324
"mp3": MP3CommandBuilder,

app/core/media/ffmpeg_builders/video/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
from .mov import MOVCommandBuilder
44
from .mp4 import MP4CommandBuilder
55
from .ts import TSCommandBuilder
6+
from .nut import NUTCommandBuilder
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from ..base import FFmpegCommandBuilder
2+
3+
4+
class NUTCommandBuilder(FFmpegCommandBuilder):
5+
def build_command(self) -> list[str]:
6+
command = self._get_basic_ffmpeg_command()
7+
if self.segment_record:
8+
additional_commands = [
9+
"-c:v", "copy",
10+
"-c:a", "copy",
11+
"-map", "0",
12+
"-f", "segment",
13+
"-segment_time", str(self.segment_time),
14+
"-segment_format", "nut",
15+
"-reset_timestamps", "1",
16+
"-muxdelay", "0",
17+
"-muxpreload", "0",
18+
self.full_path,
19+
]
20+
else:
21+
additional_commands = [
22+
"-c:v", "copy",
23+
"-c:a", "copy",
24+
"-map", "0",
25+
"-f", "nut",
26+
"-muxdelay", "0",
27+
"-muxpreload", "0",
28+
self.full_path,
29+
]
30+
31+
command.extend(additional_commands)
32+
return command

app/models/media/video_format_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class VideoFormat:
44
FLV = "FLV"
55
MKV = "MKV"
66
MOV = "MOV"
7+
NUT = "NUT"
78

89
@classmethod
910
def get_formats(cls):

app/utils/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def get_startup_info(system_type: str | None = None):
254254

255255

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

260260

0 commit comments

Comments
 (0)