1. Trang chủ
  2. » Công Nghệ Thông Tin

Apress - Smart Home Automation with Linux (2010)- P23 ppt

5 272 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 248,9 KB

Nội dung

CHAPTER 3 ■ MEDIA SYSTEMS 88 Once you can use VLC to play DVDs, you know the library is successfully installed and is consequently available to all the main media player applications, such as mplayer, totem, xine, and so on. When ripping DVDs, you have to consider the amount of hard disk space you want to devote to your collection, whether you want (or need) the DVD menus, and on what devices they are being played. Ultimately, there are two choices. Rip As ISO This makes a raw copy of the entire disc and stores it as a file. This is the easiest process to initiate, because you simply invoke the following: dd if=/dev/dvd of=TheOffice-series1.iso bs=1024 This will generally require between 4GB and 8GB of space and includes all the DVD menus, titles, chapters, and subtitles. Movie players like VLC will be able to handle interactive components such as menus, but others won’t. This is especially true of units that don’t support the DVD logo since they won’t have the CSS code and of smaller low-power devices such as MediaMVP. In the case of the latter, you can partially solve the problem by using VLC to remotely transcode the movies, but it still won’t be able to handle the processing of the DVD menus. As will all disk images, Linux is able to mount them to a directory so they can be read and so their files can be queried normally. This can be done with the following or automatically through the desktop: mount -t udf –o loop TheOffice-series1.iso dvdimage Note that you cannot mount the image to your usual DVD location (such as /dev/dvd) since that is a block device, and you can only mount images to a directory. Rip As Movie Files This method occupies the bulk of “DVD ripping” software, with many available versions for both the command line and the GUI. Although the GUI versions provide screenshots of the titles and chapters and an array of configurable options, they are (almost without exception) merely front ends to a set of standard back-end tools, such as mencoder. You can remove the resources and time utilized by this middle man by going straight to the metal. UnDVD (http://sourceforge.net/projects/undvd/) is a Perl script that provides a simple command-line method to rip DVDs into their component titles, taking whichever language or subtitles you want at the same time. A typical invocation to rip the first three tracks, with English audio, might be as follows: undvd -t 1,2,3 -a en The number of tracks available can be determined with the associated tool, scandvd. Since most households will speak a common language, the necessity for the full ISO is reduced, making this a consistent process. The following script provides a full rip of the disc into its own subdirectory. It could even be triggered from a link on the household web page, for example. #!/usr/bin/perl my $language = "en"; my $subtitles = "off"; CHAPTER 3 ■ MEDIA SYSTEMS 89 my $output = `lsdvd`; $output =~ /Disc Title\:\s+(.*?)\n/s; my $title = lc $1; $title =~ s/\b(\w)/\U$1/g; $title =~ s/_(\w)/ \U$1/g; my $cmd = "undvd -t 1"; my $count = $output=~s/\nTitle\://g; foreach(2 $count) { $cmd .= ",$_"; } mkdir($title); chdir($title); $cmd .= " -a $language -s $subtitles -e 2"; system($cmd); chdir(" "); Issues with Movies With so many codecs and players available, it’s inevitable that you will occasionally find one that has a problem, such as being unable to play the movie, crashing partway through, losing synchronization between video and audio, unable to fast-forward, and so on. Even the commercial offerings have these problems, so they’re not unique to the open source community. In fact, since we work primarily with software-based solutions, we have a better deal, since the problems can be fixed fairly quickly. Here are some tips: • Sometimes you can solve sync problems by pausing and unpausing the video. • Movies that won’t fast-forward often don’t have an chunk index, which can be built when starting the movie with mplayer -idx. • Other problems will usually need to be reencoded (or transcoded). This can be handled from the larger tools, such as VLC. CHAPTER 3 ■ MEDIA SYSTEMS 90 Cassette Tapes and Vinyl Yes, really! There are many people with these beloved relics of technology who want to keep them alive electronically. These are the slowest form of media to rip since they must be done in real time. 4 The obvious way to do this is to connect the phono outputs from your deck (be it tape or record) into the line-in inputs of your sound card. You should have as few components in the signal chain as possible, so if your turntable has a preamplifier, so much the better. Otherwise, consider the relative merits of your sound card and deck, and let the higher-quality unit perform the preamp stage. Vinyl particularly requires a preamp stage with RIAA equalization to avoid the sound sounding tinny. Once you have the deck connected, find the loudest section of music, and monitor the levels in an audio-recording program, such as Audacity. It should be as loud as possible, without clipping. This ensures you get the most out of the 16-bit resolution, ensuring the maximum possible dynamic range. This volume, however, should come from the preamp if possible, since a power amplifier will introduce noise. To ensure maximum quality during recording, you need to take care of external hardware elements, too. So, don’t use the microwave while recording because this can introduce electrical noise that might affect the recordings, don’t fiddle with the connectors, and so on. It is also a good idea to plug the deck into a high-quality UPS or power smoother to limit the amount of wow and flutter caused by fluctuations in mains voltage. The same approach also works for cassettes, although most tape players have a built-in preamp, so you have no choice here. There are currently some all-in-one units on the market that combine a tape or record deck with all the necessary amplifiers and converters necessary to provide you with a digital input over a USB cable. These are ideal for casual users, but since they are made to a price point, and not for quality, you won’t get as good results as you will from a manual setup. Once you have the recording digitized, it is then a matter of extracting the individual tracks from the file called side_1.wav and encoding them accordingly. There are some tools to do this automatically. Audacity has its own Silence Finder function (in the Analyze menu), which looks for suitably long gaps in the recording and places markers by them. You can then adjust these markers if necessary and select Export Multiple to save the data between these markers as individual files. You can then encode them as appropriate. Here’s an example: #!/bin/bash LIST="$(ls *.wav)" for FILE in "$LIST"; do flac $FILE done or with the following: oggenc $FILE 4 It is technically possible to play tapes and records at higher speeds (using high-speed dubbing tape players or switching the record deck to 45 rpm) and compensate by pitch shifting in software. But isn’t really worth the effort or loss in quality. CHAPTER 3 ■ MEDIA SYSTEMS 91 According to the music and your personal opinions of high-fidelity audio, you may choose to keep this music in one or more formats. The most direct is to keep only the OGG files, because they are suitable for casual around-the-house listening and some fairly involved critical listening. For more discerning audiophiles, Free Lossless Audio Codec (FLAC) provides the same quality as WAV but in a smaller footprint. Some people will keep the FLAC versions stored away on a separate (offline) hard drive while using the OGG files for everyday use. This allows the high-quality recordings to be reencoded at a later date when better-quality codecs become available, without needing to rerip the data. True audiophiles would never be happy with a computer sound card and should never rip the music in the first place! Storage All data must be stored somewhere. In desktop computing that’s an internal hard drive. In home automation, we want that drive to be accessible everywhere else. This generally means it must be on a network and controlled by a network service like Samba. Stand-Alone NAS Systems Network addressable storage (NAS), to all intents and purposes, is a hard drive that connects to the outside world through a network cable and IP address instead of an IDE, SCSI, or SATA cable. There are two main advantages with this approach. This first is that by being naturally network aware, you can use the files anywhere in the world with little to no additional configuration. This includes your office, your partner’s office, the bedroom, or even a laptop in the garden or on the train, connected wirelessly. The second is that by being separate from the main computer, you can declutter your main work area by hiding the NAS drive in a cupboard or in the loft/attic. This has a security benefit whereby any burglar stealing your computer hasn’t stolen your data also. Naturally, without a computer to control the hard drive, there has to be a driver somewhere in the data chain determining the disc format, capacity, and network connectivity. This can either exist in the NAS unit itself or from the server machine wanting to read the drive. Many different versions are available. Hard Drive Considerations The main selling factor of any NAS is its storage capability. Currently, anything less than 1TB is rare, which is fortunate since many older IDE drives had a limit of 137.4GB because of the 28-bit addressing mode of Logical Block Addressing (LBA). Avoid anything smaller than 137.4GB in case the manufacturer is using old hardware under the hood, even if it supports an external USB drive, since that will invariably be governed by the same limitation. Alongside the argument for disk space is the concept of disk format. This is usually given as FAT, FAT32, NTFS, or ext2 and limits the maximum file size possible (as shown in Table 3-1). The format also governs your likelihood of being able to recover it if you need to mount the drive in another machine. CHAPTER 3 ■ MEDIA SYSTEMS 92 Table 3-1. Filesystem Functionality Filesystem Maximum File Size Maximum Volume Size FAT16 2GB 2GB FAT32 4GB 2TiB or 8TiB* NTFS 16EiB 16EiB ext2/ext3 16GB to 2TiB 2TiB to 32TiB* ZFS 16EiB 16EiB * Variation depends on cluster size when formatted. So clearly, if you’re wanting a NAS to store DVD images, you will need a filesystem that can support 4.7GB files. This usually means FAT-based systems are inadequate or that you will have to remove the DVD menus and reencode the movies into an alternative (and smaller) format. The recover question is slightly more involved. If you ever have to remove the hard disk from its NAS mounting and place it in a standard PC to recover the data, you will need a PC that is able to read whatever filesystem is used by the NAS. NTFS fairs slightly better in the Linux compatibility stakes, but not much. Although it’s possible to read NTFS partitions under Linux, writing back to them is considered dangerous, although there are two open source drivers (Captive NTFS and NTFS-3G) that do support it. Additionally, there is a commercial driver (NTFS for Linux, from Paragon) that solves the same problem. For basic recovery, a read-only disc is fine, although you won’t be able to repair the disk without reformatting it for the most part. The natural solution is to use ext2 for any and all NAS drives, because this has the widest support in the Linux world. Many NAS devices now support this, so it can be worth spending a little more to get one because it ticks all the boxes. If your main desktop machine at home is Windows, then there are even ext2 recovery tools for Windows such as Linux Recovery from DiskInternals. The type of data you’re storing will determine the type of backup plan you need. When this is personal data, such as letters or photographs, then consider a NAS featuring built-in RAID functionality. These often autoconfigure themselves when a second drive is plugged in, so be warned if you insert a used drive thinking you’ll gain extra space! Several types of RAID configuration are available, but the most common in this case is RAID-1, which uses a second drive to make identical copies of anything written to the first. It does this automatically and transparently from the user, so should either drive fail, the other can be used to recover the data. You should always remember, however, that RAID isn’t a backup! It just makes it a bit less likely that you’ll lose data to disk failure. It won’t protect against corruption from controller failures, fire, flood, or theft. . "undvd -t 1"; my $count = $output=~s/ Title://g; foreach(2 $count) { $cmd .= ",$_"; } mkdir($title); chdir($title); $cmd .= " -a $language -s $subtitles -e 2";. most tape players have a built-in preamp, so you have no choice here. There are currently some all-in-one units on the market that combine a tape or record deck with all the necessary amplifiers. allows the high-quality recordings to be reencoded at a later date when better-quality codecs become available, without needing to rerip the data. True audiophiles would never be happy with a computer

Ngày đăng: 03/07/2014, 20:20

w