To extract the audio from a video file and convert it to m4r - you can simply use ffmpeg.
ffmpeg is a powerful, terminal based tool and should be available in the repositories of pretty much ALL Linux distributions. So you can simply install it via your installed distro's package management tools.
As
@dos2unix said the .m4r file format is basically just an AAC/mp4, but with the m4r extension.
It's also worth noting that .m4r ringtone files CANNOT exceed 30 seconds.
To rip a 30 second snippet of audio from the video and convert it to an m4r literally takes one command:
Bash:
ffmpeg -i /path/to/video.mov -vn -c:a aac -f mp4 -b:a 128k -ac 1 -t 30 -ss 100 /path/to/ringtone.m4r
Where:
/path/to/video.mov
is the path to the video file.
/path/to/ringtone.m4r
is the path to the desired output file in .m4r format
And the other parameters
-vn
specifies NOT to include video in the output file.
-c:a aac
specifies the stream to convert - in this case audio.
-f mp4
specifies that the output format should be mp4
-b:a 128k
specifies the bitrate of the audio stream
-ac 1
specifies
-t 30
specifies the length of the converted sample
-ss 100
specifies the position in the original file to start converting from.
So the only things you'll need to change in the above command are:
- The path to the input video file.
- The path to the output video file.
- The length of the sample.
- The start position of the snippet you want to capture
Optionally, you might want to us a different bitrate for the converted audio file. I just used 128k as it's more than reasonable for a ringtone. But you could use a higher bitrate if you wanted to.
So I'd recommend opening the video in your preferred video player and making a note of the timestamp of the start of the snippet you want to convert (in seconds).
So if the sample you want to capture is 1 hour 2 minutes and 32 seconds into the video, the value for your start position (for the
-ss
parameter ) will be 3752 seconds.
And then work out how long the sample needs to be and change the value for
-t
- again in seconds. It doesn't matter if the sample is slightly longer than you need it. Once you've ripped the sample, you could edit it with Audacity (another program that is available in ALL Linux distributions), to remove any extra bits of audio at the start/end of the sample.
But again, remember that the maximum lenght of an m4r is 30 seconds. So you could rip more than 30 seconds from the video file, but before transferring the file to your iphone, you'll need to edit it down to 30 seconds or less with something like Audacity.
I hope this helps!