Note that there are some explanatory texts on larger screens.

plurals
  1. POpython ringtone maker : how to split files
    primarykey
    data
    text
    <p>I'm writing an application for making ringtones for the iPhone. It's just for fun. Here's what I've done till now. (Mind you, i'm a beginner in Python !) So I open my mp3 file in binary mode. read the whole file. Convert it into a list. Use list slicing to split the file. Save this new split into a new mp3 file. This works fine. I however want to the ringtones to have a max of 30 seconds play time and I want the user to choose what portion of the file he wants as the ringtone. Can anyone guide me in the right direction ? Thanks</p> <p>Here's my code till now :</p> <pre><code>f = open("Bruno Mars - Locked Out Of Heaven [OFFICIAL VIDEO].mp3", 'rb').read() mp3 = list(f) fo = open("newFile.mp3", "wb") print(mp3[0:1300000]) fo.write(bytes(mp3[0:1300000])) </code></pre> <p>Here's what I got after some coding:</p> <pre><code>import os f = open("Bruno Mars - Locked Out Of Heaven [OFFICIAL VIDEO].mp3", 'rb').read() fileSize = os.path.getsize("Bruno Mars - Locked Out Of Heaven [OFFICIAL VIDEO].mp3") print("Size of the whole file",fileSize) mp3 = list(f) bitRate = int(input("Enter the bit rate of your file")) size_mbps = bitRate*(15/2048) print("MB per minute :",size_mbps) second_size = int((size_mbps/60)*(10**6)) print("Size of each second :",second_size) start_length = int(input("Enter the start time (in seconds)")) end_length = int(input("Enter the end time (in seconds)")) start_size = int(second_size*start_length) end_size = int(second_size*end_length) fo = open("newFile.mp3", "wb") fo.write(bytes(mp3[start_size:end_size])) </code></pre> <p>It works fine but I need to tweak it a little more. Any input on this code ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload