Mithronn / rusty_ytdl

A Rust library for Youtube video searcher and downloader
https://docs.rs/rusty_ytdl
MIT License
107 stars 20 forks source link

add optional ffmpeg options #26

Open Sysix opened 5 months ago

Sysix commented 5 months ago

Hello,

I'm using download_with_ffmpeg and would like to attach some parameters to the program.

I thought something like this:

let mut ffmpeg_options = String::new();

if artist.is_some() && song.is_some() {
    ffmpeg_options = format!("{} -metadata artist=\"{}\" -metadata title=\"{}\"", ffmpeg_options, artist.unwrap(), song.unwrap());
}

let ffmeg_args = Some(FFmpegArgs {
    format: None,
    audio_filter: None,
    video_filter: None,
    output_args: ffmpeg_options, // metadata, mapping, etc
    input_args: None // for cover image input
});

I don't know much about ffmpeg to be honest. I just learn to program rust and try to copy my old program to rust.
here is my typescript code which should explain a bit more :)

const worker = ffmpeg(stream)
    .audioBitrate(320)
    .audioQuality(0)
    .audioChannels(2);

if (artist) {
    worker.outputOptions(
        '-metadata', `title=${title}`,
        '-metadata', `artist=${artist}`
    )
}
if (source.coverImage) {
    try {
        imagePath = path.resolve(folder, `${mp3Title}-cover`);
        await downloadImage(source.coverImage, imagePath);
        worker
            .addInput(imagePath)
            .addOption('-map', '0:a')
            .addOption('-map', '1')
            .addOption('-disposition:v', 'attached_pic')
    } catch {
        // image thumbnail is optional
    }
}
Creative-Difficulty commented 1 month ago

@Mithronn updates on this?