sidux.com
Menu

News

Give back
Last 3 Contributions
30-11-2008 20.00
25-11-2008 100.00
25-11-2008 20.00

Donate


Sponsor
hetzner.de

Languages
Preferred language:



Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
zulu9
Post subject: script: download from youtube and encode to ogg or mp3  PostPosted: Sep 29, 2007 - 12:35 AM



Joined: Nov 30, 2006
Posts: 777
Location: Germany
Status: Offline
the scripts can now be found here:
http://sidux.com/index.php?module=pnWik ... tag=zulu91

see last post for debian-packages of youtube2mp3


Comments (negative ones too) / additions welcome.

_________________
http://sidux.wordpress.com/ inoffizielles sidux-Blog


Last edited by zulu9 on Nov 06, 2008 - 10:39 PM; edited 2 times in total
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
damentz
Post subject: RE: my first script: download from youtube and encode to ogg  PostPosted: Sep 29, 2007 - 02:00 AM



Joined: Dec 01, 2006
Posts: 751

Status: Offline
wow, thats pretty neat, i'll try it when i actually need to archive something like this

_________________
"Cool was never cool until the cool guys at Cool industries developed a cool new product: Cool."
 
 View user's profile Send private message  
Reply with quote Back to top
zulu9
Post subject: RE: my first script: download from youtube and encode to ogg  PostPosted: Sep 29, 2007 - 02:14 AM



Joined: Nov 30, 2006
Posts: 777
Location: Germany
Status: Offline
I am still experimenting with some options of ffmpeg2theora to improve quality and avoid unsynched video/audio. Also currently it is not possible to run multiple instance of the script in the same parent dir because the two instances would use the same workdir which will bork both jobs.

_________________
http://sidux.wordpress.com/ inoffizielles sidux-Blog
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
op4latino
Post subject: RE: my first script: download from youtube and encode to ogg  PostPosted: Sep 29, 2007 - 03:54 AM



Joined: Dec 02, 2006
Posts: 1046
Location: East Coast
Status: Offline
nice forum section
 
 View user's profile Send private message  
Reply with quote Back to top
RoEn
Post subject: RE: my first script: download from youtube and encode to ogg  PostPosted: Sep 29, 2007 - 06:41 AM



Joined: Nov 26, 2006
Posts: 357

Status: Offline
http://sidux.com/index.php?module=pnWik ... g=zulu91EN

_________________
So long
RoEn

"Lesen gefährdet die Dummheit"
"Was unserer Welt fehlt, ist nicht Öl, sondern mehr Toleranz"
 
 View user's profile Send private message  
Reply with quote Back to top
zulu9
Post subject: RE: my first script: download from youtube and encode to ogg  PostPosted: Aug 21, 2008 - 07:35 PM



Joined: Nov 30, 2006
Posts: 777
Location: Germany
Status: Offline
new script: gets only audio and encodes it to mp3:

youtube2mp3
Code:

#!/bin/bash
#make working dir
TMP="$(mktemp -d -p /tmp/ youtube2mp3.XXXXXX || exit 1)"
cd $TMP
#download video(s)
for URL in $*; do
        youtube-dl -t $URL
done
#convert
for VIDEO in *.flv; do
        OUTPUT=$VIDEO".mp3"
        ffmpeg -i $VIDEO -ab 128k -ar 44100 $OUTPUT
done
#move video to Desktop
mv *.mp3 ~/Desktop
#clean-up
rm -rf $TMP

_________________
http://sidux.wordpress.com/ inoffizielles sidux-Blog


Last edited by zulu9 on Oct 20, 2008 - 11:14 PM; edited 1 time in total
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
op4latino
Post subject: RE: my first script: download from youtube and encode to ogg  PostPosted: Aug 23, 2008 - 02:16 AM



Joined: Dec 02, 2006
Posts: 1046
Location: East Coast
Status: Offline
I don't know if it actually makes any difference, but what about change
Code:
youtube-dl -t $1
to
Code:
youtube-dl -t "$1&fmt=18"

source http://www.youtube.com/watch?v=aVlx2xFMZFs
 
 View user's profile Send private message  
Reply with quote Back to top
zulu9
Post subject: Re: RE: my first script: download from youtube and encode to  PostPosted: Aug 26, 2008 - 11:17 PM



Joined: Nov 30, 2006
Posts: 777
Location: Germany
Status: Offline
op4latino wrote:
I don't know if it actually makes any difference, but what about change
Code:
youtube-dl -t $1
to
Code:
youtube-dl -t "$1&fmt=18"

source http://www.youtube.com/watch?v=aVlx2xFMZFs


So this is supposed to get the high quality version? Nice. I am not sure it works for all videos tho. It should work too if you just put it in the URL you pass to the script.

_________________
http://sidux.wordpress.com/ inoffizielles sidux-Blog
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
edhunter
Post subject: RE: Re: RE: my first script: download from youtube and encod  PostPosted: Oct 20, 2008 - 11:03 PM



Joined: Jul 03, 2008
Posts: 18

Status: Offline
zulu9 thx a bunch for the 2 scripts Smile

one quick comment. the second script needs a k after 128 to set the bitrate to 128 bit/s

Code:

ffmpeg -i $VIDEO -ab 128k -ar 44100 $OUTPUT

_________________
New unofficial greek sidux forum
 
 View user's profile Send private message  
Reply with quote Back to top
zulu9
Post subject: RE: Re: RE: my first script: download from youtube and encod  PostPosted: Oct 20, 2008 - 11:15 PM



Joined: Nov 30, 2006
Posts: 777
Location: Germany
Status: Offline
thx.
according to the manpage of ffmpeg you are right. I edited the post with the script and wiki.

_________________
http://sidux.wordpress.com/ inoffizielles sidux-Blog
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Swynndla
Post subject:   PostPosted: Nov 06, 2008 - 02:26 AM



Joined: Aug 09, 2007
Posts: 41
Location: Auckland, New Zealand
Status: Offline
zulu9 I like your scripts and they work well. Well done.

As a matter of personal taste, I would change some of the format of the script, and also use a friendly looking sed. The following is just my opinions/suggestions, so ignore anything you want:
Code:
#!/bin/bash

basename=$(basename $0)  # ie this is the name of the script that's being called

TMP="$(mktemp -d -p /tmp/ $basename.XXXXXX || exit 1)"
cd $TMP
#I like to print out what the script is doing:
echo
echo "======= Working directory is $TMP ======="
echo

#download video(s)
# using "$@" (list of arguments) instead of $* (line of arguments) is a good habit to get into,
# as some arguments don't get passed properly using $*, eg if the arguments have spaces
# (although that doesn't apply for this script). "$@" is the 'proper' way of doing it.
for URL in "$@"; do
        echo
        echo "======= Downloading $URL======="
        echo
        # note that I always use double quotes so that spaces and special chars are passed correctly
        # (again it probably doesn't matter with this script)
        youtube-dl -t "$URL"
done

#convert
for VIDEO in *.flv; do
        # change the CRAP.flv to .mp3 for the OUTPUT file (and I use double quotes again):
        OUTPUT=`echo "$VIDEO" | sed 's/-\w\+\.flv/.mp3/'`
        echo
        echo "======= Creating $OUTPUT ======="
        echo
        # (and I use double quotes again):
        ffmpeg -i "$VIDEO" -ab 128k -ar 44100 "$OUTPUT"
done

echo
echo "======= Moving to Desktop ======="
echo
mv *.mp3 ~/Desktop

echo
echo "======= Cleaning up ======="
echo
rm -rf $TMP

echo
echo "Done."
echo
 
 View user's profile Send private message  
Reply with quote Back to top
ModestUser
Post subject:   PostPosted: Nov 06, 2008 - 03:56 AM



Joined: Jan 07, 2008
Posts: 298

Status: Offline
If you want to change FILE.flv to FILE.mp3, bash parameter expansion can do some magic:
Code:

VIDEO="example.flv"
OUTPUT="${VIDEO/%flv/mp3}"
 
 View user's profile Send private message  
Reply with quote Back to top
Swynndla
Post subject:   PostPosted: Nov 06, 2008 - 05:38 AM



Joined: Aug 09, 2007
Posts: 41
Location: Auckland, New Zealand
Status: Offline
ModestUser wrote:
If you want to change FILE.flv to FILE.mp3, bash parameter expansion can do some magic:
Code:

VIDEO="example.flv"
OUTPUT="${VIDEO/%flv/mp3}"

Nice.

BTW - the sed way changes "thisvideoblah-JFlA3pVTHEkM.flv" to "thisvideoblah.mp3". How would this be done with parameter expansion if we don't know the "CRAP" to remove?
 
 View user's profile Send private message  
Reply with quote Back to top
ModestUser
Post subject:   PostPosted: Nov 06, 2008 - 02:21 PM



Joined: Jan 07, 2008
Posts: 298

Status: Offline
Code:

OUTPUT="${VIDEO%-*flv}.mp3"


See "man bash".
 
 View user's profile Send private message  
Reply with quote Back to top
zulu9
Post subject:   PostPosted: Nov 06, 2008 - 05:46 PM



Joined: Nov 30, 2006
Posts: 777
Location: Germany
Status: Offline
thanks guys!
I like to see this small thing improving by the community.
I made some .debs for it tho you can really just put it anywhere.
Please check if I missed some contributor in the copyright-file Wink

the new version is yet untestet. I applied the changes from Swynndla and ModestUser.

_________________
http://sidux.wordpress.com/ inoffizielles sidux-Blog
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
 
Logos and trademarks are the property of their respective owners, comments are property of their posters, the rest is © 2006-2008 by sidux e.V., 10407 Berlin, Kniprodestr. 104. sidux e.V. is a Berlin, Germany based non-profit foundation. Consult Impressum and Legal Terms for details. sidux™ is Free Software released under the GNU/GPL license and other compatible licenses.
powered by Zikula & Zafenio