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, 07:33   #1  |  Link
netmask
Registered User
 
netmask's Avatar
 
Join Date: Jan 2005
Location: Sydney Australia
Posts: 255
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.
__________________
Beyonwiz T3 PVR (Enigma2 clone)
Popcorn Hour A-500
Samsung ES8000 65" LED TV
Yamaha RX-A1070 AV amp
PC - Windows 7 Ultimate 64 bit
netmask is offline   Reply With Quote
Old 18th October 2019, 08:22   #2  |  Link
Tadanobu
Registered User
 
Join Date: Sep 2019
Posts: 13
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, 09:08   #3  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: Chamber 36
Posts: 5,856
You can try staxrip.
stax76 is offline   Reply With Quote
Old 18th October 2019, 11:06   #4  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,495
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, 12:01   #5  |  Link
Groucho2004
►◄
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Location: A wretched hive of scum and villainy
Posts: 4,461
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 12:07.
Groucho2004 is offline   Reply With Quote
Old 18th October 2019, 12:38   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,212
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 13:01.
StainlessS is online now   Reply With Quote
Old 18th October 2019, 12:49   #7  |  Link
Groucho2004
►◄
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Location: A wretched hive of scum and villainy
Posts: 4,461
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 12: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: 255
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.
__________________
Beyonwiz T3 PVR (Enigma2 clone)
Popcorn Hour A-500
Samsung ES8000 65" LED TV
Yamaha RX-A1070 AV amp
PC - Windows 7 Ultimate 64 bit
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: 208
Is -vcodec and -acodec instead of -c:v -c:a still supported?
Cary Knoop is online now   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: 7,212
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 online now   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 06:21.


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