The code to demonstrate ripping to MP3 is in 04/12_rip_mp3_from_mp4.py. moviepy makes this process incredibly easy.
- The following rips the MP4 downloaded in the previous recipe:
import moviepy.editor as mpclip = mp.VideoFileClip("BigBuckBunny.mp4")clip.audio.write_audiofile("movie_audio.mp3")
- When running this, you will see output, such as the following, as the file is ripped. This only took a few seconds:
[MoviePy] Writing audio in movie_audio.mp3100%|██████████| 17820/17820 [00:16<00:00, 1081.67it/s][MoviePy] Done.
- When complete, you will have an MP3 file:
# ls -l *.mp3-rw-r--r--@ 1 michaelheydt staff 12931074 Sep 27 21:44 movie_audio.mp3