Transcode MOV to MP4

GitHub Source

Motivation:

Digital cameras and phones typically save video to MOV (Motion JPEG) files. I share my photos & videos via a self hosted open source photo gallery (zenPhoto). MOV files must be converted to a compatible format like MP4 to stream through the readily available web video players like Flowplayer.

Script features:

  • Handles multiple files at once… even from different folders, e.g. when part of a file explorer search result
  • Applies rotation where recognized in the EXIF metadata.
  • Touches new file datestamp to be same as original.

Leverages 3rd party tools:

  • FileMenu Tools (FMT) - handy for creating a FileExplorer right mouse context menu for executing transcode on selected files
  • HandBrake - read something that suggested HandBrake is faster than ffmpeg and that appears true on my quick comparison
  • MediaInfo - pulls the EXIF metadata to determine if any rotation is necessary

Install:

  1. save transcode.ps1 to a known location
  2. install FileMenu Tools and disable all the commands you don’t want.
  3. Configure a “transcode” command as shown in screenshot below... edit for your path
    • updated FMT Arguments: -Command "{path}\transcode.ps1" -list %TEMPFILEPATHS% -rotate auto
  4. install HandBrake and put HandBrakeCli in your path
  5. minimally, put MediaInfo.exe and MediaInfo.dll in your path

Windows File Explorer UI example

enter image description here

FileMenu Tools Config

enter image description here

Transcoding Motion-JPEG (.MOV) to MPEG-4 (H264)

 

please see => Newer Approach

 

I have a Panasonic DMC-ZS5 (dpreview, Panasonic) which creates .MOV files that contain the Motion JPEG (M-JPEG) “format” (for want of a more technical term).

In order to stream those videos from my IIS/PHP based photo gallery (zenPhoto.org), they must be converted to a more “web compatible” format like MPEG-4.  I haven’t found a more straightforward approach than direct batch conversion to another format… you can readily automate the conversion of say all the videos in a folder so it’s pretty much turnkey and ignore.

Update 2015-01-05: This is my current go-to:

Notes:

  • make sure to double up all the %%v if you put in .cmd batch file
  • ffmpeg is a very popular 3rd party command line util. I get mine from here.

Update 2015-07-18: cropping 3D movies down to single image

  • obviously check the real resolution before setting the crop… just divide it by 2
  • “setdar” is the aspect ratio… i found it was necessary… one way to find it is with VLC CTRL-J on the original video

VLC will do this via a command line like so:

Notes:

  • I’ve had to remove the acodec=mpga for my iPhone MOV’s or else I get garbled audio.
  • I included the vfilter=”rotate…” for rotation syntax since it was so hard for me to find but only include if you want rotation.

However, I noticed that VLC chops off the last 2 seconds no matter what I do… it seemed a little better choosing a different vcodec but h264 is too rocking to use anything else.

So I wound up going with QuickTime as my go-to transcoder for now.  It doesn’t truncate any video and creates a slightly smaller output file than VLC.  The compression is dramatic and h264 does an awesome job with preserving quality… even while maintaining 1280 x 720 HD, a 100MB MJPG will go down to a 5MB h264/MPEG file.

Following code stolen from here and tweaked a little, automates the QuickTime COM API to convert a directory full of MJPG’s (see sample code for Chapter.8 > “BatchExport.js”).

There’s no reason why this shouldn’t be in PowerShell… it’d be interesting to see if it was any more readable.

Considering Home Network Storage Alternatives

My current bottom line is that I’ve got a 6 x SATA ICH9R just sitting there on my main Windows 7 machine’s mobo for free so I slapped on 2 TB x 2 in RAID1, published a few shared folders and leave that machine powered on 24/7. After everything else (optical & OS drives) I had two ports left doing nothing so the previous gen 750GB’s x 2 are in RAID0 receiving scheduled backups for a little more cheap peace of mind. I’m hoping by the time I actually need more space, that there will be something along the lines of a 5-bay Drobo engineered around SATA 3.0 (6 Gb/s) internally and USB 3.0 (5 Gb/s!!) externally to finally give us some serious speed for that $700 price point. My big up front consideration: NAS vs DAS

  • What’s better, a true stand alone NAS box –OR- a large/fast DAS array shared from your primary machine???
  • FOR THE HOME scenario: I always go back to preferring DAS connected to my main beefiest workstation/”home-server”
  • You get to rally the performance wagons around at least one location where you have absolute top end HDD access when you want it…
  • If you go with a NAS, you basically accept that GbE is your top end… true, even DAS RAID0 HDD configs generally level out around 100MB/s average xfer rate which is basically the GbE saturation point (1 Gb/s = 125 MB/s minus some packet overhead puts you right around 100 MB/s)… but sequential burst rates can go upwards of 300MB/s (2.4 Gb/s) … so I believe NAS over GbE could very well prevent your drives from spitting the bits as fast as they’re capable.
  • After chasing NAS box performance specs for a while you start to realize that the end game is basically spec’ing out a mid-range PC… so that’s why I can’t stop swinging back to throwing my money at the primary machine’s horsepower and just leave that powered up all the time to share files.
  • My current working scenario is based on a main machine that’s sits at the center of our home’s media universe as the do-it-all living room media player… projector, good speakers, VLC, iTunes, etc… after that, it’s a matter of streaming (primarily video) wirelessly for individual needs (internet tablet, wifey’s PC, etc)… even if I did have the luxury of hiding that main machine somewhere other than the main living space, I think I’d just roll with a cheapo networked media player (e.g. Western Digital TV) in the living room with network storage requirements still covered by the main box.
  • Invariably one wants to share a few things out on the internet as well as around the home… my config readily lends itself to accomplishing this from simple IIS Directory Browsing up to a full blown photo gallery (PHP/MySQL based zenPhoto, love it!!)… other NAS boxes (Synology, etc.) market themselves on more and more “server” oriented features, but why fuss with learning and navigating around the limitations of various embedded linux flavors when you can have the full power of your primary machine’s OS to load up all kinds of goodies?? e.g. Synology’s built in photo gallery is nice but open source is always going to be ahead of the game
  • Another consideration: you don’t hear much talk about virus checking and NAS… maybe I’m worrying about this too much but full scans are something that one must do from time to time… ok yes, most of what we’re putting out there is going to be non executable media that doesn’t require scanning… but being a developer, I’ve developed a fairly extensive library of software that I like to have on hand… it’s doesn’t add up as fast as movies but it’s substantial… and apparently even JPG’s can get viruses… the thought of scanning all those files over the wire (repeatedly) just doesn’t appeal to me.
  • I like the idea of running a reasonable database in this space… granted the optimal database drive configuration is not the same as your primary storage volume –BUT- you do still benefit from having those byte buckets near each other for backups and such
  • [29 Sep 2010] Another one hit me: We finally have full symbolic/hard-link flexibility under Windows 7 NTFS… we can cross phyiscal drives with a link, etc… this allows full granularity to choose exactly what consumes the more valuable RAID1 space but still symlink anything into the same visible folder hierarchy… e.g. a single “movie” shared folder is physically comprised of “classics” subfolder (hosted on RAID1) in addition to “unwatched” (hosted on RAID0)… Shell Link Extension makes symlinks awesomely convenient to create with Windows Explorer.
  • For the HOME sized problem: There starts to be a pile of compelling reasons in favor of connecting the physical storage to the main CPU horsepower over the highest bandwidth possible

Pertinent specs:

  • MB/s = MegaBytes per second, Mbit/s & Mb/s = MegaBits per sec, GbE = GigaBit Ethernet, Gb/s = GigaBits per sec
  • Notable NAS vendors: Synology, QNapBuffalo, LaCieHP, Acer, AsusNetGear, Cisco, ZyXEL
  • Performance rundown of many popular NAS boxes
    • RAID0 based units hold the crown – and nothing tops out much over 100MB/s read or write
    • Didn’t realize the Qnap’s were kicking so much arse
    • The NetGear seems to be the champ but she’s pricey (see my note about their X-RAID technology below under Holy Grail)
  • HD Video Streaming, minimum required bandwidth: in the ballpark of <10MB/s (per client)
    • Blu-ray spec max data transfer rate = 54 Mbit/s (~7 MB/s)
    • HD DVD spec max data transfer rate = 36 Mbit/s
The Holy Grail (at the raw storage level):
  1. Single Volume – a single logical storage pool
  2. Redundancy – at least single drive failure redundancy (with RAID 5 style efficiency)
  3. Different Size Drives – we all want to take advantage of the biggest/cheapest drive available from one year to the next

