Results 1 to 3 of 3

Thread: Bash Script Options?

  1. #1
    Join Date
    Apr 2008
    Location
    Ohio
    Beans
    202

    Bash Script Options?

    I'm making a simple YouTube video to MP3 script (in bash) and is there any way that if I enter
    [quote]yt2mp3 --keep-vid[/code]
    It will also keep the downloaded YouTube video?

    Current script:
    Code:
    #!/bin/bash
    echo "Enter the URL of the YouTube video to start downloading."
    read VIDEO
    echo "Downloading..."
    rm -rf "tmp.flv"
    youtube-dl $VIDEO -o "tmp.flv"
    clear
    echo What is the artist of the song?
    read ARTIST
    echo
    echo What is the name of the song?
    read NAME
    echo
    ffmpeg -i "tmp.flv" "${ARTIST} - ${NAME}.mp3"
    rm -rf "tmp.flv"
    echo
    echo "YouTube video converted! Yay!"

  2. #2
    Join Date
    Feb 2005
    Location
    Geneva, Switzerland
    Beans
    976

    Re: Bash Script Options?

    Code:
    #!/bin/bash
    echo "Enter the URL of the YouTube video to start downloading."
    read VIDEO
    echo "Downloading..."
    rm -rf "tmp.flv"
    youtube-dl $VIDEO -o "tmp.flv"
    clear
    echo What is the artist of the song?
    read ARTIST
    echo
    echo What is the name of the song?
    read NAME
    echo
    ffmpeg -i "tmp.flv" "${ARTIST} - ${NAME}.mp3"
    if [ "$1" != "--keep-vid" ] ; then
        rm -rf "tmp.flv"
    fi
    echo
    echo "YouTube video converted! Yay!"

  3. #3
    Join Date
    Sep 2006
    Beans
    3,713

    Re: Bash Script Options?

    I recommend changing:
    Code:
    ffmpeg -i "tmp.flv" "${ARTIST} - ${NAME}.mp3"
    to
    Code:
    ffmpeg -i "tmp.flv" -acodec copy "${ARTIST} - ${NAME}.mp3"
    Now ffmpeg will copy the mp3 audio stream instead of re-encoding it. This will be faster and will preserve the quality.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •