How to remove an audio track from an avi file

If you want to remove an unwanted audio track from a dual audio avi movie file, you can use the following command with Mencoder:

mencoder original_dual_audio_file.avi -o target_file.avi -oac copy -ovc copy -aid 2

or with Ffmpeg:

ffmpeg -i original_dual_audio_file.avi -vcodec copy -map 0:0 -acodec copy -map 0:2 target_file.avi

These will create a file named target_file.avi retaining only the second audio track (aid 2).

Advertisements

Join multiple AVI or MPEG videos into a single file with mencoder

I have some videos I wish to concatenate into a single one, without re-encoding.

It’s very easy with mencoder.

If they are avi:

mencoder -forceidx -ovc copy -oac copy part1.avi part2.avi part3.avi -o total.avi

-forceidx forces to rebuild the index, for seeking.

But if they are MPG files i should use the MPEG container (mencoder uses avi as default, regardless of file extension)

mencoder -forceidx -of mpeg -noskip -mc 0 -ovc copy -oac copy part1.mpg part2.mpg part3.mpg -o total.mpg

The mencoder manual advises the use of -noskip -mc 0 when muxing mpeg files.
For MPEG1 format this has to be specified, because MPEG2 is the default:

mencoder -forceidx -of mpeg -noskip -mc 0 -mpegopts format=mpeg1 -ovc copy -oac copy part1.mpg part2.mpg part3.mpg -o -o total.mpg

Some mencoder scripts

This mencoder script converts WMV into Xvid AVI:

#!/bin/bash
echo -e "   wmv2avi - converts wmv into Xvid avi \n"
echo -e "wmv2avi [wmv] [bitrate] [lame preset] [output] \n"
WMV=${1}
BITRATE=${2-2000}
LAMEPRESET=${3-standard}
AVI=${4-WMV%%.wmv}.avi
echo -e "\n $WMV --> $AVI \n"
echo -e "video bitrate = $BITRATE"
echo -e "LAME preset = $LAMEPRESET \n"
mencoder \
-oac mp3lame -lameopts preset=$LAMEPRESET \
-ovc xvid -xvidencopts pass=1:turbo:quant_type=mpeg \
-ofps 30000/1001 \
$WMV -o /dev/null
mencoder \
-oac mp3lame -lameopts preset=$LAMEPRESET \
-ovc xvid -xvidencopts pass=2:bitrate=$BITRATE:quant_type=mpeg \
-ofps 30000/1001 \
$WMV -o $AVI
rm divx2pass.log

And this one repeats the process for every WMV file in the dir:

#!/bin/bash
echo -e "   allwmv2avi - converte todos os wmv em Xvid \n "
echo -e "   allwmv2avi [bitrate] [lame preset] \n "
for file in *.wmv
do
BITRATE=${1-2000}
LAMEPRESET=${2-standard}
file=${file%%.wmv}
echo -e "\n $file : video bitrate = $BITRATE , LAME preset = $LAMEPRESET \n"
mencoder \
-oac mp3lame -lameopts preset=$LAMEPRESET \
-ovc xvid -xvidencopts pass=1:turbo:quant_type=mpeg \
-ofps 30000/1001 \
$file.wmv -o /dev/null
mencoder \
-oac mp3lame -lameopts preset=$LAMEPRESET \
-ovc xvid -xvidencopts pass=2:bitrate=$BITRATE:quant_type=mpeg \
-ofps 30000/1001 \
$file.wmv -o $file.avi
rm divx2pass.log
done

Change bitrate, fps, LAME presets.

Also to consider are the options -mc 10 or -noskip.

quant=h263 is better for low bitrates (softer video)