syed kashifullah
syed kashifullah

Reputation: 21

How to change or modify pitch of audio file (music etc like .mp3 file)using FFMPEG?

I want to change and modify pitch an .mp3 audio file using FFMPEG. But I am unable to use FFMPEG to change or modify pitch of that sound. what command (exact command) should be exactly use for changing pitch of an audio file?

 String outPutPath = new File("/storage/emulated/0/Share it Application/Over_the_HorizonTemp.wav").getPath();
                 
                String[] strFfmpeg  = {"ffmpeg","-i" ,strInputPath,"-af", "rubberband=tempo=1.0:pitch=1.5:pitchq=quality" ,outPutPath};
                execffmpegBinary(strFfmpeg);

execffmpegBinary Function:

public void execffmpegBinary(String[] command) {
    Config.enableLogCallback(new LogCallback() {
        @Override
        public void apply(LogMessage message) {
            Log.e(Config.TAG, message.getText());
            Log.e("TAG", "apply: " +message.getText());
        }
    });
    Config.enableStatisticsCallback(new StatisticsCallback() {
        @Override
        public void apply(Statistics statistics) {

        }
    });

    long executionId = FFmpeg.executeAsync(command, new ExecuteCallback() {
        @Override
        public void apply(long executionId, int returnCode) {
            if (returnCode == RETURN_CODE_SUCCESS) {
                
                Log.e("1TAG", "apply:return code "+returnCode );
                Log.e("1TAG", "apply:execution Id "+executionId );
                Log.e("1TAG", "apply:execution Id "+ new FFmpegExecution(executionId,command));


            } else if (returnCode == RETURN_CODE_CANCEL) {
                Log.e("2TAG", "apply:return code "+returnCode );
                Log.e("2TAG", "apply:execution Id "+executionId );
                Log.e("2TAG", "apply:execution Id "+ new FFmpegExecution(executionId,command));

            } else {
                Log.e("3TAG", "apply: returnCode"+ returnCode);
                Log.e("3TAG", "apply:return code "+returnCode );
                Log.e("3TAG", "apply:execution Id "+executionId );
                Log.e("3TAG", "apply:execution Id "+ new FFmpegExecution(executionId,command));

            }
        }
    });
}

Upvotes: 0

Views: 1107

Answers (1)

Rolf of Saxony
Rolf of Saxony

Reputation: 22443

Try using rubberband

ffplay -i interview.wav -af "rubberband=tempo=1.0:pitch=1.5:pitchq=quality"

You may want to play around with the transients variable of this option as well.

https://ffmpeg.org/ffmpeg-filters.html#toc-rubberband

Edit: if you're unfamiliar with ffmpeg and ffplay, the ffmpeg command line would be:

ffmpeg -i input.wav -af "rubberband=tempo=1.0:pitch=1.5:pitchq=quality" output.wav

If you require details of some other method, other than the command line, you will have to specify what method you are using, preferably with a code sample of what you have tried so far. (edit your question, don't add another comment)

Upvotes: 2

Related Questions