2

I have a bunch of video files with 2 audio tracks. They are avi files. The audio tracks have no labels and when I try to play them the default track has no audio. There are 2 more tracks, the second is the one with audio.

Is there a command I could run that would remove tracks 1 and 3 from every file?

They are on a Ubuntu server. CLI only.

avprobe version 9.18-6:9.18-0ubuntu0.14.04.1, Copyright (c) 2007-2014 the Libav developers
  built on Mar 16 2015 13:19:10 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[mpeg4 @ 0xd1dac0] Invalid and inefficient vfw-avi packed B frames detected
Input #0, avi, from 'Video004.avi':
  Metadata:
    encoder         : VirtualDubMod 1.5.10.2 (build 2540/release)
  Duration: 00:49:16.99, start: 0.000000, bitrate: 1937 kb/s
    Stream #0.0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 640x480 [PAR 1:1 DAR 4:3], 23.98 tbn, 23.98 tbc
    Stream #0.1: Audio: mp3, 32000 Hz, 1 channels, s16p, 96 kb/s
    Stream #0.2: Audio: mp3, 32000 Hz, 1 channels, s16p, 96 kb/s
    Stream #0.3: Audio: mp3, 32000 Hz, 1 channels, s16p, 96 kb/s
# avprobe output
1

avconv seems to be the solution

avconv -i $file -map 0:0 -map 0:2 -acodec copy -vcodec copy $outfile

I put this into a loop

dir="*.avi"
for file in $dir
do 
 avconv -i $file -map 0:0 -map 0:2 -acodec copy -vcodec copy $outfile
done

I did not try saving to the same file name but I assume it would not work. You can easily have this delete the old file and rename the new one. I just output to a temp directory with the same names and then moved them all overwriting the originals.

To explain The map arg. tells avconv what tracks to copy. 0:0 is the video and 0:2 is the second audio track. Then acodec and vcodec are set to copy meaning it copies the audio and video without changing it.

|improve this answer|||||
  • after trying your method i get this message, Stream map '0:2' matches no streams. To ignore this, add a trailing '?' to the map. So I add ? and it worked like a charm. Thanks :) – ddas Sep 19 '17 at 6:20
0

Try this link. Scroll down until you reach Convert Mono Audio to Stereo and Vice Versa and try that. It allows you to turn a stereo track into a Mono track by choosing one of the channels.

|improve this answer|||||
  • Unfortunatly thats just for audio files. – JpaytonWPD Oct 14 '15 at 19:45
  • Would it work with this? avidemux.org/admWiki/doku.php?id=using:command_line_usage – Academiphile Oct 14 '15 at 21:50
  • Either choose the track, or extract the track, edit it with the first tool, and then choose that one – Academiphile Oct 14 '15 at 22:02
  • so --save-raw-audio maybe. Will it actually remove the audio from the avi or just copy? I dont see any argument to select which audio track to extract. – JpaytonWPD Oct 15 '15 at 12:23
  • Check out the Re-encoding a soundtrack to MP3 VBR Section. Save the raw audio, process it using the first program, and then save it to the avi again – Academiphile Oct 15 '15 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.