Shifting, converting and trimming audio

What exactly?

Shifting is the process when you delay an audio in a negative or positive way. Matching it from one source on another source.
Trimming is the process when you remove parts of the audio. Also, for the same purpose.


What do I need for shifting the audio?

Subfix-Pack, WSL version 1 with Ubuntu / Debian / Pengwin & one of the following scripts:
Shift_AudioToBD.bat

Run the following commands under one of the listed ditros:

sudo apt update 
sudo apt upgrade -y
sudo apt-get install -y ffmpeg sox

What do I need for trimming the audio?

Subfix-Pack, Aegisub & one of the following scripts:
Trim_Audio.bat
Convert_Trim_Audio-toAAC.bat
Convert_Trim_Audio-toFLAC.bat
Put the scripts inside the “Subfix-Pack” folder.
As always I highly recommend reading all comments starting with “::” inside the batch files.
Some scripts might not work out of the box.


What do I need for converting the audio?

Subfix-Pack & one of the following scripts:
Convert_Trim_Audio-toAAC.bat
Convert_Trim_Audio-toFLAC.bat
Put the scripts inside the “Subfix-Pack” folder.
As always I highly recommend reading all comments starting with “::” inside the batch files.
Some scripts might not work out of the box.


Shifting audio:

Just run the batch file.


Shifting audio (old method):

This method is much slower for a whole show, so I don’t recommend it.
Only use this if you really can’t set WSL up.

Open both source with Aegisub.
2020-07-21 20_13_17-_ Untitled - Aegisub 8975-master-8d77da3.png
The source you want to use (Source 1) and the source you want to take the audio and/or subtitles from (Source 2). Skip through both of the videos (arrow keys on your keyboard) to the exact same frame. You probably notice a time difference with both sources, that’s your wanted delay. You can easily calculate it, just substract “Source 1” with “Source 2” – resulting in 1001ms difference in this example.
2020-07-21 20_21_42-_ Untitled - Aegisub 8975-master-8d77da3

Open MKVToolnix and drag & drop both sources on it. Deactivate all tracks you don’t need and start entering the “Delay (in ms)” you got from your work below. You have to enter them for every audio & subtitle you want from “Source 2”.
2020-07-21 20_31_41-MKVToolNix GUI v46.0.0 ('No Deeper Escape') 64-bit.png
Mux it and you’re done.


Trimming audio:

Open your source with Aegisub.
2020-07-21 20_13_17-_ Untitled - Aegisub 8975-master-8d77da3.png
Skip through the video (arrow keys on your keyboard) until you see the part you want to trim. Note down the starting frame and ending frame of that part.
2020-07-21 20_15_16-_ Untitled - Aegisub 8975-master-8d77da3
In this example the starting frame is 4297 and ending frame 6353.
That means you want everything except the part between 4297 & 6253.
So, your trim command is: Trim(0,4296)++Trim(6254,0)
0 also means “until the end”, which is really useful.
The syntax is basically: Trim(START_FRAME,END_FRAME)

Some other examples:
Trim(3000,0) = Starting with frame 3000 until 0 (End)
Trim(3000,30000) = Starting with frame 3000 until 30000
Trim(1000,5000)++Trim(6000,0) = Starting with frame 1000 until 5000 & starting from 6000 until 0 (End) – Removing everything between 5001 and 5999

After having the “Trim” command, you’ve to create a “Trim.txt” inside the “Subfix-Pack” folder. Write your command down and save it. That’s all. You can run the Batch-File now.
2020-07-21 20_42_03-Subfix-Pack.png


Converting audio:

You can change the options inside the batch file.

trim
If you want to trim the audio before converting
Allowed values: "y" or "n"
Default: n
replace
Replace the audio from your source if your input is .mkv/.mp4
Allowed values: "y" or "n"
Default: n
track
Use a different audio track than the first one
Allowed values: Every number
Default: 0 (autodetect)