diff --git a/internal/encoder/encoder.go b/internal/encoder/encoder.go index 31bfe4d..dabaf08 100644 --- a/internal/encoder/encoder.go +++ b/internal/encoder/encoder.go @@ -27,6 +27,7 @@ type StreamInfo struct { SampleAspectRatio string `json:"sample_aspect_ratio"` DisplayAspectRatio string `json:"display_aspect_ratio"` CodecName string `json:"codec_name"` + CodecType string `json:"codec_type"` } type ProbeResult struct { @@ -116,14 +117,19 @@ func (e *Encoder) GetMediaInfo(path string) (width, height int, interlaced bool, return 0, 0, false, fmt.Errorf("parsing ffprobe output: %w", err) } + foundVideo := false for _, stream := range result.Streams { - if stream.CodecName == "mpeg2video" || stream.CodecName == "h264" || stream.CodecName == "hevc" { + if stream.CodecType == "video" { width = stream.Width height = stream.Height - fmt.Printf("DEBUG detected video: %dx%d, SAR=%s\n", width, height, stream.SampleAspectRatio) + foundVideo = true + fmt.Printf("DEBUG detected video: %dx%d, codec=%s, SAR=%s\n", width, height, stream.CodecName, stream.SampleAspectRatio) break } } + if !foundVideo { + return 0, 0, false, fmt.Errorf("no video stream found") + } cmd = exec.Command(e.ffmpegPath, "-hide_banner",