Log in

View Full Version : New utility to remux MOV to AVI for Windows NLE happiness.


Blue_MiSfit
24th May 2007, 07:36
Hey folks,

So I've been searching for a simple way to write a batch file that will take a list of QuickTime MOVs containing DV and PCM, and run them through mencoder to remux to AVI, maintaining the 16x9 PAR, and leaving the video and audio streams untouched.

I have a lot of people giving me stuff from their Final Cut systems that I need to work with in Premiere. This utility speeds this process significantly, as it allows me to batch convert a folder of MOVs to AVIs, and then drop them straight into a Premiere timeline, instead of working with Premiere's dreadful media conform engine which (gasp) re-encodes everything, I think.

I dusted off my wholly incomplete Java skillz from my first year of college *thank you SSH and my still active Unix account, complete with my old programs that served as cheat-sheets*, and managed to cobble together a very ugly bit of code that gets the job done to my satisfaction.

I thought I'd post it here. It's pretty short, so I will just add it as code.


// Name: makebatch.java
// By: Blue_MiSfit
// Last Modified 5/23/07, 11:30 PM
//
// This simple little app takes a list of files generated with
// the dir /b command, and generates a .bat file which will
// automatically use mencoder to remux all files to 16x9
// DV AVIs. Handy for exchanging files between NLEs
// when you don't want to rely on their media conforming.
//
// Usage: makebatch list.txt output.bat

import java.io.*;
import java.util.*;

public class makebatch{

public static void main(String[] args){

//setup some data structures
String filename = "";
String newname = "";
String command = "";
FileReader in = null;
BufferedReader filein = null;
FileWriter out = null;
BufferedWriter fileout = null;


// sanity check the command line
if (args.length < 2){
System.err.println("Usage: makebatch list.txt output.bat");
System.exit(2);
}

//setup the reader
try {
in = new FileReader(args[0]);
}
catch (IOException badfile){
System.err.println("input "+args[0]+" is invalid");
System.exit(2);
}
filein = new BufferedReader(in);

//setup the writer
try {
out = new FileWriter(args[1]);
}
catch (IOException badfile){
System.err.println("input "+args[1]+" is invalid");
System.exit(2);
}
fileout = new BufferedWriter(out);

//read a line
while(true){
try{
filename = filein.readLine();
}
catch (IOException badread) {
System.err.println("Error reding input file");
System.exit(2);
}
if (filename == null) break;

// twiddle the line to build the mencoder command
newname = filename + ".avi";

command = "mencoder "+filename+" -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o "+newname;

// write an output line


try{
fileout.write(command);
}
catch (IOException badwrite) {
System.err.println("Error writing output file");
System.exit(2);
}

try{
fileout.newLine();
}
catch (IOException badwrite) {
System.err.println("Error writing output file");
System.exit(2);
}
} // end while loop

//close files
try{
filein.close();
}
catch (IOException badclose) {
System.err.println("Error closing input file");
System.exit(2);
}

try{
fileout.close();
}
catch (IOException badclose) {
System.err.println("Error closing input file");
System.exit(2);
}
}
}


It's hideous, and I will be improving the cleanliness of the code... If there is any interest in developing this into a more capable utility, let me know and I can do some modifications.

Some "idiosyncrasies":
1) It parses every line of the input file, and it doesn't care what that line is. So, if you've got lots of files in your source directory, and not just QuickTime MOVs, it doesn't care. It will make a mencoder command line for everything!

2) I've only compiled this on Solaris. It's Java, so it should run ok on everything, but no guarantees...

3) The batch files it generates expect mencoder to be in the system32 directory, or at least in the same directory as the bat file.

4) The batch file also assumes that the files in question are in the same folder as the batch file.

5) It doesn't remove the MOV extension entirely, it just appends a .AVI to the end. :) I forget the details of twiddling strings to remove 3 characters at the end, and adding 3 others, so I just got lazy and tacked on a new extension.

