Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.
TypeScript agent-skillscodex-clideskop-appdubbingimage-generationlocalizationskillsttsvideo-editingvideo-generationvideo-transcriptionvideo-translation
fix: reject invalid dubbing cue durations
wulienaa4c197e5381
diff --git a/internal/service/dubbing/srt.go b/internal/service/dubbing/srt.goindex 82e18e4c..3ce8bbc7 100644--- a/internal/service/dubbing/srt.go+++ b/internal/service/dubbing/srt.go@@ -50,6 +50,9 @@ func ParseSRTFile(path string) ([]Cue, error) {if err != nil {return nil, fmt.Errorf("cue %d end: %w", index, err)}+ if end <= start {+ return nil, fmt.Errorf("cue %d invalid duration: start=%s end=%s", index, FormatTimestamp(start), FormatTimestamp(end))+ }cues = append(cues, Cue{Index: index,diff --git a/internal/service/dubbing/srt_test.go b/internal/service/dubbing/srt_test.goindex 49caac8a..73527655 100644--- a/internal/service/dubbing/srt_test.go+++ b/internal/service/dubbing/srt_test.go@@ -56,6 +56,34 @@ func TestParseSRTFileAllowsFlexibleArrowWhitespace(t *testing.T) {}}+func TestParseSRTFileRejectsNonPositiveCueDuration(t *testing.T) {+ cases := []struct {+ name string+ content string+ }{+ {+ name: "zero duration",+ content: "1\n00:00:01,000 --> 00:00:01,000\n你好\n\n",+ },+ {+ name: "end before start",+ content: "1\n00:00:02,000 --> 00:00:01,000\n你好\n\n",+ },+ }+ for _, tt := range cases {+ t.Run(tt.name, func(t *testing.T) {+ dir := t.TempDir()+ path := filepath.Join(dir, "bad.srt")+ if err := os.WriteFile(path, []byte(tt.content), 0644); err != nil {+ t.Fatal(err)+ }+ if _, err := ParseSRTFile(path); err == nil {+ t.Fatalf("ParseSRTFile() error = nil, want non-positive duration error")+ }+ })+ }+}+func TestParseTimestampRejectsOutOfRangeValues(t *testing.T) {badValues := []string{"00:60:00,000",