Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Question for performing "Auto-Cut" of big MP3 Files

This isnt a bug at all but as I am new to coding with python I have a Community question as I am not sure where to start ! At the moment I use the following code for cutting mp3 files with Python :
-----------------------------------------
from pydub import AudioSegment

files_path = ''
file_name = ''

startMin = 9
startSec = 50

endMin = 13
endSec = 30

# Time to miliseconds
startTime = startMin*60*1000+startSec*1000
endTime = endMin*60*1000+endSec*1000

# Opening file and extracting segment
song = AudioSegment.from_mp3( files_path+file_name+'.mp3' )
extract = song[startTime:endTime]

# Saving
extract.export( file_name+'-extract.mp3', format="mp3")
-----------------------------------------

This works without any issue. Now I have a lot of 1h+ .mp3 Files (Electronic Music Sets) and want to cut them all in 1-2 min MP3 Files which have all random lenghts (between 1-2 mins) and are all name for Example (File Pt. 1) (File Pt.2) etc. So in the end I should have the whole Set as tracks which can still be heard in a row.

How do I have to change the code to achieve this solution ? To make the problem and the needed functions clear a last time:

   1.File is 1 hour+ and have to be cutted into single tracks which are named in a way that they can still be heard in a row.
   2.All tracks should have different lenghts between 1-2 mins
   3.File name should be set 1 time and all files afterwards should be continued with "Pt. 2/3/4" etc.
   4.(Auto Detect the lenght of the MP3 File so it will 100% just use values between 1-2mins and the last file is not 30 seconds for example)

Also after this works I would like to have a simple small GUI for choosing the File and entering the File Name and maybe choose the Directory for saving the final files. As there are also a lot of possiblities it would be awesome if you could suggest me one !

Best Regards to all of you guys !


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Java] by Account of the GodsAug 15, 2017 05:33 AM 6 299 Aug 15, 2017 05:33 AM
Last Post: Mohinder
[C] by Byte™Aug 8, 2017 12:35 AM 2 259 Aug 8, 2017 12:35 AM
Last Post: owonbo
[.NET] by prapaoNov 9, 2015 09:38 AM 5 180 Nov 9, 2015 09:38 AM
Last Post: Diamondo