Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบ >> Linux

ปรับและ Normalize ไฟล์เพลงด้วย FFMPEG

ไฟล์เสียงไม่ได้สร้างเท่ากัน บางไฟล์เงียบเกินไป ดังเกินไป หรือแค่ไม่พอใจ พบไฟล์เสียง problematic ไม่ต้องแค่ทน FFmpeg powerful open-source audio utility ช่วยได้ ปรับ volume ไฟล์ และ normalize กำจัด volume fluctuations ที่ไม่พอใจ แตกกว่า fully scriptable และ baked เข้า Python scripts ที่ streamline ทั้งกระบวนการ

ติดตั้ง FFmpeg

ถ้ายังไม่มี FFmpeg ง่ายมาก Linux users หาได้เกือบทุก distribution repositories Windows และ Mac หาได้ที่ download page ของโปรเจกต์

Basic Loudness

ทุกอย่างที่นี่ผ่าน terminal FFmpeg มี graphical front ends แต command line simplest และ direct ทำงานได้ เปิด terminal ทำงาน

Change directories ไป folder ที่มีไฟล์ต้องการทำงาน FFmpeg รองรับ audio format ทุกประเภทเกือบหมด ไม่ต้องกังวล มีไฟล์ทำงาน รัน FFmpeg ใช้ flag -i ระบุ input file แล้ว flag -filter:a ระบุ filter ในกรณีนี้ปรับ volume FFmpeg ใช้ 1 เป็น original volume ของไฟล์ ลด volume ครึ่ง ตั้ง "volume" = 0.5 จบด้วย output file name รวมแล้วเป็นตัวอย่างด้านล่าง

ffmpeg -i input.flac -filter:a "volume=0.5" output.flac

รันคำสั่งนี้ FFmpeg สร้าง copy input file volume ครึ่ง output ไปชื่อไฟล์ที่ระบุ เพิ่ม volume ได้ด้วย number > 1 ตัวอย่างด้านล่าง volume เพิ่ม 50%

ffmpeg -i input.flac -filter:a "volume=1.5" output.fac

FFmpeg convert files ได้เต็มที่ ระบุ output extension ต่างออกไป FFmpeg จัดการส่วนที่เหลือ

ffmpeg -i input.flac -filter:a "volume=1.25" output.mp3

บางคนสบาย decibels ควบคุมไฟล์ technical FFmpeg รองรับ แทน base one system ก่อน ระบุ decibels ที่อยากเพิ่ม volume ตามด้วย "dB"

ffmpeg -i input.flac -filter:a "volume=5dB" output.flac

ใส่ negative number ลด volume ใน decibels

ffmpeg -i input.flac -filter:a "volume=-5dB" output.flac

Loudness Normalization

ถ้า volume ไฟล์ inconsistent ใช้ FFmpeg built-in normalization function ควบคุมได้ ตั้งคำสั่งเหมือนปรับ volume แตใช้ "loudnorm" แทน volume เป็น filter FFMpeg จะพยายาม lower และ raise peaks และ valleys ในเสียง ทำให้ฟังสบายขึ้น

ffmpeg -i input.flac -filter:a loudnorm output.flac

Automated with Python

มีอะไรเพิ่มตอน normalize audio ด้วย FFmpeg แตต้องการความรู้ audio works และ math แทนทำเอง มี Python script 便利 automate ทั้งหมด และ handle folders เยอะพร้อมกัน

ติดตั้ง ffmpeg-normalize

ถ้ามี Python ติดตั้งพร้อม Pip package manager ใช้ติดตั้ง ffmpeg-normalize Linux และ Mac users จะต้อง "sudo" เว้นแต่ config แตกต่าง

sudo pip3 install ffmpeg-normalize

ใช้ ffmpeg-normalize

ffmpeg-normalize ใช้ง่ายมาก ให้ input file ตามด้วย output file หลัง flag -o script จะ auto normalize ไฟล์ ต้องระบุ codec เพื่อทำงาน

ffmpeg-normalize input.flac -c:a flac -o output.flac

ระบุ multiple input และ output files พร้อมกันได้

ffmpeg-normalize input.flac input2.flac input3.flac -c:a flac -o output1.flac -o output2.flac -o output3.flac

convert files ได้ด้วย ยังต้องระบุ codec และ bitrate แตทำงานดี Flags เหมือน plain FFmpeg

ffmpeg-normalize input.flac -c:a libmp3lame -b:a 320k -o output.mp3

ใช้ ffmpeg-normalize บนโฟลเดอร์ทั้งหมด

ใช้ wildcard character(*) normalize โฟลเดอร์ทั้งหมด พร้อมหรือไม่มี conversion outputs จะวางใน folder ของตัวเองอัตโนมัติ คำสั่งต่างกันบน Windows และ Linux/Mac แตผลลัพธ์เดียวกัน เพิ่มเติม ต้องระบุ output extension แต่ละไฟล์ด้วย flag -ext ไม่งั้นได้ .mkv files

Mac และ Linux

ffmpeg-normalize *.flac -c:a libmp3lame -b:a 320k -ext mp3

Windows

for %%f in ("*.flac") do ffmpeg-normalize "%%f" -c:a libmp3lame -b:a 320k -ext mp3

วิธีไหนก็ตาม ไม่มีเหตุผลทน poor quality audio ปรับและ normalize volume ได้ง่ายด้วย FFmpeg ได้ something evenly balanced ที่ fit กับ collection ที่เหลือดีกว่า