cancel
Showing results for 
Search instead for 
Did you mean: 

Change/remove default audio strean in an avi?

HairyMcbiker
All Star
Posts: 6,792
Thanks: 266
Fixes: 21
Registered: ‎16-02-2009

Change/remove default audio strean in an avi?

I have several (read GB's) of avi's that are dual audio DL/ENG. Now vlc will play the second stream fine, but my media player won't so how do it remove the DL audio and leave the ENG one, or switch them over so ENG is the first stream?
11 REPLIES 11
Waldo
Grafter
Posts: 473
Registered: ‎01-08-2007

Re: Change/remove default audio strean in an avi?

Short answer: don't know.
Less short answer: have you tried avidemux?

$ apt-cache show avidemux
[...]
Description: A free video editor (GTK version)
Avidemux is a free video editor designed for simple cutting, filtering and
encoding tasks. It supports many file types, including AVI, DVD compatible
MPEG files, MP4 and ASF, using a variety of codecs. Tasks can be automated
using projects, job queue and powerful scripting capabilities.
.
This package contains the classic version with GTK+ interface.
Bugs: mailto:marillat@debian.org
Homepage: http://fixounet.free.fr/avidemux/

HairyMcbiker
All Star
Posts: 6,792
Thanks: 266
Fixes: 21
Registered: ‎16-02-2009

Re: Change/remove default audio strean in an avi?

Nope will give it a try, I was thinking I may have to use ffmpeg to strip the first audio stream, but not sure how to do it.
Ben_Brown
Grafter
Posts: 2,839
Registered: ‎13-06-2007

Re: Change/remove default audio strean in an avi?

Quick google found this:
http://ubuntuforums.org/showthread.php?t=1148243
That'll probably be quicker than using a full on gui like avidemux.
HairyMcbiker
All Star
Posts: 6,792
Thanks: 266
Fixes: 21
Registered: ‎16-02-2009

Re: Change/remove default audio strean in an avi?

Nearly, Using ffmpeg -i gives:-
  Duration: 01:33:07.52, start: 0.000000, bitrate: 1201 kb/s
    Stream #0.0: Video: mpeg4, yuv420p, 640x352 [PAR 1:1 DAR 20:11], 25 tbr, 25 tbn, 25 tbc
    Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 32 kb/s
    Stream #0.2: Audio: mp3, 48000 Hz, stereo, s16, 32 kb/s
doing an
ffmpeg -i file.avi -map 0:0 -map 0:2 -acodec copy -vcodec copy filea.avi
Which is I think correct ? I want streams 0 & 2, but it gives corrupt audio on playing.
VileReynard
Hero
Posts: 12,616
Thanks: 582
Fixes: 20
Registered: ‎01-09-2007

Re: Change/remove default audio strean in an avi?

Surely those two audio streams are a single stereo channel?
You might have to demux the avi file into a mp4 (video) and a mp3 (audio) files.
Then mangle the mp3 into mono (if wanted)
Finally remux the mp4 and mp3 file back into a avi file.
A lot of processing!

"In The Beginning Was The Word, And The Word Was Aardvark."

HairyMcbiker
All Star
Posts: 6,792
Thanks: 266
Fixes: 21
Registered: ‎16-02-2009

Re: Change/remove default audio strean in an avi?

No it is def. 2xstereo.
Using avidemux just now and it says the audio is VBR, which is probably why is is corrupt when I try to do a simple copy.
Have it running on a sample of 10 to see how fast/slow it is at the mo.
HairyMcbiker
All Star
Posts: 6,792
Thanks: 266
Fixes: 21
Registered: ‎16-02-2009

Re: Change/remove default audio strean in an avi?

Deleted
Nope it isn't working
HairyMcbiker
All Star
Posts: 6,792
Thanks: 266
Fixes: 21
Registered: ‎16-02-2009

Re: Change/remove default audio strean in an avi?

Ok got it working using avidemux-cli some javascript and a shell script  Grin Simple really  Wink
shutter
Community Veteran
Posts: 22,206
Thanks: 3,769
Fixes: 65
Registered: ‎06-11-2007

Re: Change/remove default audio strean in an avi?



That`s the beauty of Linux..... Simpliicity !... Grin Grin 
(mental note.... keep HB happy, in case you need to know how to do it ! !  Cheesy )
HairyMcbiker
All Star
Posts: 6,792
Thanks: 266
Fixes: 21
Registered: ‎16-02-2009

Re: Change/remove default audio strean in an avi?

Don't know how you would do it in M$. The script was on the avidemux wiki, I just modified it a bit. The javascript was generated by the app (GUI version) when I did a sample run. The -cli version was from the repo.
So as I said simple 😉
#!/bin/bash
mkdir converted
VAR="files.txt"
ls *.avi | sort > $VAR # Collect the files in the current directory
cat $VAR | while read line; do  # Loop read the filenames from the file
INPUT=$(echo ${line}) # Grab the nxt new filename
  avidemux --force-alt-h264  --load "$INPUT" --run ../sample.js --save "converted/$INPUT"  --output-format AVI --quit
done
rm $VAR # Remove the text file with the file names

This is the script. It was originally to convert mpg to avi.
I create a folder called converted, generate a list of all the avi's in the folder, then for each run avidemux telling it to save to converted and use my sample.js file that tells it to select the second audio stream as the main one.
HairyMcbiker
All Star
Posts: 6,792
Thanks: 266
Fixes: 21
Registered: ‎16-02-2009

Re: Change/remove default audio strean in an avi?

OK this failed on 40 odd files for some reason it didn't like the audio.
new cmd line is
"mkvmerge" -o "converted/$INPUT"  "--forced-track" "0:no" "--forced-track" "2:no" "-a" "2" "-d" "0" "-S" "-T" "--no-global-tags" "--no-chapters" "$INPUT" "--track-order" "0:0,0:2"
using mkvmerge to generate mkv's from the avi source, removing the first audio track