Skip to content

Instantly share code, notes, and snippets.

@ryo-utsunomiya
Last active August 29, 2015 14:05
Show Gist options
  • Save ryo-utsunomiya/595f403518137014340f to your computer and use it in GitHub Desktop.
Save ryo-utsunomiya/595f403518137014340f to your computer and use it in GitHub Desktop.
<?php
$before_ext = '.wma';
$after_ext = '.mp3';
$bitrate = 192;
$ffmpeg = '/usr/bin/env ffmpeg';
$pattern = '*' . $before_ext;
$files = glob($pattern);
foreach ($files as $file) {
$after = str_replace($before_ext, $after_ext, $file);
$command = sprintf(
'%s -y -i %s -b:a %dk %s',
$ffmpeg,
escapeshellarg($file),
$bitrate,
escapeshellarg($after)
);
exec($command, $output, $return_var);
if (0 !== $return_var) {
echo $command;
print_r($output);
exit(1);
}
}
@ryo-utsunomiya
Copy link
Author

Requirement

  • PHP5
  • FFMpeg

Usage

cd /path/to/wma_files
php convert_wma_to_mp3.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment