Skip to content

Instantly share code, notes, and snippets.

@realamirhe
Created July 9, 2021 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save realamirhe/b92ec7721f8a57e46db98e7b701506cd to your computer and use it in GitHub Desktop.
Save realamirhe/b92ec7721f8a57e46db98e7b701506cd to your computer and use it in GitHub Desktop.
Extract audio from power point (pptx file) with ffmpeg in python
import os
PREFIX_LENGTH = len('media')
POSTFIX_LENGTH = len('.wma')
files = [file for file in os.listdir('.') if file.endswith('wma')]
files.sort(key=lambda string: int(string[PREFIX_LENGTH: -1*POSTFIX_LENGTH]))
count_of_files = len(files)
input_query = ' -i '.join(files)
os.system(f"ffmpeg -i {input_query} -filter_complex '[0:0][1:0][2:0][3:0]concat=n={count_of_files}:v=0:a=1[out]' -map '[out]' output.wav")
# Bitrate range kbit/s [170-210] avg=190
# os.system("ffmpeg -i output.wav -codec:a libmp3lame -qscale:a 2 output.mp3")
# Bitrate range kbit/s [120-150] avg=130
os.system("ffmpeg -i output.wav -codec:a libmp3lame -qscale:a 5 output.mp3")
  1. Make sure you've installed ffmpeg, FFmpeg on Ubuntu 18.04

  2. change your power point file extension to zip

  3. extract new zip file

  4. cd to file-name/ppt/media

  5. paste conatenation.py in this directory

  6. run the conatenation.py

  7. this will create two output.wav and output.mp3 file

Note: Then you can use the VLC player and listen to full voice in 2x speed 🎉.

@rubyFeedback
Copy link

I get an error:

"-filter_complex: No such file or directory"

@realamirhe
Copy link
Author

Hey @rubyFeedback, are you on windows?
Could you remove the single quote after the filter_complex value and check that out again?

os.system(f"ffmpeg -i {input_query} -filter_complex [0:0][1:0][2:0][3:0]concat=n={count_of_files}:v=0:a=1[out] -map '[out]' output.wav")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment