Pintaste Pintaste

Batch Convert MP4 Files to MP3

1 min read 77 words 阅读中文版

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

Downie - Video Downloader for macOS - Charlie Monroe Software

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~

CC BY-NC-SA 4.0 · pintaste

Comments

Giscus comments activate once PUBLIC_GISCUS_* env vars are set.