problem: double audio playback
The other day I encountered a problem when playing back a cartoon dubbed in my native tongue. When playing you could hear the english track playing at the same time as the other audio track. This was on an Apple TV using Plex, and I could not reproduce the behavior locally using VLC or Media Player Classic. Doing a bit of research I encountered the solution. Opening the video using MediaInfo I could see that both audio track where marked as default, this can be fixed using ffmpeg and the following command:
ffmpeg.exe -i <input file> -map 0 -c copy -disposition:a:0 0 -disposition:a:1 default <output_file>
Basically, we need to remux the file to a similiar file where the first audio track (a:0 0) is reset, and the second audio track (a:1) is marked as default.
The default track of the resulting file can be checked using MediaInfo or the ffmpeg tool ffprobe:
ffprobe -hide_banner <output_file>
Here's a PowerShell script to automate the task:
# Recursively scans for and processes all identified mp4 files from the current working directory
$input_videos = Get-ChildItem -Filter *.mp4 -Recurse
foreach ($video in $input_videos) {
$output_dir = '<output dir>' # Change this to where you want the output saved (eg. 'C:\Converted_videos')
$output_vid_name = $output_dir + $video.Basename + $video.extension
ffmpeg.exe -i $video.FullName -map 0 -c copy -disposition:a:0 0 -disposition:a:1 default $output_vid_name
# Uncomment the following lines if you want the output of ffprobe to be saved alongside the remuxed videos
# $output_meta_name = $output_dir + $video.Basename + ' ffmpeg info.txt'
# ffprobe -hide_banner $output_vid_name 2>&1 | Set-Content -Encoding oem $output_meta_name
}