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 > Video Encoding > New and alternative video codecs

Reply
 
Thread Tools Search this Thread Display Modes
Old 26th November 2010, 13:38   #1  |  Link
PLAzmA247
Registered User
 
Join Date: Dec 2007
Posts: 7
PLAzmA's FLV2MKV Batch Script

PLAzmA's FLV2MKV Batch Script - VERSION v1.09


Ok, as we all know FLV is probably how streamed videos come down from many places on the internet.

However FLV containers rather restrict what the files can be played back on, which is why im sure most of you like me prefer to stick the audio and video back in a far more compatible MKV container that doesnt suck donkies danglies.

So after months of manually converting files, i eventually got pissed off enough to go looking for a batch conversion tool that would only extract the video and audio and not try and butcher the quaility by re-encoding it.

Only problem is, i dont think one exists, so then i got pissed off enough to write my own, so here it is:

The scripts can be downloaded from:

http://www.opem.co.uk/download/PLAzm...pt%20V1.09.zip

REQUIREMENTS FOR INSTALL

OS REQUIREMENTS:
Windows 7 (x86/x64)
Windows Vista (x86/x64)
Windows XP (x86/x64)
Windows Server (x86/x64) but is untested.

*NOTE: Although it works in x64 the script only makes use of X86 programs

REQUIRED COMPONENTS FOR INSTALL

Firstly your going to need a home to put the two batch scripts, i recommend c:\scripts or something like this.

Next thing you need to do is download mkvtoolnix (as you need mkvmerge) and flvextract these can be downloaded from:

MKVTOOLNIX - http://www.bunkus.org/videotools/mkvtoolnix/
IF YOUR USING WINDOWS XP SEE BELOW

FLVEXTRACT - http://moitah.net/

FFMPEG win32 - http://ffmpeg.arrozcru.org/builds/

FLV2MPEG4 - http://www.geocities.jp/iconsetjp/fl...v2mpeg4gui.zip
(not sure how long this tool be be here for download)

ADDITIONAL COMPONENTS FOR XP USERS

.NET FRAMEWORK - This is required for flvextract (the flvextract site has the downloads)

FORFILESXP 1.1 - http://www.ipass.net/davesisk/oont_d...d_forfiles.htm
(there is an official ms download for this but using this one you wont need to extact it from the rest of the resource kit. I seriously recommend that you drop choice.com into:

c:\windows\system32

That way it will remain in your system path and wont need its own path.

CHOICE FOr XP - http://support.microsoft.com/default...;EN-US;q117600
(you will need to use something like winrar to extract choice.com so you can use this in xp. I seriously recommend that you drop choice.com into:

c:\windows\system32

That way it will remain in your system path and wont need its own path.

MKVTOOLNIX - After creating the XP update i discovered that an MKV created case most MKV players to crash, after debugging i tracked the issue down to mkvmerge which i belive at time of writing this is version number 4.4.0, assuming it must have worked at some point in the past i tried it with an earlier build of mkvtoolnix, below is the link to the Version i used, other versions may also work ive no clue, all i can tell you is 3.1.0 works in XP.

Im not sure if this is a know fault or just something to do with my system

http://www.bunkus.org/videotools/mkv....1.0-setup.exe

On now you have the tools installed (those without installers i suggest you stick them in their own folder in program files or something. You will also need to set the master batch file (flv2mkv.bat) variables to ensure that you are pointing at the appropriate folders for the tools.


RUNNING THE SCRIPT
Ok now you have it all installed and ready to go, the script has a number of options to make it safer to use and also so it able to work under full automation mode using a task scheduler. You will have already seen the two safety variables in the main batch file, the confirmation must be turned off if you are running using a task scheduler program to launch the script.

The program can either be called from the current folder; this will attempt to convert all the flv files inside the current folder (no child folders).

If your running it using a task scheduler or you want to run the script from another folder, you can simply pass the folder you wish to work with to the script at startup, eg:

flv2mkv.bat "C:\SOMEFOLDERTOCHANGE\SUBFOLDER"

It’s also possible to run the command:

flv2mkv /?

This will bring in the simple built in command line help.

A MESSAGE FROM THE CREATOR

I wrote the script for myself, but as other people can also get some use from it, I let it into the wild.

PLEASE NOTE: users of the script take their own responsibilities for any damage, loss of data or any other desired or undesired results from running the script.

The only thing I really ask is that anyone who does modify the script to improve it, is they think of others like I have and post back their updated script. I don’t have any initial plans to keep development of this rolling past today, however if people help and are interested it may release another version and start to write in far more intelligence to the script.
Pease out PLAzmA 2010


CHANGE LOG:

V1.09
12:19 GMT 30/11/2010
Turns out although mkvmerge detects the real aspect ratio of a video, it completely fails to detect and set the display aspect ratio. For example a 4:3 video would display correctly but it would be in a 16:9 container that meant on a 4:3 display or anything that wasn’t 16:9 it would have black bars down the left and the right. Doesn’t bother me as i only ever play full screen. But technically its wrong by doing this, so i wrote in a fix, to get ffmpeg to read and work out the correct container aspect ratio. Had a thought that I may later on extend the script to run against folders using a recursive search, so this is probably going to be include in the next build. This should mean you could convert an entire drive in one go go on EAT ME.

V1.08
14:02 GMT 29/11/2010
Updated the script to make it work with windows XP as well, see additional components for appropriate downloads. This was a bit of a fudge as XP never had a few of the commands and alas although these tools can be used their functionality is different from the later versions that appeared with vista and windows7. Due to this a few things had to happen to make it work. Firstly all filenames in XP mode will have the spaces and a few other characters removed. This is because forfiles for XP wont pass the variable properly if you have spaces and other things properly. Once the script is ran it will attempt to convert back all underscores (used for space replacement) with spaces to make the filenames look nicer once the scripts complete.

V1.07
16:55 GMT 26/11/2010
Originally the script could only rip x264 video and not the older FLV1 x263 videos, so I’ve written in a tool that will convert FLV1 to MPEG4, or in as so much as it re-pads the video so it thinks it’s actually a proper mpeg4 container. It appears for older FLV1 based videos the time codes are not needed for conversion and in fact screw up playback when included. Due to this I’ve created a dodge to pass in and out the timecode if its required for the conversion.

V1.06
04:31 GMT 26/11/2010
I’ve noticed a documented command in the mkvmerge that allows cropping, this is great as its really fast and doesn’t require a re-encode, so it’s useful for videos that were not cropped properly for broadcast. Because this feature will probably be more useful to call once in a while from the command line I’ve included support for a launch value to be passed as well as a hardcoded value in the main script (note, this is always ignored if command line is supplied) Tested with a few videos and appears to work great.

V1.05
02:42 GMT 26/11/2010
Ok I’ve written in command line passing of the conversion folder (so can run on the existing folders location or can be pass it as a startup variable) and updated confirm start check and confirm delete sub calls. Included simple command line help, will expand on in future versions.

V1.04
19:43 GMT 25/11/2010
Ok I managed to include a small batch routine to strip off the Ampersands and replace them with the english word and instead to prevent it wigging out.


V1.03
19:43 GMT 25/11/2010
Opps Noticed on some files the audio started to wig out, so I’ve updated the script so that it extracts the time codes and passes them into mkvmerge, going to have to redownload a file before i will know if it did fix it in all situations as i stupidly deleted the sources for about 3 gig of data. HAHA oh well, no pain no gain.
UPDATE: After a re-download of the flv file i originally noticed none of the iplayer and uk streamers go wrong without the time codes at time of convert, just a few of the us based files I’ve got. Which is why I didn’t see my mistake before, the corrections worked fine and with the original problem files it all works great again.

V1.02
17:30 GMT 25/11/2010
EAK I’ve just noticed this only currently works with videos that are 25fps, I’m just writing in a fps detection sub call Ok I’ve managed to use a port of ffmpeg win32 to perform the fps detection and it works flawlessly on everything I’ve given it so far, so I’ve updated the tool and it works spot on as far as i can tell. This was a pretty big bodge by just passing the file to ffmpeg and asking it to do nothing apart from dumping the start-up log to obtain the true fps, if ffmpeg changes in the future a better way will be needed to run fps detect or just rebodge the script to capture the right variable again.

V1.01
17:50 GMT 25/11/2010
Initial Build (it manage to convert a folder, huurraarr)

Last edited by PLAzmA247; 30th November 2010 at 18:11.
PLAzmA247 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 15:16.


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