Convert all files in folder hierarchy from MKV to MP4 files

204 views
Skip to first unread message

Kayle Maclou

unread,
Jun 16, 2015, 4:38:02 AM6/16/15
to house...@googlegroups.com

I would like to convert a few hundred MKV video files, to MP4 video format. I don’t want to convert them one at a time and would prefer to convert them as a batch. These files are stored in a directory hierarchy and once converted, I would like the MP4 file saved to the same directory, as it’s corresponding MKV file.


I am considering writing a Windows batch file, to traverse the directory hierarchy, to find all the MKV files and then call a command-line video converter, to perform the actual conversion.


HOWEVER, before embarking on this “saga,” I was wondering if anyone new of a simpler method or a tool that I could use to perform this batch video file conversion?

Dieter Rosch

unread,
Jun 16, 2015, 4:43:52 AM6/16/15
to house...@googlegroups.com
Check out Handbrake 
https://handbrake.fr/

Sent from my iPad
--
--
You received this message because you are subscribed to the Google
Groups "house4hack" group.
To post to this group, send email to house...@googlegroups.com
To unsubscribe from this group, send email to
house4hack+...@googlegroups.com
---------------------------------------------------------------------------------------------
www.house4hack.co.za | Centurion Tue 18-21 & Sat 9-14 | Randburg Wed 18-21
---------------------------------------------------------------------------------------------
---
You received this message because you are subscribed to the Google Groups "house4hack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to house4hack+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Philip Booysen

unread,
Jun 16, 2015, 4:46:10 AM6/16/15
to house...@googlegroups.com

Gert van den Berg

unread,
Jun 16, 2015, 10:53:56 AM6/16/15
to house...@googlegroups.com
If you have a decent verion of Windows 7 (Enterprise / Ultimate), start by installing Subsystem for Unix applications (And the SDK from Microsoft)... It allows you to write decent scripts without dealing with the batch file "language" (which make csh scripts look usable) (ksh / Bourne shell) (You can also install gentoo-prefix on to of Interix (SUA) for a decent environment) (Cygwin is another option, but it runs on top of Win32, rather than as a subsystem on top of the NT kernel, so its performance is likely worse...) (SUA was discontinued somewhere in Win 8.x though...)

Powershell is another option that allows for decent scripting.

I would script ffmpeg / libav for the purpose... (You might be able to copy the existign video / audio stream if the codecs in the MKV is usable in MP4)

Bourne like script: (outfile name setting might be bash-specific)
ffmpeg_options="-acodec copy -vcodec copy" # Change as needed
find /startdir -type d | while read dir; do ( # Start a subshell per directory
    cd "$dir"
    for f in *.mkv; do
       if ! [ -f "$f" ]; then
          continue
       fi
       outfile="${f%mkv}mp4"
       ffmpeg -i $ffmpeg_options "$f" "$outfile" & # The ampersand might want to be avoided if you have a lack of processing power (if transcoding) / disk IO (with codecs set to copy)
    done
    wait # Wait for background jobs started with "&"
); done

Paul Scott

unread,
Jun 16, 2015, 11:41:10 AM6/16/15
to house...@googlegroups.com

Or you could get the native binaries for Windows from https://www.ffmpeg.org/download.html


--

Gert van den Berg

unread,
Jun 16, 2015, 11:45:37 AM6/16/15
to house...@googlegroups.com

Doesn't solve the lack of a Bourne like shell...

You received this message because you are subscribed to a topic in the Google Groups "house4hack" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/house4hack/Z_HkD0rkwtA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to house4hack+...@googlegroups.com.

Paul Scott

unread,
Jun 16, 2015, 11:50:10 AM6/16/15
to house...@googlegroups.com

I'm not a Windows person (apart from writing the occasional win app and xbox app), but surely powershell could do it? Not a very complex script, and having to install a ton of stuff that can all go wrong, seems like a bad idea to me.

Other alternative is to quickly spin up an Ubuntu VM, and just copy and paste...

-- Paul

Gert van den Berg

unread,
Jun 16, 2015, 5:17:04 PM6/16/15
to house...@googlegroups.com


On Tuesday, June 16, 2015 at 5:50:10 PM UTC+2, Paul Scott wrote:

I'm not a Windows person (apart from writing the occasional win app and xbox app), but surely powershell could do it? Not a very complex script, and having to install a ton of stuff that can all go wrong, seems like a bad idea to me.

Other alternative is to quickly spin up an Ubuntu VM, and just copy and paste...


Powershell should be able to do it... (As I mentoned before) (I can't give a script for it by making it up as I go along though )

I like SUA if I need to use Windows though...

(A batch file should be possible, but it is not an especially friendly language to deal with... (The WSH languages might be a better option))

Gert

Kobus Van der Walt

unread,
Jun 17, 2015, 1:00:04 AM6/17/15
to house4hack
Thanks for the windows info Gert.. running bash scripts in windows! awesume!


--
Reply all
Reply to author
Forward
0 new messages