These are the only options I’m currently aware of:
  • Drobo
  • Windows Home Server
  • NeatGear has something called X-RAID2 in their ReadyNAS line that looks pretty good as well… 6 bay Pro model (empty) = $1000 street <yikes>
  • zFS – Solaris only…various OpenSolaris based versions out there… people do run it under a Windows VM with some success but seems clunky
  • BeyondRAID is like RAID 5 striping & redundancy yet with the freedom of on-the-fly swapping of any drive size
  • Pre-emptive, automatic self healing
  • Tool-less, Tray-less HDD slots
  • Sexy Health lights
  • OS X TimeMachine compatible
  • Downsides:
    • – a bit pricey (5 bay, eSata “Drobo S” = ~$700 empty!) … i feel like they’re charging about $100-$200 over average hardware for their secret sauce
    • – unfortunately it’s run of the mill speedy (60-90 MB/s over eSATA)… too bad we can’t justify the cost with some extra performance
    • – unavoidably it’s running a proprietary format in order to work its magic … the million dollar questions is: What is Drobo’s track record now that they’ve been out there a while??  Definitely need to dig up some solid reliability satistics…  If it ever does totally puke on you, you’d have to wait for a replacement unit to drop in your drives and see what’s still there… and after that, only Data Robotics Inc can possibly save you and it’ll cost you.
    • but is this really any different than RAID5?  RAID is pretty much the same vendor specific lock-in isn’t it??… if your RAID controller up and dies (for me that’d be my mobo 😐 … you’d have to obtain nearly identical duplicate hardware to salvage your drives… apparently you can migrate across same vendor like ICH9R –> ICH10R which does give slightly more flexibility
Windows Home Server
  • You can install PHP
  • It does run fine in a VM
  • OS X TimeMachine compatible
  • – When you add a drive you must designate it as either Storage or Backup (the Storage pool offers no redundancy)
  • – Obnoxious – there’s something whacky about how it does not balance allocation very well across available drives
  • WHS “v2” aka “Vail” due sometime 2010 (V2 is Windows 2008 based, V1 is Windows 2003 based)
  • Great AnandTech.com dissection
    • v1 was basically a fancy tack-on above NTFS – “Drive Extender was the biggest component of the secret sauce that made WHS unique from any other Microsoft OS. It was Drive Extender that abstracted the individual hard drives from the user so that the OS could present a single storage pool, and it was Drive Extender that enabled RAID-1 like file duplication on WHS v1. Drive Extender was also the most problematic component of WHS v1 however: it had to be partially rewritten for WHS Power Pack 1 after it was discovered that Drive Extender was leading to file corruption under certain situations.
    • v2 Drive Extender is now ‘below’ NTFS… proprietary block based storage… single file can/will be spread across multiple disks (“chunking”)
      • biggest downside is that you can no longer just plop a WHS drive in another server to pull files in an emergency
      • chunking means that you’re in a more RAID0 like risk category for your main storage
      • enables backup of open files… to me, Drive Extender v2 provides similar freedoms to what Volume Shadow Copy provides us elsewhere
    • Great stuff in the many comments:
      • This comment basically sums up my WHS vs Drobo question => [RE: Almost there by davepermen on Wednesday, April 28, 2010, on comment page 2] – “in storage-loss for the security, raid5 is superior. if all your data is in duplication mode on whs, it needs 2x the storage space. raid5 needs "one additional disk".” … so Drobo is more like WHS flexibility + RAID5 reliability… so they really are the only game in town and hence the price.
  • Generally accepted as a solid WHS implementation: HP Storage Works x510 (rebranded MediaSmart EX495)


Links:

Richard Feynman (Nobel Physicist, 1918 – 1988)

Richard_Feynman Just kinda catching up with how “fun smart” this guy was… worked on the Manhattan project, all kinds of creative physics problem solving, “Original Prophet of Nanotechnology”, Nobel prize in Physics 1965, liked strip clubs, art and bongo drums… there are at least two semi-auto biographies out there in public circulation… I’m reading “Surely You’re Joking, Mr. Feynman!” right now… also a few enjoyable BBC Horizon videos featuring a fair amount of direct interview content: “The Pleasure of Finding Things Out (1981)”, “The Quest for Tannu Tuva (1988)” and “No Ordinary Genius (1993)

Media Players

Popcorn Hour boxes – ($200 – $350) One of the most popular right now… especially Euro/Asian markets… very much a kitchen sink of features imageimageimage Patriot (memory company) – “Box Office” ($100) image image Iomega – Sreenplay line (<$100 for Iomega ScreenPlay TV Link Director Edition w/o drive) ScreenPlay TV Link Director Edition Director HD Seagate – FreeAgent Theater+, GoFlex TV ($120 range) image image Mede8er image

  • $159 for hard drive less model

ASUS – O!Play Air (HDP-R3) (Best One Yet!?) 212208941  212208941_007 212208941_005 m7RevEHHZoGGWUUg_500

  • $130 Street
  • great to see eSATA! finally as well as typical USB
  • WiFi-N built in
  • cardreader slots
  • haven’t found a good review of it yet but 2 folks on Buy.com liked the non air version

  (Update: 5 Jan 2010) LaCie – LaCinema Rugged HD LaCinema_Rugged_HD_Top_Angle_Remote LaCinema_Rugged_HD_Back_Bezel

  • Loving the looks of that enclosure!  Nice job there Neil!
  • $175 street seems reasonable including 500GB drive
  • This review uses words like “frustrating” :

(Update: 5 Jan 2010) Western Digital – WD TV Live (WDBAAN0000NBK) wdfWDTV_Live

  • Western Digital’s latest lineup has added a “Live” model with network connectivity for $120 street
  • as well as a lower end “Mini” model for $60 street

  Western Digital – WD TV (WDAVN00BN)
mainimage
Highlights:

  • $100 street
  • HDMI & Component
  • only 4” x 4” x 1.6”, 0.67 lbs
  • carry case doesn’t come with but looks pretty slick

IOGear (GMD2025U120)

Highlights:

  • $120 street w/120GB drive
  • HD is definitely upgradeable (2.5”)
  • “only” component and composite, no HDMI

Cirago (CMC1000)
image image
Highlights: