horizon-youtube-mp3
Get info and download (server or local) MP3 audio from youtube videos in node.js using horizon-youtube-mp3.
Main Online App
Project developed using this module: YouTube Transfer App Site
Prerequisites
ffmpeg and ffprobe
fluent-ffmpeg requires ffmpeg >= 0.9 to work. It may work with previous versions but several features won't be available (and the library is not tested with lower versions anylonger).
If the FFMPEG_PATH
environment variable is set, fluent-ffmpeg will use it as the full path to the ffmpeg
executable. Otherwise, it will attempt to call ffmpeg
directly (so it should be in your PATH
). You must also have ffprobe installed (it comes with ffmpeg in most distributions). Similarly, fluent-ffmpeg will use the FFPROBE_PATH
environment variable if it is set, otherwise it will attempt to call it in the PATH
.
Most features should work when using avconv and avprobe instead of ffmpeg and ffprobe, but they are not officially supported at the moment.
Windows users: most probably ffmpeg and ffprobe will not be in your %PATH
, so you must set %FFMPEG_PATH
and %FFPROBE_PATH
.
Debian/Ubuntu users: the official repositories have the ffmpeg/ffprobe executable in the libav-tools
package, and they are actually rebranded avconv/avprobe executables (avconv is a fork of ffmpeg). They should be mostly compatible, but should you encounter any issue, you may want to use the real ffmpeg instead. You can either compile it from source or find a pre-built .deb package at https://ffmpeg.org/download.html (For Ubuntu, the ppa:jon-severinsson/ffmpeg
PPA provides recent builds).
Main features
- Convert video from youtube in mp3 files (128 kBit/s) in realtime;
- Pipe stream of converted bytes;
- Save file in local folder (New);
- Crop time (start and end time).
With npm do:
npm install horizon-youtube-mp3
API
Get info parameters:
horizon Get information from video
Example:
// Get video informationhorizon;
Download parameters (server):
//Convert and send bytes to stream (download mp3 on client side)horizon;
Example:
horizon;
Download to Local parameters (local):
//Convert video and save the final file in local path.horizon;
Params Info:
videoURL = Url Youtube video;res = API Response (to server only);directory = Directory to save file (to local only);optionalName = A default name for the audio file;cropParams = Crop params;maxTimeAllowed = Total time from video allowed (seconds);showSize = Show size of file during download (to server only);callback = Call on dowload file is complete;onProgress = Show progress of conversion (to local only);
Type of errors callback:
log...NO_DESTINATION; When res and directory parameters is not definedLONG_VIDEO_TIME; Video time is longer than allowedERROR_ON_GET_INFO; Error on get infoVIDEO_DOES_NOT_EXIST; Video does not existERROR_PROCESSING_VIDEO: Internal Server Error on Processing VideoURL_VIDEO_NOT_DEFINED; Url Video Not DefinedMISSING_CROP_PARAMS; Missing params on CropParams
Type of success callback
log...CONVERSION_FILE_COMPLETE; Conversion File
Usage Examples
Get info from video.
var horizon = ;horizon;
Use for server-side processing and client-side downloading
var horizon = ;var http = ;var url = ;var log = level: 'info' ;var server = http;server;log;log;
Use for local processing (New)
var horizon = ;var path = ; var downloadPath = path; horizon; { console; // Will return... //null, conversionFileComplete} { console; // Will return... // Progress: 90.45518257038955 Timemark: 00:02:20.04 Target Size: 2189 // Progress: 93.73001672942894 Timemark: 00:02:25.11 Target Size: 2268 // Progress: 100.0083970106642 Timemark: 00:02:34.83 Target Size: 2420}
Run examples
Get video information:
npm run info
Convert and save file to local folder:
npm run app
Convert and server bytes stream to client side:
npm run server
License
MIT