Skip to content

Commit

Permalink
Implemented check for files with subtitles stream
Browse files Browse the repository at this point in the history
  • Loading branch information
mikigal committed May 4, 2024
1 parent db5d045 commit 82dc921
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
21 changes: 11 additions & 10 deletions data.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ import (
)

type Anime struct {
Name string
Length int64
Size int64
Width int
Height int
FrameRate float64
TotalFrames int
Streams []*ffprobe.Stream
Path string
Status AnimeStatus
Name string
Length int64
Size int64
Width int
Height int
FrameRate float64
TotalFrames int
HasSubtitlesStream bool
Streams []*ffprobe.Stream
Path string
Status AnimeStatus
}

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

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

anime := Anime{
Name: pathSplit[len(pathSplit)-1],
Length: int64(data.Format.DurationSeconds * 1000),
Size: file.Size(),
Width: videoStream.Width,
Height: videoStream.Height,
FrameRate: base / divider,
TotalFrames: int((base / divider) * data.Format.DurationSeconds),
Path: path,
Streams: data.Streams,
Status: NotStarted,
Name: pathSplit[len(pathSplit)-1],
Length: int64(data.Format.DurationSeconds * 1000),
Size: file.Size(),
Width: videoStream.Width,
Height: videoStream.Height,
FrameRate: base / divider,
TotalFrames: int((base / divider) * data.Format.DurationSeconds),
HasSubtitlesStream: data.FirstSubtitleStream() != nil,
Path: path,
Streams: data.Streams,
Status: NotStarted,
}

animeList = append(animeList, anime)
totalProgress = fmt.Sprintf("%d / %d", calcFinished(), len(animeList))
logMessage("Added file "+path, false)
Expand Down
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ func startProcessing() {
animeList[index].Status = Processing
g.Update()

if anime.HasSubtitlesStream && outputFormat != "mkv" {
animeList[index].Status = Error
buttonLabel = "Start"
processing = false
logMessage("File "+anime.Name+" contains subtitles stream, output format must be MKV", false)
g.Update()
return
}

outputPath := fmt.Sprintf("%s_upscaled.%s", strings.TrimSuffix(anime.Path, filepath.Ext(anime.Path)), strings.ToLower(outputFormat))
ffmpegParams := buildUpscalingParams(anime, resolution, shader, outputPath)

Expand Down

0 comments on commit 82dc921

Please sign in to comment.