diff --git a/README.md b/README.md index 2143e40..65ec16c 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,15 @@ At the end of the road this section should either disappear or be full of `Yes` | Clip | opacity | Not yet | | | Clip | transform | Not yet | | | Clip [`VideoAsset`] | all ✅ | Yes ✅ | | -| Clip [`ImageAsset`] | src | Partial 🛠 | Download asset only | -| Clip [`ImageAsset`] | crop | Not yet | | +| Clip [`ImageAsset`] | all ✅ | Yes ✅ | | +| Clip [`TitleAsset`] | all | Not yet | | +| Clip [`HTMLAsset`] | all | Not yet | | +| Clip [`AudioAsset`] | src | Partial 🛠 | Download asset only | +| Clip [`AudioAsset`] | trim | Not yet | | +| Clip [`AudioAsset`] | volume | Not yet | | +| Clip [`AudioAsset`] | effect | Not yet | | +| Clip [`LumaAsset`] | src | Partial 🛠 | Download asset only | +| Clip [`LumaAsset`] | trim | Not yet | | | Output | format | Partial 🛠 | Only `mp4` at the moment | | Output | resolution | Yes ✅ | | | Output | aspectRatio | Not yet | | diff --git a/go/ffmpeg.go b/go/ffmpeg.go index 7cc4a9e..fa7e80e 100644 --- a/go/ffmpeg.go +++ b/go/ffmpeg.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "io/ioutil" + "path/filepath" "strings" "github.com/spf13/cast" @@ -28,7 +29,8 @@ import ( ) type FFMPEGSource struct { - path string + path string + needLoop bool } type FFMPEGTrack struct { @@ -60,9 +62,10 @@ func (s *FFMPEG) AddDefaultParams() error { return nil } -func (s *FFMPEG) AddSource(fileName string) error { +func (s *FFMPEG) AddSource(fileName string, needLoop bool) error { var newSource = &FFMPEGSource{ - path: fileName, + path: fileName, + needLoop: needLoop, } s.src = append(s.src, *newSource) return nil @@ -487,6 +490,11 @@ func (s *FFMPEG) generateOutputName() string { return file.Name() } +func (s *FFMPEG) isImagePath(path string) bool { + imageValues := []string{"jpeg", "jpg", "png", "bmp", "gif"} + return slices.Contains(imageValues, filepath.Ext(path)[1:]) +} + func (s *FFMPEG) ToFFMPEG(renderQueue *RenderQueue, queue *ProcessingQueue) error { _ = s.AddDefaultParams() _ = s.SetOutputFormat(renderQueue.Data.Output.Format) @@ -494,6 +502,7 @@ func (s *FFMPEG) ToFFMPEG(renderQueue *RenderQueue, queue *ProcessingQueue) erro _ = s.SetOutputFps(*renderQueue.Data.Output.Fps) } _ = s.SetDefaultBackground(renderQueue.Data.Timeline.Background) + // _ = s.SetOutputAspectRatio(renderQueue.Data.Output.AspectRatio) // Handle Sources var sourceClip = 0 @@ -521,7 +530,7 @@ func (s *FFMPEG) ToFFMPEG(renderQueue *RenderQueue, queue *ProcessingQueue) erro sourceFileName := queue.FindSourceClip(trackNumber, iClip) if sourceFileName != "" { - _ = s.AddSource(sourceFileName) + _ = s.AddSource(sourceFileName, s.isImagePath(sourceFileName)) } _ = clip.ToFFMPEG(s, sourceClip, trackNumber, clipNumber) @@ -585,6 +594,10 @@ func (s *FFMPEG) ToString() []string { // Handle source var maxSource = len(s.src) - 1 for _, source := range s.src { + if source.needLoop { + parameters = append(parameters, "-loop") + parameters = append(parameters, "1") + } parameters = append(parameters, "-i") parameters = append(parameters, source.path) } diff --git a/go/model_clip.go b/go/model_clip.go index 04849c6..a23719c 100644 --- a/go/model_clip.go +++ b/go/model_clip.go @@ -188,11 +188,19 @@ func (s *Clip) ToFFMPEG(FFMPEGCommand FFMPEGCommand, sourceClip int, trackNumber effects = append(effects, FFMPEGCommand.ClipFillerOverlay(sourceClip, trackNumber, currentClip, FFMPEGCommand.ClipCropOverlayPosition(currentAsset.Crop))) } - // case ImageAssetType: - // handled = true - // effects = append(effects, FFMPEGCommand.ClipImage(sourceClip, trackNumber, currentClip, 0, s.Length)) + case ImageAssetType: + var currentAsset = s.Asset.(*ImageAsset) + effects = append(effects, FFMPEGCommand.ClipImage(sourceClip, trackNumber, currentClip, 0, s.Length)) + + if currentAsset.Crop != nil { + effects = append(effects, FFMPEGCommand.ClipCrop(sourceClip, trackNumber, currentClip, currentAsset.Crop)) + effects = append(effects, FFMPEGCommand.ClipFillerOverlay(sourceClip, trackNumber, currentClip, FFMPEGCommand.ClipCropOverlayPosition(currentAsset.Crop))) + } else { + effects = append(effects, FFMPEGCommand.ClipFillerOverlay(sourceClip, trackNumber, currentClip, "topLeft")) + } default: fmt.Println("Type not handled for converting to FFMPEG", typeAsset.String()) + return nil } // Resize clip to ensure concat will work diff --git a/go/model_ffmpeg.go b/go/model_ffmpeg.go index 49951a0..0320349 100644 --- a/go/model_ffmpeg.go +++ b/go/model_ffmpeg.go @@ -18,7 +18,7 @@ along with this program. If not, see . package openapi type FFMPEGCommand interface { - AddSource(string) error + AddSource(string, bool) error AddDefaultParams() error ToString() []string AddTrack(int) error diff --git a/go/model_output.go b/go/model_output.go index e618375..34f3541 100644 --- a/go/model_output.go +++ b/go/model_output.go @@ -44,7 +44,7 @@ type Output struct { Resolution string `json:"resolution,omitempty"` // The aspect ratio (shape) of the video or image. Useful for social media output formats. Options are: - AspectRatio string `json:"aspectRatio,omitempty"` + AspectRatio string `json:"aspectRatio,omitempty" default:"16:9"` Size *Size `json:"size,omitempty"` diff --git a/go/queue.go b/go/queue.go index e705b9f..b089764 100644 --- a/go/queue.go +++ b/go/queue.go @@ -192,6 +192,7 @@ func (s *ProcessingQueue) FetchSrcAssets(trackNumber int, clipNumber int, clip C case ImageAssetType: asset := clip.Asset.(*ImageAsset) assetSrc = asset.Src + assetHandled = true case VideoAssetType: asset := clip.Asset.(*VideoAsset) assetSrc = asset.Src