So yes, it's very un-intelligent, but it serves my purposes for now...

Let me know if anyone finds this useful!

Example input file

20030920-113334-01.mov
20030920-114132-01.mov
20030920-115613-01.mov
20030920-115613-02.mov
20030920-122445-01.mov
20030920-124125-01.mov
20030920-124713-01.mov
20030920-125730-01.mov
20030920-130506-01.mov
20030920-131748-01.mov
20030920-132524-01.mov
20030920-132650-01.mov
20030920-132650-02.mov
20030920-134845-01.mov
20030920-134845-02.mov
20030920-140710-01.mov
20030920-142159-01.mov
20030920-142729-01.mov
20030920-155055-01.mov
20030920-155543-01.mov
20030920-160014-01.mov
20030920-161006-01.mov
20030920-162219-01.mov
20030920-162818-01.mov
20030920-162818-02.mov
20030920-162818-03.mov
20030920-170045-01.mov
20030920-171037-01.mov
20030920-171037-02.mov
20030920-173004-01.mov
20030920-173004-02.mov
20030920-175907-01.mov
20030920-180514-01.mov
20030920-181257-01.mov
20030920-181257-02.mov
20030920-181257-03.mov


Example output file:

mencoder 20030920-113334-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-113334-01.mov.avi
mencoder 20030920-114132-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-114132-01.mov.avi
mencoder 20030920-115613-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-115613-01.mov.avi
mencoder 20030920-115613-02.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-115613-02.mov.avi
mencoder 20030920-122445-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-122445-01.mov.avi
mencoder 20030920-124125-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-124125-01.mov.avi
mencoder 20030920-124713-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-124713-01.mov.avi
mencoder 20030920-125730-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-125730-01.mov.avi
mencoder 20030920-130506-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-130506-01.mov.avi
mencoder 20030920-131748-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-131748-01.mov.avi
mencoder 20030920-132524-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-132524-01.mov.avi
mencoder 20030920-132650-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-132650-01.mov.avi
mencoder 20030920-132650-02.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-132650-02.mov.avi
mencoder 20030920-134845-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-134845-01.mov.avi
mencoder 20030920-134845-02.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-134845-02.mov.avi
mencoder 20030920-140710-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-140710-01.mov.avi
mencoder 20030920-142159-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-142159-01.mov.avi
mencoder 20030920-142729-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-142729-01.mov.avi
mencoder 20030920-155055-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-155055-01.mov.avi
mencoder 20030920-155543-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-155543-01.mov.avi
mencoder 20030920-160014-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-160014-01.mov.avi
mencoder 20030920-161006-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-161006-01.mov.avi
mencoder 20030920-162219-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-162219-01.mov.avi
mencoder 20030920-162818-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-162818-01.mov.avi
mencoder 20030920-162818-02.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-162818-02.mov.avi
mencoder 20030920-162818-03.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-162818-03.mov.avi
mencoder 20030920-170045-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-170045-01.mov.avi
mencoder 20030920-171037-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-171037-01.mov.avi
mencoder 20030920-171037-02.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-171037-02.mov.avi
mencoder 20030920-173004-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-173004-01.mov.avi
mencoder 20030920-173004-02.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-173004-02.mov.avi
mencoder 20030920-175907-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-175907-01.mov.avi
mencoder 20030920-180514-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-180514-01.mov.avi
mencoder 20030920-181257-01.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-181257-01.mov.avi
mencoder 20030920-181257-02.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-181257-02.mov.avi
mencoder 20030920-181257-03.mov -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o 20030920-181257-03.mov.avi


~MiSfit

hanfrunz
25th May 2007, 16:35
hi,

this line in a windows-batchfile should do the same with all *.mov files in the current directory.

for %%x in (*.mov) do mencoder %%x -oac pcm -ovc copy -ffourcc dvsd -force-avi-aspect 16/9 -o %%x.avi

hanfrunz