Introduction
Recently, I came across a content creator I really like on Bilibili. After hitting the like, share, and subscribe buttons, I wanted to download all their videos and convert them to MP3 format so I could listen to them in the car during my daily commute.
System Environment
- macOS Ventura 13.0.1
Download Videos
Install FFmpeg
brew install ffmpeg # Install ffmpeg
Save the Script
vim mp4_to_mp3.sh # Create the script file
#!/bin/bash
mkdir outputs # Create output folder
for f in *.mp4; # Loop through all mp4 files in the current folder
# Convert to mp3 format
do ffmpeg -i "$f" -c:a libmp3lame "outputs/${f%.mp4}.mp3";
done # End loop
Place this file in the folder where the videos are located.
Run the Script
sudo chmod +x mp4_to_mp3.sh
./mp4_to_mp3.sh
enjoy~
