Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SCRIPT] CD and DVD burning/ripping
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
vandien
Tux's lil' helper
Tux's lil' helper


Joined: 03 May 2006
Posts: 137

PostPosted: Thu May 04, 2006 3:03 pm    Post subject: [SCRIPT] CD and DVD burning/ripping Reply with quote

Here are a few scripts I use regularly. I helped install gentoo on a friends laptop he asked me to send these to him, so I thought some people here might find them useful too. I have them saved in /usr/local/bin so they can be accessed directly by typing their name.

Code:
#!/bin/bash
# burn-cd-dir <directory>
# makes an iso on the fly and burns it to a CD.
# requires: app-cdr/cdrtools

mkisofs -R -l $* | cdrecord dev=/dev/hdc speed=12 padsize=63s -eject -pad -v driveropts=burnfree -


Code:
#!/bin/bash
# burn-cd-iso <iso image>
# burns a pre-made .iso file to CD.
# requires: app-cdr/cdrtools

cdrecord dev=/dev/hdd speed=12 padsize=63s -dao -eject -pad -v driveropts=burnfree $*


Code:
#!/bin/bash
# burn-dvd-dir <directory>
# burns a directory to a DVD.
# requires: app-cdr/dvd+rw-tools

growisofs -use-the-force-luke=dao -dvd-compat -speed=2 -J -R -Z /dev/hdc $*


Code:
#!/bin/bash
# burn-dvd-iso
# burns a pre-made .iso file to a DVD.
# requires: app-cdr/dvd+rw-tools

growisofs -use-the-force-luke=dao -dvd-compat -speed=2 -Z /dev/hdc=$*


Code:
#!/usr/bin/perl
# calc <expression>
# simple command line calculator

print eval("@ARGV") . "\n";


Code:
#!/bin/bash
# check <word>
# spellcheck a word
# requires: app-text/aspell app-dicts/aspell-en (or another dictionary)

echo "$@" | aspell -a | grep -v "^@" # | tac | tail -2 | tac


Code:
#!/bin/bash
# rawread /dev/hdc >output.iso
# creates an .iso from a cd/dvd in your cdrom drive.
# borrowed from http://www.troubleshooters.com/linux/coasterless.htm
# requires: app-cdr/cdrtools

device=$1

blocksize=`isoinfo -d -i $device | grep "^Logical block size is:" | cut -d " " -f 5`
if test "$blocksize" = ""; then
        echo catdevice FATAL ERROR: Blank blocksize >&2
        exit
fi

blockcount=`isoinfo -d -i $device | grep "^Volume size is:" | cut -d " " -f 4`
if test "$blockcount" = ""; then
        echo catdevice FATAL ERROR: Blank blockcount >&2
        exit
fi

command="dd if=$device bs=$blocksize count=$blockcount conv=notrunc,noerror"
echo "$command" >&2
$command


Code:
#!/usr/bin/perl
# mkdir <title of movie> and cd into it.
# ripdvd <source>
# quick, low-ish quality dvd-rip. good for animated movies.
# if you don't specify a source, it will default to dvd://1
# the source can be anything you can play with: mplayer <file>
# requires: media-video/mplayer (with proper USE flags set)

if("@ARGV" eq "") {
  $source = "dvd://1";
} else {
  $source = "@ARGV";
}

$title = `pwd`;
chomp($title);
$title =~ s|.+/||;

system("mencoder $source -o $title.avi -alang en -oac copy -ovc xvid -xvidencopts fixed_quant=4 -vobsubout $title -vobsuboutindex 0 -sid 0");


Code:
#!/usr/bin/perl
# mkdir <title of movie> and cd into it.
# ripdvd2 <source>
# long, 2 pass dvd-rip, better quality.
# it will stop after the first step and ask what bitrate you want.
# add "-ss 350 -endpos 20" to each command to test encoding.
# requires: media-video/mplayer (with proper USE flags set)

if("@ARGV" eq "") {
  $source = "dvd://1";
} else {
  $source = "@ARGV";
}

$title = `pwd`;
chomp($title);
$title =~ s|.+/||;

system("mencoder $source -oac copy -ovc frameno -o frameno.avi");

print "\nwhat bitrate do you want to encode at (1200)? ";
$bitrate = <STDIN>;
chomp($bitrate);
if($bitrate eq "") {
  $bitrate = "1200";
}

system("mencoder $source -oac copy -ovc xvid -xvidencopts pass=1:bitrate=$bitrate -o /dev/null");
system("mencoder $source -oac copy -ovc xvid -xvidencopts pass=2:bitrate=$bitrate -o $title.avi");
Back to top
View user's profile Send private message
Aszrael
Tux's lil' helper
Tux's lil' helper


Joined: 15 Feb 2005
Posts: 101
Location: Hannover/Germany

PostPosted: Mon May 08, 2006 7:12 am    Post subject: Reply with quote

NICE - thanks for posting

Aszrael
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Mon May 08, 2006 9:27 am    Post subject: Reply with quote

Very nice collection!!

at least there are some command line fans out there 8)
_________________
Video Encoding scripts collection | Project page
Back to top
View user's profile Send private message
dkure
n00b
n00b


Joined: 20 Apr 2004
Posts: 51
Location: Sydney, Australia

PostPosted: Mon May 08, 2006 1:02 pm    Post subject: Reply with quote

Just a quick comment on all these scripts, first off they seem great, one improvement that could be made with them is if no arguments are given, print how to use the script. This is always useful incase you have forgotten which script to use.
Back to top
View user's profile Send private message
someguy
Guru
Guru


Joined: 10 Jul 2003
Posts: 433
Location: (-_-) .::OH_WELL::. (-_-)

PostPosted: Tue May 16, 2006 7:20 am    Post subject: Reply with quote

{root@oceania:/mnt/sda1/Movies/rips/animatrix}rip
MEncoder 1.0pre7try2-3.4.5 (C) 2000-2005 MPlayer Team
CPU: Advanced Micro Devices (Family: 8, Stepping: 0)
Detected cache-line size is 64 bytes
CPUflags: Type: 8 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE SSE2

85 audio & 196 video codecs
File not found: 'frameno.avi'
Failed to open frameno.avi
xvidencopts is not an MEncoder option

Exiting... (error parsing cmdline)


i just want to rip and encode :(
_________________
print pack"C*",split/\D+/,`echo "16iII*o\U@{$/=$z;[(pop,pop,unpack"H*",<>
)]}\EsMsKsN0[lN*1lK[d2%Sa2/d0<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<J]dsJxp"|dc`
while [ 1 ] ; do echo "*" | telnet ip.of.print.er 9100 ; done
Back to top
View user's profile Send private message
vandien
Tux's lil' helper
Tux's lil' helper


Joined: 03 May 2006
Posts: 137

PostPosted: Tue May 16, 2006 1:39 pm    Post subject: Reply with quote

someguy wrote:
85 audio & 196 video codecs
File not found: 'frameno.avi'
Failed to open frameno.avi
xvidencopts is not an MEncoder option

Exiting... (error parsing cmdline)

Make sure you compiled mplayer with the xvid use flag? My flags look like this:

Code:
[ebuild   R   ] media-video/mplayer-1.0.20060415  USE="X aac alsa cpudetection dts dv dvd dvdread encode gif ipv6 jpeg mad matroska mmx png sdl sse truetype vorbis win32codecs x264 xv xvid -3dfx -3dnow -3dnowext -aalib -arts -bidi -bindist -bl -cdparanoia -custom-cflags -debug -dga -directfb -doc -dvb -edl -esd -fbcon -ggi -gtk -i8x0 -jack -joystick -libcaca -lirc -live -livecd -lzo -matrox -mmxext -musepack -nas -nvidia -openal -opengl -oss -real -rtc -samba -speex -sse2 -svga -tga -theora -unicode -v4l -v4l2 -xanim -xinerama -xmms -xvmc" 0 kB

Did you make any changes to the script or is it copied exactly?
Back to top
View user's profile Send private message
zurd
Apprentice
Apprentice


Joined: 17 Dec 2003
Posts: 228
Location: Canada, Montreal

PostPosted: Thu May 25, 2006 7:06 am    Post subject: Reply with quote

To rip a DVD, this is what I use, no xvid or xvidencopts option :

1) Make sur the file frameno.avi doesn't exist :
rm frameno.avi

2) Gives us the vbitrate for the quality and an estimate of the filesize, takes only 5-15 minutes to complete :
mencoder -o frameno.avi -ovc frameno -oac mp3lame -lameopts vbr=3 -dvd-device /mnt/dvdrw dvd://1

3) This one takes a few hours though, don't forget to put the vbitrate you choose from number 2 at the 2 places :
mencoder -o movie.avi -ovc lavc -lavcopts vcodec=mpeg4:vpass=1:vbitrate=??? -oac copy -dvd-device /mnt/dvdrw dvd://1 && mencoder -o movie.avi -ovc lavc -lavcopts vcodec=mpeg4:vpass=2:vbitrate=??? -oac copy -dvd-device /mnt/dvdrw dvd://1

Note : Make sure you change /mnt/dvdrw to your location of your DVD


And does anyone have a script to convert mp3 to wav/cdr and burn them on a CD? :wink:
Back to top
View user's profile Send private message
linuxlife
n00b
n00b


Joined: 07 Mar 2006
Posts: 16

PostPosted: Fri Jun 02, 2006 12:17 pm    Post subject: Reply with quote

Code:

#!/bin/bash
# burn-cd-dir <directory>
# makes an iso on the fly and burns it to a CD.
# requires: app-cdr/cdrtools

mkisofs -R -l $* | cdrecord dev=/dev/hdc speed=12 padsize=63s -eject -pad -v driveropts=burnfree -



Is there also a way to just write it down to a .iso file without burning to a CD directly? I dont have a cd-burner in my server (remote)..
Back to top
View user's profile Send private message
zurd
Apprentice
Apprentice


Joined: 17 Dec 2003
Posts: 228
Location: Canada, Montreal

PostPosted: Fri Jun 02, 2006 2:55 pm    Post subject: Reply with quote

linuxlife : of course, in fact, mkisofs creates the iso file then cdrecord burn it, so if you just call mkisofs it'll create the iso file for you.

Personally, I use :
mkisofs -JRv -o image.iso /some/directory

J is for using Joliet filename (windows)
R is for using Rockridge filename (linux)
v is for verbose

If it's for a DVD, there's always the -dvd-video for mkisofs. You could always check the mkisofs --help, tough it is quite big :\
Back to top
View user's profile Send private message
linuxlife
n00b
n00b


Joined: 07 Mar 2006
Posts: 16

PostPosted: Fri Jun 02, 2006 3:44 pm    Post subject: Reply with quote

Thanks for this. I am using now this:

Code:

mkisofs -J -R -v -o /dev/sdb1/image.iso /


but then it tells me that it cant write the iso to disk. If i mount the /dev/sdb1 as /backup im sure it will try to backup the /dev/sdb1 disk too and get in a looping, so i wont try that. But i need to mount it before i can write the backup to it.

Code:

mount /dev/sdb1 /backup
mkisofs -J -R -v -o /backup/image.iso /dev/sda


Does also not work. How do i handle this?
Back to top
View user's profile Send private message
zurd
Apprentice
Apprentice


Joined: 17 Dec 2003
Posts: 228
Location: Canada, Montreal

PostPosted: Sat Jun 03, 2006 4:44 am    Post subject: Reply with quote

But what do you want to accomplish exactly ?
Back to top
View user's profile Send private message
linuxlife
n00b
n00b


Joined: 07 Mar 2006
Posts: 16

PostPosted: Sat Jun 03, 2006 8:19 am    Post subject: Reply with quote

zurd wrote:
But what do you want to accomplish exactly ?


my sda disc does have 4 partitions, /boot /var /home /
my sdb disc has 1 partition /
i mount the sdb1 partition normally as /backup

i want to make a full backup of my sda disc and write it down to my sdb disc to the sdb1 partition so i can download it to my workstation and burn it on a cd-rom.
Back to top
View user's profile Send private message
Arundel
n00b
n00b


Joined: 03 Jun 2006
Posts: 1

PostPosted: Sat Jun 03, 2006 1:40 pm    Post subject: Reply with quote

Very nice! Thanks for sharing
Back to top
View user's profile Send private message
zurd
Apprentice
Apprentice


Joined: 17 Dec 2003
Posts: 228
Location: Canada, Montreal

PostPosted: Tue Jun 06, 2006 8:46 am    Post subject: Reply with quote

linuxlife : Sorry for the delay, it's weird I didn't receive an e-mail from forums.gentoo.org that someone replied :\

Anyway, I see what you're trying to accomplish now, I think you should give this a try :

Code:
mkisofs -J -R -v -o /mnt/sdb1/image.iso -x /mnt -x /tmp -x /dev -x /proc /


so -x is to exclude some path, like here I excluded /mnt, /tmp, /dev and /proc, feel free to modify them as you wish. The last / is to tell mkisofs to make an image of your root filesystem. And be sure to not use -o /dev/something, that won't work, mount your backup hard disk to /mnt and use the -x /mnt to not include it. That should do the trick!
Back to top
View user's profile Send private message
linuxlife
n00b
n00b


Joined: 07 Mar 2006
Posts: 16

PostPosted: Tue Jun 06, 2006 4:54 pm    Post subject: Reply with quote

Thanks zurd! I solved directly the other problem. Do nog include the /sys/ folder (/sys/ error):
"You really don't want to include /sys, or /proc, in an iso image (or in a tarball, for that matter)"

Finally a complete working set of commands to make a complete disk copy in .iso format:

Code:

mkdir /mnt/backup
mount /dev/sdb1 /mnt/backup
mkisofs -J -R -v -o /mnt/backup/image.iso -x /mnt -x /tmp -x /dev -x /sys -x /proc -x /usr/portage -x /var/tmp/portage /
mkisofs -J -R -v -o /mnt/backup/portage_files.iso /usr/portage /var/tmp/portage


Code:
Output:
-rw-r--r--  1 root root 861M Jun  6 06:42 image.iso
-rw-r--r--  1 root root 542M Jun  6 06:47 portage_files.iso


My only question left is: why do not include the /dev/ folder to the iso? When i do not add them i can put back the image on all sort of computers/servers, or is this list created every time on boot?
Back to top
View user's profile Send private message
zurd
Apprentice
Apprentice


Joined: 17 Dec 2003
Posts: 228
Location: Canada, Montreal

PostPosted: Tue Jun 06, 2006 7:17 pm    Post subject: Reply with quote

I'm not sure about the /dev folder, I think, tough, that with either devfs or udev, it is creating the list when you boot.

Anyway, why should we re-invent the wheel? Check out this page on how to make a backup of your system, they created a nice working script for that :
http://blinkeye.ch/mediawiki/index.php/GNU/Linux_System_Backup_Script_%28stage4%29

It came from that thread :
https://forums.gentoo.org/viewtopic-p-2223380.html#2223380
Back to top
View user's profile Send private message
linuxlife
n00b
n00b


Joined: 07 Mar 2006
Posts: 16

PostPosted: Tue Jun 06, 2006 8:53 pm    Post subject: Reply with quote

Ah fine. Will fully read and try that tomorrow!
Back to top
View user's profile Send private message
synss
Apprentice
Apprentice


Joined: 08 Mar 2006
Posts: 282
Location: Dijon > Berlin > Tokyo > Nürnberg > München

PostPosted: Wed Jun 21, 2006 8:54 pm    Post subject: Reply with quote

