feat: ConvertGUI v2.0 (Wails + preview/trim + NSIS + Gitea CI)
Build Windows Installer / build (push) Successful in 4m11s
Build Windows Installer / build (push) Successful in 4m11s
This commit is contained in:
40 files changed
+6084
-266
No files matched your search
@@ -0,0 +1,96 @@
|
||||
package media
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseProbeJSON_MultiAudio(t *testing.T) {
|
||||
sample := `{
|
||||
"format": {
|
||||
"filename": "clip.mp4",
|
||||
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
|
||||
"duration": "125.500000",
|
||||
"size": "104857600",
|
||||
"bit_rate": "6683824"
|
||||
},
|
||||
"streams": [
|
||||
{
|
||||
"index": 0,
|
||||
"codec_type": "video",
|
||||
"codec_name": "h264",
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"pix_fmt": "yuv420p",
|
||||
"avg_frame_rate": "60/1",
|
||||
"r_frame_rate": "60/1"
|
||||
},
|
||||
{
|
||||
"index": 1,
|
||||
"codec_type": "audio",
|
||||
"codec_name": "aac",
|
||||
"channels": 2,
|
||||
"channel_layout": "stereo",
|
||||
"sample_rate": "48000",
|
||||
"tags": {"title": "Desktop Audio"}
|
||||
},
|
||||
{
|
||||
"index": 2,
|
||||
"codec_type": "audio",
|
||||
"codec_name": "aac",
|
||||
"channels": 1,
|
||||
"channel_layout": "mono",
|
||||
"sample_rate": "48000",
|
||||
"tags": {"title": "Microphone", "language": "rus"}
|
||||
}
|
||||
]
|
||||
}`
|
||||
|
||||
info, err := ParseProbeJSON([]byte(sample), `C:\clips\clip.mp4`, 123)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if info.Width != 1920 || info.Height != 1080 {
|
||||
t.Fatalf("unexpected resolution: %dx%d", info.Width, info.Height)
|
||||
}
|
||||
if info.FPS != 60 {
|
||||
t.Fatalf("expected 60 fps, got %v", info.FPS)
|
||||
}
|
||||
if info.Duration != 125.5 {
|
||||
t.Fatalf("expected duration 125.5, got %v", info.Duration)
|
||||
}
|
||||
if len(info.AudioStreams) != 2 {
|
||||
t.Fatalf("expected 2 audio streams, got %d", len(info.AudioStreams))
|
||||
}
|
||||
if info.AudioStreams[1].AudioOrder != 1 || info.AudioStreams[1].Title != "Microphone" || info.AudioStreams[1].Language != "rus" {
|
||||
t.Fatalf("unexpected audio stream 1: %+v", info.AudioStreams[1])
|
||||
}
|
||||
if !info.BrowserNative {
|
||||
t.Fatalf("expected mp4 h264+aac to be browser native")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseProbeJSON_NoVideo(t *testing.T) {
|
||||
sample := `{"format":{"duration":"10"},"streams":[{"index":0,"codec_type":"audio","codec_name":"mp3"}]}`
|
||||
if _, err := ParseProbeJSON([]byte(sample), "audio.mp3", 100); err == nil {
|
||||
t.Fatalf("expected error when no video stream exists")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseRationalFPS(t *testing.T) {
|
||||
cases := []struct {
|
||||
in string
|
||||
want float64
|
||||
}{
|
||||
{"60/1", 60},
|
||||
{"30000/1001", 30000.0 / 1001.0},
|
||||
{"0/0", 0},
|
||||
{"", 0},
|
||||
{"24", 24},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
got := parseRationalFPS(tc.in)
|
||||
if got != tc.want {
|
||||
t.Fatalf("parseRationalFPS(%q) = %v, want %v", tc.in, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user