Skip to content

Commit

Permalink
Merge pull request #43 from sturman/output-file-name
Browse files Browse the repository at this point in the history
Add option to specify output file name
  • Loading branch information
akiomik authored Nov 5, 2023
2 parents ce6858a + 5109a92 commit b573d51
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ vimeo-dl -i "https://8vod-adaptive.akamaized.net/xxx/yyy/sep/video/9f88d1ff,b83d
--audio-id "b83d0f9d" \
--combine

# Download a video as my-video-file-name.mp4.
vimeo-dl -i "https://8vod-adaptive.akamaized.net/xxx/yyy/sep/video/9f88d1ff,b83d0f9d,da44206b,f34fd50d,f9ebc26f/master.json?base64_init=1" \
--video-id "b83d0f9d" \
--audio-id "b83d0f9d" \
--combine \
--output "my-video-file-name"

# The combine option is equivalent to the following command.
vimeo-dl -i "https://8vod-adaptive.akamaized.net/xxx/yyy/sep/video/9f88d1ff,b83d0f9d,da44206b,f34fd50d,f9ebc26f/master.json?base64_init=1" \
--video-id "b83d0f9d" \
Expand All @@ -51,6 +58,7 @@ Flags:
--combine combine video and audio into a single mp4 (ffmpeg is required)
-h, --help help for vimeo-dl
-i, --input string url for master.json (required)
-o, --output string output file name
--user-agent string user-agent for request
-v, --version version for vimeo-dl
--video-id string video id
Expand Down
22 changes: 14 additions & 8 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ import (
)

var (
input string
userAgent string
videoId string
audioId string
combine bool
input string
userAgent string
videoId string
audioId string
outputFilename string
combine bool
)

var rootCmd = &cobra.Command{
Expand All @@ -56,7 +57,11 @@ var rootCmd = &cobra.Command{
os.Exit(1)
}

videoOutputFilename := masterJson.ClipId + "-video.mp4"
if outputFilename == "" {
outputFilename = masterJson.ClipId
}

videoOutputFilename := outputFilename + "-video.mp4"
err = createVideo(client, masterJson, masterJsonUrl, videoOutputFilename)
if err != nil {
fmt.Println("Error:", err.Error())
Expand All @@ -73,15 +78,15 @@ var rootCmd = &cobra.Command{
}

if len(masterJson.Audio) > 0 {
audioOutputFilename := masterJson.ClipId + "-audio.mp4"
audioOutputFilename := outputFilename + "-audio.mp4"
err = createAudio(client, masterJson, masterJsonUrl, audioOutputFilename)
if err != nil {
fmt.Println("Error:", err.Error())
os.Exit(1)
}

if combine {
outputFilename := masterJson.ClipId + ".mp4"
outputFilename := outputFilename + ".mp4"
err = combineVideoAndAudio(videoOutputFilename, audioOutputFilename, outputFilename)
if err != nil {
fmt.Println("Error:", err.Error())
Expand All @@ -99,6 +104,7 @@ func init() {
rootCmd.Flags().StringVarP(&userAgent, "user-agent", "", "", "user-agent for request")
rootCmd.Flags().StringVarP(&videoId, "video-id", "", "", "video id")
rootCmd.Flags().StringVarP(&audioId, "audio-id", "", "", "audio id")
rootCmd.Flags().StringVarP(&outputFilename, "output-file-name", "o", "", "output file name")
rootCmd.Flags().BoolVarP(&combine, "combine", "", false, "combine video and audio into a single mp4 (ffmpeg is required)")
rootCmd.MarkFlagRequired("input")
}
Expand Down

0 comments on commit b573d51

Please sign in to comment.