diff --git a/Basilisk/MACAO/macao_12/contenu/media/extract_mp3.sh b/Basilisk/MACAO/macao_12/contenu/media/extract_mp3.sh new file mode 100644 index 0000000000000000000000000000000000000000..72e711e0fe890e56712a948d35045e8ccf061c98 --- /dev/null +++ b/Basilisk/MACAO/macao_12/contenu/media/extract_mp3.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# Extract all MP3 (MPEG) audio streams from a Flash SWF file +# Dependencies: ffmpeg, ffprobe, jq + +if [ -z "$1" ]; then + echo "Usage: $0 <file>" + exit 1 +fi +input=$1 + +# List all streams in the file as JSON, filter all with codec "mp3" and print their index +streams="$(ffprobe -show_streams $input -of json 2>/dev/null | jq -r '.streams | map(select(.codec_name == "mp3")) | map(.index) | join("\n")')" +echo "$input: found $(wc -l <<< $streams) MP3 streams: $streams" + +# Assemble ffmpeg command line by adding '-map' argument and outfile for each stream +cmd="ffmpeg -i $input -vn -c:a copy" +outputs="" +i=0 +while read -r stream_id ; do + cmd="$cmd -map 0:$stream_id $input.$i.mp3" + i=$((i+1)) +done <<< "$streams" +# Run ffmpeg +echo "Executing: '$cmd'" +$cmd +echo "Extracted $i MP3 files from $input."