Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > New and alternative a/v containers

Reply
 
Thread Tools Search this Thread Display Modes
Old 11th July 2021, 17:41   #1  |  Link
_kermit
Registered User
 
Join Date: Apr 2017
Posts: 63
Replace video with new video on many mkv

I have a few MKVs I want to replace the video track

I can't figure out how to do this scripted (in this case powershell, but I'm fine even with batch).

the principle is always like that:

* New Video Track (to be added)
* Old Video Track (to be removed)
* Audio (everything else kept)
* subs
* chapter, global etc.

So, keep everything else while replacing the video with another file (always same name).

any pointers, examples?

Last edited by _kermit; 11th July 2021 at 19:00.
_kermit is offline   Reply With Quote
Old 11th July 2021, 18:03   #2  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,219
You can add and remove, video, audio and subtitle tracks/streams using MKVToolNix GUI
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 11th July 2021, 18:59   #3  |  Link
_kermit
Registered User
 
Join Date: Apr 2017
Posts: 63
Quote:
Originally Posted by SeeMoreDigital View Post
You can add and remove, video, audio and subtitle tracks/streams using MKVToolNix GUI
"I can't figure out how to do this scripted (in this case powershell, but I'm fine even with batch)."
_kermit is offline   Reply With Quote
Old 14th July 2021, 21:02   #4  |  Link
therube
Registered User
 
Join Date: Aug 2013
Posts: 191
This is very basic. Test & see if something like this works for you.

MUX - V_A - out.mkv.BAT:
Code:
@ECHO OFF

ECHO  MUX  0:VIDEO:CLIP:0  with  1:AUDIO:CLIP:0 -- *IN THAT ORDER, only!*
ECHO  much like how Video To Video does it, as opposed to "MUX" which is
ECHO  really a "JOIN"
ECHO.
ECHO  therube 02/09/2015
ECHO.
ECHO  VIDEO:
ECHO  %1
ECHO  AUDIO:
ECHO  %2
ECHO.
ECHO  OUTPUT TO .mkv, as that allows stuff like mp4 vid + opus aud, which won't work in .mp4
ECHO.


PAUSE


ECHO.
SET   OUT=C:\OUT
ECHO  OUT=: %OUT%
SET   OFILE=%OUT%\%~n1_MUX_AV%~x1.mkv
ECHO  Output filename:
ECHO  "%OFILE%"
SET   LOG=%OUT%\MUX_AV.TXT
ECHO.

PAUSE


SET VIDEO=%1
SET AUDIO=%2

ECHO  %VIDEO%  > %LOG%
ECHO  %AUDIO% >> %LOG%
ECHO.         >> %LOG%

ECHO  ffmpeg     >> %LOG%
ECHO  -i %VIDEO% >> %LOG%
ECHO  -i %AUDIO% >> %LOG%
ECHO  -c copy  -map 0:v:0  -map 1:a:0  -bsf:a aac_adtstoasc >> %LOG%
ECHO  "%OFILE%"  >> %LOG%
ECHO.            >> %LOG%
ECHO  ========================================================================================= >> %LOG%
ECHO.            >> %LOG%
SF    %LOG%

PAUSE


:: ffmpeg -i %VIDEO% -i %AUDIO% -c copy -map 0:v:0 -map 1:a:0 -bsf:a aac_adtstoasc "%OFILE%"  2>&1  |  tee -a %LOG%
   ffmpeg -i %VIDEO% -i %AUDIO% -c copy -map 0:v:0 -map 1:a:0                      "%OFILE%"  2>&1  |  tee -a %LOG%
ECHO.

PAUSE

touch "%OFILE%" --reference=%1
PAUSE

EXIT
In my case, the intent is to MUX a new audio track in place of the existing.
You would want to adjust it such that the video track is replaced.

The file with your video & the file with your audio need to be in that order, video, then audio (at least as written above).
Touch is the UNIX touch command. Can be ignored if you don't care about setting the file's date to that of the existing (video) file.
tee is the UNIX tee command.
SF is (a renamed) ShowTx. Simply substitute (Windows) TYPE if you want.

Last edited by therube; 14th July 2021 at 21:09.
therube is offline   Reply With Quote
Old 15th July 2021, 12:42   #5  |  Link
_kermit
Registered User
 
Join Date: Apr 2017
Posts: 63
Quote:
Originally Posted by therube View Post
This is very basic. Test & see if something like this works for you.

MUX - V_A - out.mkv.BAT:
Code:
@ECHO OFF

ECHO  MUX  0:VIDEO:CLIP:0  with  1:AUDIO:CLIP:0 -- *IN THAT ORDER, only!*
ECHO  much like how Video To Video does it, as opposed to "MUX" which is
ECHO  really a "JOIN"
ECHO.
ECHO  therube 02/09/2015
ECHO.
ECHO  VIDEO:
ECHO  %1
ECHO  AUDIO:
ECHO  %2
ECHO.
ECHO  OUTPUT TO .mkv, as that allows stuff like mp4 vid + opus aud, which won't work in .mp4
ECHO.


PAUSE


ECHO.
SET   OUT=C:\OUT
ECHO  OUT=: %OUT%
SET   OFILE=%OUT%\%~n1_MUX_AV%~x1.mkv
ECHO  Output filename:
ECHO  "%OFILE%"
SET   LOG=%OUT%\MUX_AV.TXT
ECHO.

PAUSE


SET VIDEO=%1
SET AUDIO=%2

ECHO  %VIDEO%  > %LOG%
ECHO  %AUDIO% >> %LOG%
ECHO.         >> %LOG%

ECHO  ffmpeg     >> %LOG%
ECHO  -i %VIDEO% >> %LOG%
ECHO  -i %AUDIO% >> %LOG%
ECHO  -c copy  -map 0:v:0  -map 1:a:0  -bsf:a aac_adtstoasc >> %LOG%
ECHO  "%OFILE%"  >> %LOG%
ECHO.            >> %LOG%
ECHO  ========================================================================================= >> %LOG%
ECHO.            >> %LOG%
SF    %LOG%

PAUSE


:: ffmpeg -i %VIDEO% -i %AUDIO% -c copy -map 0:v:0 -map 1:a:0 -bsf:a aac_adtstoasc "%OFILE%"  2>&1  |  tee -a %LOG%
   ffmpeg -i %VIDEO% -i %AUDIO% -c copy -map 0:v:0 -map 1:a:0                      "%OFILE%"  2>&1  |  tee -a %LOG%
ECHO.

PAUSE

touch "%OFILE%" --reference=%1
PAUSE

EXIT
In my case, the intent is to MUX a new audio track in place of the existing.
You would want to adjust it such that the video track is replaced.

The file with your video & the file with your audio need to be in that order, video, then audio (at least as written above).
Touch is the UNIX touch command. Can be ignored if you don't care about setting the file's date to that of the existing (video) file.
tee is the UNIX tee command.
SF is (a renamed) ShowTx. Simply substitute (Windows) TYPE if you want.
ffmpeg instead of mkvtoolnix. Didn't think of that.
Would the remaining parts of the original mkv be kept for the new one when just replacing the video?
_kermit is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:47.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.