A Coub downloader (CLI).
As local package:
$ npm i coub-dl
As CLI:
$ npm i -g coub-dl
- FFmpeg (see FFmpeg instalation)
List options and examples
$ coub-dl --help
Available options:
-V, --version output the version number
-i, --input <input> input (coub link or id)
-o, --output <output> output file location
-c, --crop [crop] crop the output (width:height:x_offset:y_offset)
-s, --scale <size> resize the output (widthxheight)
-A, --no-audio prevent addition of audio to the output
-l, --loop <times> loop the coub X times
-t, --time <amount> set the maximal amount of seconds for the length of the output
-d, --details use in order to view the logs from ffmpeg while it works
-C, --copy-codec copy the codecs from the input. Improves speed but might cause issues with sound in some players
-h, --help output usage information
NOTE: About the -C
option. Originally codecs were copied by default as it improved the speed of the process, but it was reported
that some players fail to detect the sound of the output file when doing so, as such, the codec copying is now an option.
-
If you DO use the
-C
option: some players will have issues with the sound of the output BUT the process will be faster! Use this if you don't really care about sound, or your player (or whatever else uses your output) supports the codecs for sound. -
If you DON'T use the
-C
option: all players will be able to play your file just fine, but the process will take longer as ffmpeg will have to decode and reencode your file.
The --copy-codec
option will only work if you don't use any other video filters such as crop
and scale
.
If you do, adding this option will have no effect. (FFmpeg will still have to decode and encode the video)
Examples:
# Download coub without audio
$ coub-dl --input https://coub.com/view/135nqc --output out.mp4 --no-audio -C
# Download coub as gif, crop it as a square and scale it down to 250x250
$ coub-dl -i https://coub.com/view/135nqc -o out.gif --crop --scale 250
# Download coub and loop it 3 times
$ coub-dl -i https://coub.com/view/135nqc -o out.mp4 --loop 3 -C
# Download coub and make sure it's no longer than 12 seconds
$ coub-dl -i https://coub.com/view/135nqc -o out.mp4 --loop 10 --time 12 -C
Extends FFmkek.
const Coub = require('coub-dl')
Takes a coub URL (or just ID), fetches it and returns a Coub instance.
Optionally takes a quality argument. Can only be high
or med
.
const coub = await Coub.fetch('http://coub.com/view/w6uc9')
// => Promise<Coub>
Takes an argument similar to the FFmpeg crop filter except it is optional. If no data is provided the output is cropped as a centered square.
coub.crop() // Crops centered square
coub.crop('500:200:0:0') // Crop 500x200 with no offset from top right
// => Coub
Scale the output video.
coub.scale(250) // Scale the video to 250 pixel width while preserving aspect ratio
coub.scale('-2:100') // Scale the video to 100 pixel height while preserving aspect ratio
coub.scale('250:100') // Scale the video to 250x100
// => Coub
Attaches the Coub audio to the output. NOTE: Do this before applying any other filters. Unless you want to apply the filters to the audio.
coub.attachAudio()
// => Coub
Loop the video a given amount of times. If the video ends up longer than the audio, it is shortened to the length of the audio.
coub.loop(3)
// => Coub
The write()
method is inherited from FFmkek.
coub.write('my/coub/dir/thing.mp4')
// => Promise<string>
coub.write()
// => Promise<Stream>