dkure wrote:
Just a quick comment on all these scripts, first off they seem great, one improvement that could be made with them is if no arguments are given, print how to use the script. This is always useful incase you have forgotten which script to use.


He is right on both points, for those who do not know how to do the usage trick, follow this example:
Code:
#!/bin/bash

if [ -z ${1} ]; then cat << EOF
burn-cd-iso <iso image>
burns a pre-made .iso file to CD.
requires: app-cdr/cdrtools
EOF
exit
fi

/usr/bin/cdrecord dev=/dev/hdd speed=12 padsize=63s -dao -eject -pad -v driveropts=burnfree $*


Simple.

zurd wrote:
I'm not sure about the /dev folder, I think, tough, that with either devfs or udev, it is creating the list when you boot.

If you use udev, /dev is mounted in RAM anyway (in tmpfs, I believe) so not saved after shutdown and is "dynamically" created when you boot and updated when you plug/unplug hardware. Do not make back ups of that guy.
_________________
Compress portage tree
Elog viewer
Autodetect swap
Back to top
View user's profile Send private message
linuxlife
n00b
n00b


Joined: 07 Mar 2006
Posts: 16

PostPosted: Tue Sep 05, 2006 4:18 pm    Post subject: Reply with quote

Hey,

is it possible that after i did a format of both harddisks and i raw copy back the whole .iso burned cd to the harddisks that it wont run?
Back to top
View user's profile Send private message
zurd
Apprentice
Apprentice


Joined: 17 Dec 2003
Posts: 228
Location: Canada, Montreal

PostPosted: Tue Sep 05, 2006 6:08 pm    Post subject: Reply with quote

linuxlife : if you use dd if=/dev/hda of=/dev/hdb1/hda-backup.iso
and trying to use that iso to recreate hda it won't work out of the box.

You'll need to do a few other things like calling LILO or Grub and other things that I'm not all fully aware of.

To make a backup of your HD, you should use that link :
http://blinkeye.ch/mediawiki/index.php/GNU/Linux_System_Backup_Script_%28stage4%29
Back to top
View user's profile Send private message
linuxlife
n00b
n00b


Joined: 07 Mar 2006
Posts: 16

PostPosted: Wed Sep 06, 2006 9:19 am    Post subject: Reply with quote

hehe ok, i should have done that some earlier ;)
Back to top
View user's profile Send private message
synss
Apprentice
Apprentice


Joined: 08 Mar 2006
Posts: 282
Location: Dijon > Berlin > Tokyo > Nürnberg > München

PostPosted: Sun Oct 08, 2006 1:47 pm    Post subject: On the fly audio-cd ripping Reply with quote

[EDIT: and I just found vlorb, emerge vlorb]

on the fly ripping at the console, for cd audio (can be improved but it does the job)

rip-audio-cd:
#!/bin/bash
#rip-cd-audio DIR
#
#rip-cd-audio on the fly
#
#requires ogg-vorbis, cdparanoia, cdplay

NBTRACK="$(cdplay -i | tail -1 | cut -d" " -f1)"
NLOOP=0

DIR="${1}"

[[ -z "${DIR}" ]] && DIR='ripped-audio-cd'
[[ -e "${DIR}" ]] && echo "${DIR} exists... exiting" && exit

mkdir "${DIR}"
cd "${DIR}"

while [[ $NLOOP -ne $NBTRACK ]]
do
   NLOOP=`expr $NLOOP + 1`
   cdparanoia -r $NLOOP - | oggenc -r -q6 -o track${NLOOP}.ogg -
done

_________________
Compress portage tree
Elog viewer
Autodetect swap


Last edited by synss on Sun Oct 08, 2006 7:15 pm; edited 1 time in total
Back to top
View user's profile Send private message
mudrii
l33t
l33t


Joined: 26 Jun 2003
Posts: 789
Location: Singapore

PostPosted: Sun Oct 08, 2006 5:56 pm    Post subject: Reply with quote

nice scripts

Thx for post
_________________
www.gentoo.ro
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum