Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --seconds parameter to specify video duration #9

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func newGenerateCommand() *ffcli.Command {
fs.IntVar(&cfg.Height, "height", 0, "output video height (optional)")
fs.BoolVar(&cfg.Explore, "explore", false, "explore mode (optional)")
fs.BoolVar(&cfg.LastFrame, "last-frame", false, "use source image as the last frame (optional)")
fs.IntVar(&cfg.Seconds, "seconds", 10, "duration of the video in seconds (optional)")

return &ffcli.Command{
Name: cmd,
Expand Down Expand Up @@ -120,6 +121,7 @@ func newExtendCommand() *ffcli.Command {
fs.BoolVar(&cfg.Upscale, "upscale", false, "upscale frames (optional)")
fs.BoolVar(&cfg.Watermark, "watermark", false, "add watermark (optional)")
fs.BoolVar(&cfg.Explore, "explore", false, "explore mode (optional)")
fs.IntVar(&cfg.Seconds, "seconds", 2, "duration of the video in seconds (optional)")

return &ffcli.Command{
Name: cmd,
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/extend/extend.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Config struct {
Upscale bool
Watermark bool
Explore bool
Seconds int
}

// Run generates a video from an image and a text prompt.
Expand Down Expand Up @@ -106,6 +107,7 @@ func Run(ctx context.Context, cfg *Config) error {
Watermark: cfg.Watermark,
Extend: false,
ExploreMode: cfg.Explore,
Seconds: cfg.Seconds,
})
if err != nil {
return fmt.Errorf("vidai: couldn't generate video: %w", err)
Expand Down
3 changes: 3 additions & 0 deletions pkg/cmd/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Config struct {
Height int
Explore bool
LastFrame bool
Seconds int
}

// Run generates a video from an image and a text prompt.
Expand Down Expand Up @@ -89,6 +90,7 @@ func Run(ctx context.Context, cfg *Config) error {
Height: cfg.Height,
ExploreMode: cfg.Explore,
LastFrame: cfg.LastFrame,
Seconds: cfg.Seconds,
})
if err != nil {
return fmt.Errorf("vidai: couldn't generate video: %w", err)
Expand All @@ -104,6 +106,7 @@ func Run(ctx context.Context, cfg *Config) error {
Upscale: cfg.Upscale,
Watermark: cfg.Watermark,
Extend: true,
Seconds: cfg.Seconds,
})
if err != nil {
return fmt.Errorf("vidai: couldn't extend video: %w", err)
Expand Down
5 changes: 3 additions & 2 deletions pkg/runway/runway.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ type GenerateRequest struct {
Height int
ExploreMode bool
LastFrame bool
Seconds int
}

type Error struct {
Expand Down Expand Up @@ -466,7 +467,7 @@ func (c *Client) Generate(ctx context.Context, cfg *GenerateRequest) (*Generatio
AssetGroupName string `json:"assetGroupName"`
ExploreMode bool `json:"exploreMode"`
}{
Seconds: 4,
Seconds: cfg.Seconds,
Gen2Options: gen2Options{
Interpolate: cfg.Interpolate,
Seed: seed,
Expand Down Expand Up @@ -513,7 +514,7 @@ func (c *Client) Generate(ctx context.Context, cfg *GenerateRequest) (*Generatio
Internal: false,
Options: gen3Options{
Name: name,
Seconds: 10,
Seconds: cfg.Seconds,
TextPrompt: cfg.Prompt,
Seed: seed,
ExploreMode: cfg.ExploreMode,
Expand Down
Loading