3

I am trying to simply input an audio file, trim the first 5 seconds and than output it into a directory. I am using jupyter notebook.
This is what i did:

import ffmpeg audio_input = ffmpeg.input('input.mp3') audio_cut = audio_input.audio.filter('atrim', duration=5) audio_output = ffmpeg.output(audio_cut, 'out.mp3') 

I get no errors, but no results as well. I also noticed even if i enter a non-existent file name or path i still don't get any errors.

3
  • Did you try to convert the mp3 to raw PCM audio before cutting it ? I don't thing you can manipulate mp3 without decompressing it first. Commented Nov 29, 2020 at 21:48
  • I haven't tried that. Could you show me how it's done? I am pretty new to this. Or a reference would be helpful Commented Nov 29, 2020 at 23:58
  • The first thing you should do is to convert your file to a .wav file (if you don't have an application for that there are plenty of websites doing that online) and try again with ffmpeg.input('input.wav) instead to see if the problem is really there. Commented Nov 30, 2020 at 9:07

1 Answer 1

9

Add a line of code: ffmpeg.run(audio_output)

import ffmpeg audio_input = ffmpeg.input('input.mp3') audio_cut = audio_input.audio.filter('atrim', duration=5) audio_output = ffmpeg.output(audio_cut, 'out.mp3') ffmpeg.run(audio_output) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.