Compare commits

..

No commits in common. "7717bf13a17ae357950ec80b7ba81764e9673ffe" and "ab3207d44199ed8202d3242c7d837a53eccec586" have entirely different histories.

5 changed files with 65 additions and 82 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4,9 +4,8 @@ import (
"embed"
"os"
"videoconcat/services"
"github.com/wailsapp/wails/v3/pkg/application"
"videoconcat/services"
)
//go:embed assets
@ -55,9 +54,9 @@ func main() {
// 创建窗口
services.LogDebug("创建应用窗口...")
window := app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "视频拼接工具",
Width: 1100,
Height: 800,
Title: "视频拼接工具",
Width: 1100,
Height: 800,
MinWidth: 800,
MinHeight: 600,
})

View File

@ -23,16 +23,16 @@ func NewExtractService() *ExtractService {
// ExtractFrameRequest 抽帧请求
type ExtractFrameRequest struct {
FolderPath string `json:"folderPath"`
ExtractCount int `json:"extractCount"` // 每个视频生成的数量
FolderPath string `json:"folderPath"`
ExtractCount int `json:"extractCount"` // 每个视频生成的数量
}
// ExtractFrameResult 抽帧结果
type ExtractFrameResult struct {
VideoPath string `json:"videoPath"`
VideoPath string `json:"videoPath"`
OutputPath string `json:"outputPath"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
}
// ListVideos 列出文件夹中的视频文件
@ -213,37 +213,37 @@ func (s *ExtractService) ExtractFrames(ctx context.Context, req ExtractFrameRequ
// 检查文件是否已存在
if _, err := os.Stat(t.OutputPath); err == nil {
mu.Lock()
current++
result := ExtractFrameResult{
VideoPath: t.VideoPath,
OutputPath: t.OutputPath,
Success: true,
}
results = append(results, result)
mu.Unlock()
return
}
err := s.RemoveFrameRandom(ctx, t.VideoPath, t.OutputPath)
mu.Lock()
current++
var result ExtractFrameResult
if err != nil {
result = ExtractFrameResult{
VideoPath: t.VideoPath,
Success: false,
Error: err.Error(),
}
} else {
result = ExtractFrameResult{
VideoPath: t.VideoPath,
OutputPath: t.OutputPath,
Success: true,
}
result := ExtractFrameResult{
VideoPath: t.VideoPath,
OutputPath: t.OutputPath,
Success: true,
}
results = append(results, result)
mu.Unlock()
return
}
err := s.RemoveFrameRandom(ctx, t.VideoPath, t.OutputPath)
mu.Lock()
current++
var result ExtractFrameResult
if err != nil {
result = ExtractFrameResult{
VideoPath: t.VideoPath,
Success: false,
Error: err.Error(),
}
} else {
result = ExtractFrameResult{
VideoPath: t.VideoPath,
OutputPath: t.OutputPath,
Success: true,
}
}
results = append(results, result)
mu.Unlock()
}(task)
}
@ -301,28 +301,29 @@ func (s *ExtractService) ModifyVideosMetadata(ctx context.Context, folderPath st
outputFileName := fmt.Sprintf("modify%d%s", randomNum, filepath.Base(videoPath))
outputPath := filepath.Join(outputDir, outputFileName)
err := s.ModifyByMetadata(ctx, videoPath, outputPath)
mu.Lock()
current++
var result ExtractFrameResult
if err != nil {
result = ExtractFrameResult{
VideoPath: videoPath,
Success: false,
Error: err.Error(),
}
} else {
result = ExtractFrameResult{
VideoPath: videoPath,
OutputPath: outputPath,
Success: true,
}
err := s.ModifyByMetadata(ctx, videoPath, outputPath)
mu.Lock()
current++
var result ExtractFrameResult
if err != nil {
result = ExtractFrameResult{
VideoPath: videoPath,
Success: false,
Error: err.Error(),
}
results = append(results, result)
mu.Unlock()
} else {
result = ExtractFrameResult{
VideoPath: videoPath,
OutputPath: outputPath,
Success: true,
}
}
results = append(results, result)
mu.Unlock()
}(video)
}
wg.Wait()
return results, nil
}

View File

@ -381,16 +381,16 @@ func (s *VideoService) JoinVideos(ctx context.Context, req VideoConcatRequest) (
}
helper := GetFFmpegHelper()
if !helper.IsAvailable() {
LogError("ffmpeg 不可用")
result.Status = "拼接失败"
result.Progress = "失败"
mu.Lock()
results = append(results, result)
mu.Unlock()
return
}
cmd := helper.Command(args...)
if !helper.IsAvailable() {
LogError("ffmpeg 不可用")
result.Status = "拼接失败"
result.Progress = "失败"
mu.Lock()
results = append(results, result)
mu.Unlock()
return
}
cmd := helper.Command(args...)
cmd.Run() // 忽略错误,水印是可选的
}
@ -438,3 +438,4 @@ func (s *VideoService) JoinVideos(ctx context.Context, req VideoConcatRequest) (
wg.Wait()
return results, nil
}