Skip to content

Commit 82dc921

Browse files
committed
Implemented check for files with subtitles stream
1 parent db5d045 commit 82dc921

File tree

3 files changed

+32
-22
lines changed

3 files changed

+32
-22
lines changed

data.go

+11-10
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ import (
66
)
77

88
type Anime struct {
9-
Name string
10-
Length int64
11-
Size int64
12-
Width int
13-
Height int
14-
FrameRate float64
15-
TotalFrames int
16-
Streams []*ffprobe.Stream
17-
Path string
18-
Status AnimeStatus
9+
Name string
10+
Length int64
11+
Size int64
12+
Width int
13+
Height int
14+
FrameRate float64
15+
TotalFrames int
16+
HasSubtitlesStream bool
17+
Streams []*ffprobe.Stream
18+
Path string
19+
Status AnimeStatus
1920
}
2021

2122
type Shader struct {

gui.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const encoderTooltip = "Codec for encoding output file. In most cases GPU based
2121
"AV1 is compatible only with RTX 4000+ and RX 6500XT+"
2222
const crfTooltip = "Constant Rate Factor parameter encoder. \nDon't set it too high - file will be very big. " +
2323
"\n\nCorrect values: 0 - 51 \nIf you don't know what to enter, leave it as 20"
24-
const outputFormatTooltip = "If your input file have subtitles stream (mainly in MKV files) you MUST select MKV as output, otherwise ffmpeg will throw error"
24+
const outputFormatTooltip = "If your input file contains subtitles streams you must use MKV as output format due to other formats limitations"
2525
const compatibilityModeTooltip = "Should be used only for compatibility troubleshooting, disables most of features"
2626
const debugModeTooltip = "Show more detailed logs, useful for troubleshooting and debugging"
2727

@@ -160,18 +160,18 @@ LOOP:
160160
divider, _ := strconv.ParseFloat(frameRateSplit[1], 64)
161161

162162
anime := Anime{
163-
Name: pathSplit[len(pathSplit)-1],
164-
Length: int64(data.Format.DurationSeconds * 1000),
165-
Size: file.Size(),
166-
Width: videoStream.Width,
167-
Height: videoStream.Height,
168-
FrameRate: base / divider,
169-
TotalFrames: int((base / divider) * data.Format.DurationSeconds),
170-
Path: path,
171-
Streams: data.Streams,
172-
Status: NotStarted,
163+
Name: pathSplit[len(pathSplit)-1],
164+
Length: int64(data.Format.DurationSeconds * 1000),
165+
Size: file.Size(),
166+
Width: videoStream.Width,
167+
Height: videoStream.Height,
168+
FrameRate: base / divider,
169+
TotalFrames: int((base / divider) * data.Format.DurationSeconds),
170+
HasSubtitlesStream: data.FirstSubtitleStream() != nil,
171+
Path: path,
172+
Streams: data.Streams,
173+
Status: NotStarted,
173174
}
174-
175175
animeList = append(animeList, anime)
176176
totalProgress = fmt.Sprintf("%d / %d", calcFinished(), len(animeList))
177177
logMessage("Added file "+path, false)

main.go

+9
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,15 @@ func startProcessing() {
150150
animeList[index].Status = Processing
151151
g.Update()
152152

153+
if anime.HasSubtitlesStream && outputFormat != "mkv" {
154+
animeList[index].Status = Error
155+
buttonLabel = "Start"
156+
processing = false
157+
logMessage("File "+anime.Name+" contains subtitles stream, output format must be MKV", false)
158+
g.Update()
159+
return
160+
}
161+
153162
outputPath := fmt.Sprintf("%s_upscaled.%s", strings.TrimSuffix(anime.Path, filepath.Ext(anime.Path)), strings.ToLower(outputFormat))
154163
ffmpegParams := buildUpscalingParams(anime, resolution, shader, outputPath)
155164

0 commit comments

Comments
 (0)