[Tool recommended]_ios audio batch Conversion

Source: Internet
Author: User

Usually in order to facilitate marketing and to obtain higher downloads, the volume of the product installation package is as small as possible. So the question is, how can we minimize the size of the package? According to the composition of the product, the final can be divided into, code, pictures, video, audio and other parts, today we take the iOS platform as an example from the audio this piece to see how to minimize the volume of the installation package.

We know that each audio file consists of two parts:

[1]. file format (or audio container)

The file format (or audio container) is the format used to describe the file itself. We can encode real audio data in a number of different ways. The iphone supports many file formats, including MPEG-1 (. mp3), MPEG-2 ADTS (. aac), AIFF,CAF, and wave.

[2]. (or audio encoding)

    • AAC:AAC refers to "advanced Audio coding", which can be said to be a continuation of the MP3 format. You might think that this format will compress the original sound and save it on the disk, so it will reduce the quality of the original sound. However, it is often difficult to notice a decrease in quality, and this is largely determined by the bit rate we set. In fact, AAC's compression is much better than MP3, especially if the bit rate is less than 128,000 bits per second.
    • HE-AAC:HE-AAC is a superset of AAC, he means "high efficiency". The HE-AAC is optimized for low bit-rate audio (streaming audio).
    • The AMR:AMR stands for "Adaptive multi-rate", which is another encoding optimization format for speech optimization, which can highlight very low bit-rate audio.
    • ALAC: Also known as "Apple Lossless", it is an encoding that compresses audio without destroying quality. In fact, it will probably compress the original data. Plus the algorithm is carefully designed so we can decompress the data at a faster rate, which is ideal for devices like ipods or iphones.
    • ILBC: This is another optimized speech encoding that is beneficial for IP voice and streaming media formats.
    • IMA4: This is a compression format that will compress 4:1 of the 16-bit audio files. This is an important encoding for iphone devices.
    • Linear PCM: This represents a linear pulse-coded modulation, mainly describing the technology used to convert analog sound data into digital format. In short, it is uncompressed data. Because the data is uncompressed, we can play the audio as quickly as possible, and if space is not a problem, this is the preferred code choice for iphone audio.
    • Μ-law and A-law: These are two alternating encodings that convert analog data to digital format, but have better speech optimizations than linear PCM.
    • MP3: This is one of our most familiar and favorite formats. MP3 is still one of the most popular formats for years, and the iphone supports this format.

So many file formats, and data formats which do we choose? Usually we will choose the CAF because it can contain all the encoding (data format) supported by the iphone, and it is also the preferred file format option in the iphone.

Now we use all the products are MP3, how to facilitate the rapid conversion of all to CAF, Apple is really too human, has been prepared for us three built-in command line tools: Afplay,afconvert and Afinfo, we need to use is afconvert. Of course we can also use itunes to convert but it's too much trouble.

ITunes Operation:

[1]. Go to itunes Preferences

  

[2]. Enter Import settings

  

[3]. Select Editor (AAC) and make bit rate selection on demand

  

[4]. Convert Audio

  

Command line tool Afconvert:

# Test.mp3 converted to TEST.CAF and set bit rate bit 57623 (56kbps) afconvert-d aac-f caff-b 57623/user/xxx/test.mp3   /user/xxx/test.ca F

File conversion is too troublesome, there is no more convenient, such as directly to a directory of all the MP3 into the caf? Some of them will serve you.

#!/bin/shfunction Scandir () {    local cur_dir parent_dir workdir    workdir=$1    cd ${workdir}    if [${workdir } = "/"]    then        cur_dir= ""    else        cur_dir=$ (pwd)    fi to    dirlist in $ (LS ${cur_dir})    does        if test-d ${dirlist};then            cd ${dirlist}            scandir ${cur_dir}/${dirlist}            CD        : else        file=${cur_dir}/${dirlist}            # echo file            filename=${file%.*}            suffix=${file##*.}  if ["${file##*.}" = "MP3"]thenafconvert-d aac-f caff-b 57623 $file "$filename. Caf"                echo "${file}--  CAF Conversion complete ... "                rm-rf" $file "else echo ' is not MP3 file ' fi        fi    done}if test-d $1then scandir $1elif test-f    $1then    EC Ho "Please enter a file ..."    exit 1else    echo "The directory already exists ..."    exit 1fi

Copy Save as xxx.sh, you are done, just do it at the terminal.

In this way, a key painless to the list of all MP3 converted into CAF.

This site article is for baby bus SD. Team Original, reproduced must be clearly noted: (the author's official website: Baby bus )
Reprinted from "Baby bus Superdo Team" original link: http://www.cnblogs.com/superdo/p/4783380.html

[Tool recommended]_ios audio batch Conversion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.