Playing With Youtube Videos in Linux
In this short post I’ll introduce a csh script I wrote recently. I wrote it for a certain purpose and it’s definitely not “general purpose”. I’m posting it here so you/I can use it as a reference.
The script uses these programs:
1. youtube-dl (In ubuntu, you can get it by typing : sudo apt-get install youtube-dl).
2. ffmpeg (Again: sudo apt-get install ffmpeg)
3. avimerge (part of the transcode package: sudo apt-get install transcode)
The script will download videos from youtube, convert them into avi files, and finally merge them into one avi video.
To use the script, you need call it from inside a directory with only one file in it: file name needs to be “links” and it should include the URLs of the videos you want to download from youtube, one URL per line, in the order you want them to appear in the merged video. The output will be a file “all.avi” in the same directory. Of course, you’re free to modify this script to let be more flexible etc…
Here is the script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #!/bin/tcsh
# download movies
set x = 1
foreach line (`cat links`)
youtube-dl -o vid$x.flv "$line"
@ x = $x + 1
end
# convert from flv to avi
foreach file ( *.flv )
ffmpeg -i "$file" -ab 56 -ar 22050 -b 500 -s 320x240 -vcodec copy -acodec copy "$file".avi
end
# merge all avi files into one file
avimerge -i *.avi -o all.avi
# remove intermediate files
/bin/rm vid*.avi vid*.flv
Please ignore the “BASH” title of the script, it’s because GeSHi doesn’t support csh, and as far as I know bash is the closest thing to csh
Hope it helps somebody
No related posts.
2 Comments to Playing With Youtube Videos in Linux
Leave a Reply
About Me
Tags
Categories
- Algorithms
- Bash
- BlackBerry
- Collaboration
- Command Line
- Cool Tricks
- Easter Eggs
- Ebooks
- Firefox
- Hardware
- Humor
- iPhone
- Linux
- Linux Development
- Linux Kernel
- Networks
- Open Knowledge
- Other
- Productivity
- Programming
- Regular Expressions
- Science
- Security
- Shell Scripts
- Short Posts
- Social Networks
- Thoughts
- Tools
- Vim
- Web Development
- Websites
Popular Posts
Calendar
Archives
- September 2010 (2)
- August 2010 (2)
- July 2010 (5)
- June 2010 (1)
- May 2010 (1)
- April 2010 (3)
- March 2010 (1)
- January 2010 (1)
- December 2009 (2)
- September 2009 (13)
- July 2009 (1)
- June 2009 (6)
- May 2009 (4)
- March 2009 (18)
- February 2009 (10)
- January 2009 (10)
- December 2008 (7)
- November 2008 (8)
- October 2008 (1)
- August 2008 (1)
- July 2008 (1)
- June 2008 (1)

I got this when running it (the first error happens a few times before also):
WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s
ffmpeg: missing argument for option ‘-vcodec’
[AmirWatad: Log removed. Please don't post Long Error Logs in comments]
Strange, it works fine for me. Please share the solution with us if you find it.