I'm not familiar with ffmpeg, but came across this script that takes in the file and creates an output with eac3 audio.
#!/bin/sh
echo "Dolby Digital Plus Muxer"
echo "Developed by @kdcloudy, not affiliated with Dolby Laboratories"
echo "Enter the file name to be converted: "
read filepath
if [! -d $filepath]
then
exit $err
fi
ffmpeg -i $filepath -vn ddp.eac3
ffmpeg -i $filepath -i ddp.eac3 -vcodec copy -c:a eac3 -map 0:s -map 0:v:0 -map 1:a:0 output.mp4
rm ddp.eac3
I'd like to know what to modify in this code to ensure all the subtitles are copied from the original file and all the available audio tracks are converted to eac3 and added to the output.mp4 file. For the subtitles copying I tried -map but couldn't get it to work. Thanks for the help!
You only need one ffmpeg
command:
ffmpeg -i input.mkv -map 0 -c:v copy -c:a eac3 -c:s copy output.mkv
-map 0
Selects all streams. Otherwise only one stream per stream type will be selected. See FFmpeg Wiki: Map for more into on -map
.-c:v copy
Stream copy all video.-c:a eac3
Encodes all audio to E-AC-3.-c:s copy
Stream copy all subtitles.For compatibility this assumes that the input and output are both Matroska (.mkv
).
That script is not great. Here's a cleaner, simpler version (not that I think a script is necessary for this):
#!/bin/bash
# Usage: ./eac3 input.mkv output.mkv
ffmpeg -i "$1" -map 0 -c:v copy -c:a eac3 -c:s copy "$2"
If you want to convert a whole directory see How do you convert an entire directory with ffmpeg?