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 18th October 2019, 06:33   #1  |  Link
netmask
Registered User
 
netmask's Avatar
 
Join Date: Jan 2005
Location: Sydney Australia
Posts: 260
Batch convert AVI to MKV

I'm sure this has been covered countless times but my searches for a simple straight forward method have been in vain. So is there either a script I can run or a GUI preferable. I have played with MKVToolNix but I always end up with one big file all titles being appended rather than as separate files.... In all I have around 100 avi files that I would like to put in a MKV container. Many thanks.
__________________
SONY 75" Full array 200Hz LED TV
Yamaha A1070 amp
Zidoo UHD3000, Popcorn Hour A-500
BeyonWiz PVR T3 & V2 (Enigma2 clone)
Chromecast
Pioneer Bluray BDP-150-K
Windows 7 Ultimate
QNAP NAS TS851
netmask is offline   Reply With Quote
Old 18th October 2019, 07:22   #2  |  Link
Tadanobu
Registered User
 
Join Date: Sep 2019
Posts: 37
While we're at it, I'll join your thread and ask for help too.

In the past, I've been using batch files to append videos (old 2 CD rips) and merge subs. They work fine most of the time but I notice several cases where the subs and/or the audio become a bit out of synch after the process. Any idea why ? Does it comes from the script or the input files ? The same thing has been happening using MKVToolNix.

Also, I think it would be nice to have a thread with a collection of batches to perform various operations.
Tadanobu is offline   Reply With Quote
Old 18th October 2019, 08:08   #3  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
You can try staxrip.
stax76 is offline   Reply With Quote
Old 18th October 2019, 10:06   #4  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Quote:
Originally Posted by netmask View Post
I have played with MKVToolNix but I always end up with one big file all titles being appended rather than as separate files
It depends on your setting.
"MKVToolNix GUI"->"Preferences (Ctrl+P)"->"Multiplexer"->"When dropping files". There you can set to create new multiplex for each file or ask every time (when using drag&drop). Then you can add 100 files, click "Multiplexer"->"Actions for all tabs"->"Start multiplexing".

Note that this will only change the container, not re-encode to more modern codecs. To do the latter you need a software like the mentioned StaxRip. You didn't say why you want to convert to mkv.
sneaker_ger is offline   Reply With Quote
Old 18th October 2019, 11:01   #5  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by netmask View Post
In all I have around 100 avi files that I would like to put in a MKV container.
Use ffmpeg in a batch file:
Code:
for %%i in (*.avi) do (
	ffmpeg -fflags +genpts -i "%%i" -acodec copy -vcodec copy "%%~ni.mkv"
)
__________________
Groucho's Avisynth Stuff

Last edited by Groucho2004; 18th October 2019 at 11:07.
Groucho2004 is offline   Reply With Quote
Old 18th October 2019, 11:38   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Groucho2004 thing expanded a bit [no idea what "-fflags +genpts" does but I guess you could try add it (timestamps probably)]

Demo.Bat or Demo.Cmd
Code:
REM We DO NOT LIKE SPACES IN FILE NAMES (REM == REMark ie comment)

setlocal

REM Where to Find ffmpeg
set FFMPEG="C:\BIN\ffmpeg.exe"

REM Where to get input file, No terminating Backslash, "." = current directory (ie same as .bat file dir)
set INDIR="."

REM Where to place output file, No terminating Backslash. "." would be same as .bat file : ".\OUT" = OUT folder in same directory as bat file.
set OUTDIR="D:"

REM Below, can add extensionas as eg *.WMV (SPACE separated)
FOR %%A IN (*.Avi *.mp4) DO (

REM ****** Un-REM ONLY one of below lines *******.
    %FFMPEG% -i "%INDIR%\%%A" -vcodec copy    -acodec copy      "%OUTDIR%\%%~nxA.MKV"
REM %FFMPEG% -i "%INDIR%\%%A" -vcodec utvideo -acodec copy      "%OUTDIR%\%%~nxA.MKV"
REM %FFMPEG% -i "%INDIR%\%%A" -vcodec utvideo -acodec pcm_s16le "%OUTDIR%\%%~nxA.AVI"
REM *********************************************.

)

REM ... Above UN-REM'ed lines :
REM      (1) Remux, copy both video and audio   (output MKV).
REM      (2) UtVideo lossless video, copy audio (output MKV).
REM      (3) UtVideo lossless video, PCM audio  (output AVI).

Pause
Not all streams can successfully be encapsulated in all containers.
EDIT: I use 3rd one a lot for Avisynth, avoids lots of fussing about with FFMpegSource and LSmashSource, and [EDIT: Lossless] AVI is pretty much always frame accurate.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 18th October 2019 at 12:01.
StainlessS is offline   Reply With Quote
Old 18th October 2019, 11:49   #7  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by StainlessS View Post
no idea what "-fflags +genpts" does but I guess you could try add it (timestamps probably)
It prevents errors such as "Can't write packet with unknown timestamp".
Quote:
Originally Posted by StainlessS View Post
Not all streams can successfully be encapsulated in all containers.
True, it's trial and error and/or some googleling (or is it googling? Who knows...).
__________________
Groucho's Avisynth Stuff

Last edited by Groucho2004; 18th October 2019 at 11:52. Reason: typo
Groucho2004 is offline   Reply With Quote
Old 1st November 2019, 00:49   #8  |  Link
netmask
Registered User
 
netmask's Avatar
 
Join Date: Jan 2005
Location: Sydney Australia
Posts: 260
Quote:
Originally Posted by sneaker_ger View Post
It depends on your setting.
"MKVToolNix GUI"->"Preferences (Ctrl+P)"->"Multiplexer"->"When dropping files". There you can set to create new multiplex for each file or ask every time (when using drag&drop). Then you can add 100 files, click "Multiplexer"->"Actions for all tabs"->"Start multiplexing".

Note that this will only change the container, not re-encode to more modern codecs. To do the latter you need a software like the mentioned StaxRip. You didn't say why you want to convert to mkv.
The media player in question accepts MKV and is problematic with avi's. All done now and they all work seamlessly.
__________________
SONY 75" Full array 200Hz LED TV
Yamaha A1070 amp
Zidoo UHD3000, Popcorn Hour A-500
BeyonWiz PVR T3 & V2 (Enigma2 clone)
Chromecast
Pioneer Bluray BDP-150-K
Windows 7 Ultimate
QNAP NAS TS851
netmask is offline   Reply With Quote
Old 1st November 2019, 01:32   #9  |  Link
Cary Knoop
Cary Knoop
 
Cary Knoop's Avatar
 
Join Date: Feb 2017
Location: Newark CA, USA
Posts: 397
Is -vcodec and -acodec instead of -c:v -c:a still supported?
Cary Knoop is offline   Reply With Quote
Old 1st November 2019, 11:55   #10  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by Cary Knoop View Post
Is -vcodec and -acodec instead of -c:v -c:a still supported?
Well -vcodec and -acodec are both used in the bat demo previoulsy posted, and have not ever caused me any problems.

Code:
REM ****** Un-REM ONLY one of below lines *******.
    %FFMPEG% -i "%INDIR%\%%A" -vcodec copy    -acodec copy      "%OUTDIR%\%%~nxA.MKV"
REM %FFMPEG% -i "%INDIR%\%%A" -vcodec utvideo -acodec copy      "%OUTDIR%\%%~nxA.MKV"
REM %FFMPEG% -i "%INDIR%\%%A" -vcodec utvideo -acodec pcm_s16le "%OUTDIR%\%%~nxA.AVI"
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS 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 16:27.


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