Module for downloading, processing, and optionally converting YouTube videos. This package uses yt-dlp
for downloading videos and ffmpeg
for processing and converting them.
Run the following command in your project directory to install the package:
npm install ytdlp_video_processor
To use this module, first, import it:
const ytdlp_video_processor = require("ytdlp_video_processor")
Then, call ytdlp_video_processor
with the necessary parameters:
async function downloadAndProcessVideo() {
const youtubeId = "7W6RCTE0ZKM"
const startTime = 0 // Optional: Start time in seconds for trimming the video
const endTime = 120 // Optional: End time in seconds for trimming the video
const format = "ogg" // Optional: Desired output format (default is 'ogg')
try {
const processedFilePath = await ytdlp_video_processor(
youtubeId,
startTime,
endTime,
format,
)
console.log("Processed video saved at:", processedFilePath)
} catch (error) {
console.error("Error:", error)
}
}
downloadAndProcessVideo()
You can find more usage examples in the examples/index.examples.js file in the examples
folder.
- Downloads YouTube videos using
yt-dlp
. - Optionally trims videos using specified start and end times.
- Converts videos to specified formats using
ffmpeg
. - Returns the absolute path of the processed video file.
Contributions are welcome. Please ensure that your contributions adhere to the project coding standards and include appropriate tests.
When contributing:
- Fork the repository.
- Create a new branch for each feature or improvement.
- Submit a pull request with comprehensive description of changes.
This project is licensed under the MIT License - see the LICENSE file for details.