How to batch swap audio track?

I have an old series which came with two audio tracks. First is russian and other english.

Is there a way to batch switch the tracks, as changing the audio track to english every time a new episode plays is annoying.

Attached: 1517732823542.jpg (1600x2505, 500K)

your player can prioritize different audio track metadata-labels. Those labels are not mandatory so maybe its not possible.

delete the unwanted audio track? ffmpeg?

MKVToolNix

Unfortunately whoever put the files together labelled them with the same name, so I can't use mpc/vlc to do so. I also would like it to default to the english on a player that is unable to prioritize.

I found this:

ffmpeg -i input.mkv -map 0:v:0 -map 0:a:1 -map 0:a:0 -c copy output.mkv

Which I understand will simply swap the tracks, which is exactly what I want. But I'm not familiar with the tools/methods to do this for every file in the directory.

IF there is no metadata then you will have to do it by arbitrary track numbering. Yes you can arbitrarily re-mux your video files to swap channels like -map does but you'll have to personally guarantee the tracks are all laid out with the same numbering.

Yes I can confirm all files have the first track as russian and second english.

I've installed MKVToolNix, and I've tested it with one file but even though I've set it not to compress the data it still seems to.

I am also unsure as to how to batch execute this.

I have no idea what mkvtoolnix is supposed to do. Your ffmpeg command looks correct, why not use that?

Ha ha okay I won't bother with MKVTooNix then.

Yes I would like to do that, but I don't know how to do it for every file. I presume I can create a .bat file? Is there a way to specify this command for every .avi file in the directory, like some kind of wildcard type thing?

a simple bash script that reads a filename stores it and runs a command with the filename that was read?

it's actually stupidly complex but i'd recommend using find -exec. You will have missing arguments no matter what the fuck you're trying to do, it's a goddamned nightmare getting that syntax right. I don't remember it off hand.

find -name '*.mkv' -exec "ffmpeg -i {} -mapetc output_{}.mkv" \;


the alternative is just a for loop of all glob'd files or something which just makes me feel really dirty. Dirtier than find, anyway.

I made a .bat file with this:

FOR /F "tokens=*" %%G IN ('dir /b *.avi') DO ffmpeg -i "%%G" -map 0:v:0 -map 0:a:1 -map 0:a:0 -c copy "%%~nG .avi"

Which seems to work, but adds an extra 1MB to the file. I know it's a bit picky but does this mean some re-encoding/compression happened along the way? It executed quite quickly so it's not like I expect it to have done very much.

I honestly don't know a whole hell of a lot about avi containers. you can try explicitly -vcodec copy and -acodec copy and see if that helps?

Hmm seems to do the exact same thing.
Appreciate the help though!

Okay, according to the files' mediainfo, they have the exact same video, but the audio has different 'alignment', and writing application/library.

Old file:
Writing application : VirtualDubMod 1.5.4.1 (build 2066/release)
Writing library : VirtualDubMod build 2066/release

Alignment : Split accross interleaves
Interleave, duration : 40 ms (1.00 video frame)
Interleave, preload duration : 500 ms


New file:
Writing application : Lavf57.72.101

Alignment : Aligned on interleaves
Interleave, duration : 24 ms (0.60 video frame)

just add alang=eng to your mpv.conf

Oh and also the new file is reportedly 1s longer, which I presume has to do with the 'alignment'.

Thanks but please see

Sounds like a job for ffmpeg

use aid=2 then

Attached: map-audio-stream-to-out.png (2224x120, 88K)

Just to keep track of what's happening.

I appreciate all your help! Right now I'm just trying to figure out how to retain the same 'alignment' as the original . I know it's silly since I don't even know how much of an effect it will have besides slightly worse navigation(?), but I'm a stickler for getting it just right.

would forcing frame rate of the input file work

You should probably add language tags while you're at it

Excellent, I've done that now.

FOR /F "tokens=*" %%G IN ('dir /b *.avi') DO ffmpeg -i "%%G" -map 0:v:0 -map 0:a:1 -map 0:a:0 -c copy -metadata:s:a:0 language=eng -metadata:s:a:0 title=English -metadata:s:a:1 language=ita -metadata:s:a:1 title=Russian "%%~nG [converted].avi"

Still trying to figure out this

Attached: 1500320054338.jpg (3600x2413, 630K)

mpv does not have this problem

mpv has exactly that problem when the file doesn't have metadata tags. I mean the solution is one key press but it has the problem.

Is this from the /hr bread about celebs licking their lips?

Attached: 119_1504952809805.jpg (3168x4752, 978K)

mkdir swapped; for i in *.mkv; do ffmpeg -i "$i" -map 0 -map -0:a -map 0:a:1 -map -0:a:0 -c copy swapped/"$i"

>-map -0:a:0 -c copy
should be -map 0:a:0 -c copy (not excluded)

and forgot to add "; done" at the end
ffs

Haha no. Randomly selected from my collection and thought it was a neat coincidence.

Attached: 1489958532429.jpg (4625x3083, 2.89M)