Video

Converting mkv, mpeg-2, anything from disc, to DnxHD or Prores using ffmpeg

Friday, March 25th, 2016

Let’s suppose, for the sake of argument, that you’ve been asked by a director to cut his directing reel. He hands you a DVD and a Blu-ray and asks you to grab clips from them.

There are three problems here. The first is that you really should have been handed Prores or something editable from the get-go. But let’s assume you can’t get the media any other way (because often, you just can’t), and let’s assume that this is all considered fair-use (though current law makes that a bit muddy). We’re left with two technical problems:

  1. Rip: Getting the media off the disc and into a file, which may require circumventing copy protection mechanisms and encryption.
  2. Transcode: Converting the resulting file into something editable. Avid Media Composer won’t cut a .mkv file, and works with a limited range of video codecs. FCPX and Adobe Premiere Pro, despite their focus on working efficiently with many codecs, will still have trouble with some file formats. So this step is required for them too.

Rip

Regarding getting the clips off the disc, there are several applications out there for DVD, and only one that I know of for Blu-ray. From DVD, many people use a pretty fancy open-source tool that lets you pull selected ranges of video, and saves to mp4 (the software is designed to make files that play back on media devices, not for editorial purposes). If I’ve ever had to do this hypothetical task, I’ve avoided using this tool because I want the video to transfer from disc to file with no transcoding or lossy compression in between. So I’d have used this one tool which works for both DVD and Blu-ray. The result is a .mkv file which contains all the video and audio from the disc in its original codec.

So you’ve ripped the video from the disc and you’ve got an mkv file or files. You can play these in VLC Player to have a look at their contents to be sure you’ve got what you need. But none of the NLEs with which you edit can work with the files directly. Here’s how to convert them to dnxhd in order to be able to bring them into Media Composer. We’re going to use an awesome command-line tool called ffmpeg.

Install ffmpeg

At this point, I’m going to be giving instructions that relate to computers running Apple’s OS X. I’m sure it’s possible to do the next steps on a machine running Windows or Linux, but I’m not sure of the exact process. And we’re going to be using the Terminal, which you can find in /Applications/Utilities. You might as well open a Terminal window now.

There are a number of precompiled versions of ffmpeg floating around for download, but the only way to be sure you’re getting one with support for all the necessary formats built-in is to build it from source on your machine. To compile it, you’ll need Apple’s free development tool, Xcode, or at least the Xcode command line utilities. Download and install that from Apple. Then you’ll need to install ffmpeg and its dependencies, a task that is made pretty easy by a packaging system called ‘homebrew‘. If you’ve never set a password for your user account on OS X, you’ll need to do that first (the unix ‘passwd’ command, entered at the Terminal prompt, is a fast way to do this). It’s very easy to install homebrew, you just copy and paste one long command from homebrew’s web site into your Terminal window.

Once you’ve got Xcode and homebrew installed, you’re ready to install ffmpeg. I do so by pasting the following into the terminal window:

brew install ffmpeg --with-fdk-aac --with-ffplay --with-fontconfig --with-freetype --with-frei0r --with-libass --with-libbluray --with-libcaca --with-libquvi --with-libsoxr --with-libvidstab --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-openssl --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools --with-x265

That should all be one long line. Hit return, and brew will start downloading tool after tool, occasionally prompting you, and eventually installing ffmpeg. This may take a while, depending on the speed of your computer and the speed of your net connection. A half-hour wouldn’t be out of the ordinary. But when it’s done you’ll have an amazing multimedia swiss army knife at your disposal. I use ffmpeg for nearly all of my transcodes, even to watermark and transcode for upload to video distribution platforms.

Transcode your files with ffmpeg

Now that ffmpeg is installed, you can transcode your mkv file into dnxhd with one line of commands entered at the Terminal prompt. Here it is:

ffmpeg -i inputfilename.mkv -vf "scale=1920:1080" -vcodec dnxhd -r 23.976 -b:v 36M -c:a pcm_s16le -ar 48000 -ac 2 outputfilename.mov

For command-line newbies, I should point out that spaces are used as a special character to separate commands and their arguments. So if there are any spaces in your filename, or in any directory along the way to your file, they need to be typed in a special way (“escaped” with a  backslash in front of it, like “\ “) so that the Unix shell knows to interpret them as a space and not as a separator. There are other special characters too. The safest way to type the filename is to let the Terminal do it for you — just type “ffmpeg -i ” (don’t type the quotes, but do type the space after the i) and then drag your input file right into the Terminal window. It’ll type the whole path to the file into the Terminal, with all spaces and special characters properly escaped. So for this command, I do:

ffmpeg -i drag_in_mkv_file -vf "scale=1920:1080" -vcodec dnxhd -r 23.976 -b:v 36M -c:a pcm_s16le -ar 48000 -ac 2 drag_in_mkv_file_and_then_edit_its_name_to_end_in_mov

Hit enter, and ffmpeg do its thing. It’ll take the video from that mkv file, uprez it to 1080p if necessary, and output it as a DNxHD36 23.98 quicktime file with stereo 16-bit 48Khz audio. If that matches your Media Composer project’s settings, the video will fast-import. Unfortunately I haven’t yet nailed down the exact audio settings, so that audio will just do a normal and not fast-import (which means some conversion is happening during the import).

If the file you’re converting isn’t 23.98p, change that part of the command line to the appropriate frame rate. You’ll likely also need to change the bitrate. There’s a list of bitrates to use for different frame rates of dnxhd here (scroll down to the dnxhd section).

You can also convert your mkv or other files to prores using ffmpeg. For our blu-ray mkv file, a line like this should work:

ffmpeg -i inputfilename.mkv -vcodec prores -profile 2 -pix_fmt yuv422p10le -acodec pcm_s16le outputfilename.mov

That’ll make a Prores422 file with 16-bit audio. You can also do other types of Prores by changing the number after “-profile” to 0 for proxy, 1 for LT, or 3 for 422HQ.

In summary

Yes you can pull clips from DVD or Blu-ray and convert them into editable media without an intermediate transcode to mp4 – by losslessly ripping to mkv and then converting to Avid DNxHD or Prores using ffmpeg.

And if you get heavier into the command-line, you’ll find that it makes complicated scripting and batch processing pretty easy to do. So having a good command-line conversion tool becomes very powerful.

Fantastic new Star Wars trailer

Thursday, May 21st, 2015

Kudos to the VFX artist behind this new Star Wars Trailer.

Davinci Resolve 10 public beta is nifty

Tuesday, September 17th, 2013
I graded 1 a short documentary in Davinci Resolve 10 public beta yesterday, and figure I’d share a couple of observations in case they help others.

 A node tree in DaVinci Resolve
A node tree in DaVinci Resolve. In this example, node 1 is an overall adjustment to the shot, and then nodes 2 through 4 isolate and adjust different areas of the shot separately. In this case, since it’s a moving, handheld shot, the shapes in nodes 2-4 have been tracked to stick to parts of the shot. Resolve comes with an awesome and ridiculously-fast tracker.

  1. When I first launched Resolve 10, I noticed that it could see my Resolve 9 database, but said the database was not upgradeable and thus couldn’t be used. Oy, not good. I did want to carry my ongoing projects into Resolve 10. I did a bit of research, and decided maybe if I switched my Resolve 9 database from a PostgreSQL database to the other kind of database Resolve supports, a disk database, that maybe Resolve 10 would be able to use the data. So I reinstalled Resolve 9, created a disk database, selected it, and imported each of my Resolve 9 projects one by one (this took a while). I followed the procedure outlined in an unrelated post by Peter Chamberlain of Blackmagic on their forum:
    In the database manager you can make a new Disk Database. Then make that the active DB. In the Project Manager you can select the global list of databases and select your v9 projects to import to your new Disk DB.

    This worked. When I reinstalled and launched Resolve 10, it was able to use the disk database I’d created in Resolve 9. I don’t know if the steps I took will be necessary in future versions of Resolve 10 (and I’d hope they are not, and that either the app will be able to upgrade PostgreSQL databases to its format or convert them to disk db for you), but at least this is a method that works now.

  2. Resolve 10 brings with it some delightful new features — one can now apply unlimited numbers of shapes (or “power windows”, to use the world’s worst dumbest-sounding name for a shaped selection) to a node. Multiple circles and polygons affecting the effect of a single node, check! The new ‘gradient’ shape is great, though it does seem to render to screen more slowly than the other shapes. I was excited to try out the trial version of the NeatVideo OpenFX plugin for noise reduction, but though I could apply it to a node, I got a “no parameter is exposed to the user” when trying to use it. Hopefully NeatVideo or Blackmagic will get that working. Optical flow interpolation for speed changes sounded like a very cool thing, something I use all the time in After Effects, but I got some pretty weird results from it and it seemed to lack much in the way of tweakability.
  3. The program seemed to run with more speed and stability than Resolve 9. Just a subjective observation.
  4. It worked great with my Avid Artist Color / Euphonix MC Color control surface and Eucon 3.0, but would lose the connection to the control surface every time I switched applications or Resolve was pushed to the background by an alert from some other app. I posted to the Avid forum, and a rep got on the case very quickly. Hopefully this issue gets resolved 2 soon.
If you’ve been thinking of trying out Resolve, you might as well give it a look. It’s a pretty amazing application, and it’s fantastic that BlackMagic lets us all go to town with the barely-crippled “Lite” version for free 3

I’ll link to the documentary short when it’s online.

  1. Grading is the process of adjusting the images in a video or film. Bulk adjustments like brightness, contrast, gamma, saturation, and hue. Localized adjustments within shapes tracked to objects on screen, or limited by the color or brightness of objects in the shot. It’s basically like editing images in Photoshop, except these are moving images. Every feature film and TV program goes through the grading process these days, and by grading one can really spice up or bring out the beauty of the imagery, match shots to one another, give the whole piece a “look”, or just balance things out. It’s to filmmaking what darkroom artistry was for photographic pictures, back when people shot stills on film. ↩︎
  2. I did not intend this as a pun as a typed, but recognized it as I saw the word form. Groan if you must, I’m leaving it. ↩︎
  3. OK, maybe it’s not exactly free, since it’s an engine to drive sales of their video output hardware –the only way to display a true video output signal from the software. But their video output cards are solid. ↩︎

Now working on — We Are Men

Sunday, August 18th, 2013
I’m now working as assistant editor on the CBS half-hour comedy We Are Men, which will air this fall. The editorial team is comprised mostly of veterans from the film The Man with the Iron Fists. If you’re curious about the show, here’s a surprisingly comprehensive cutdown of the half-hour pilot episode 1:

It’s been a long time since I worked on a TV show, in fact my previous experience might not even count. Everything about that show was different. Travel with me back to Beijing, 2006, and feast your eyes on the promo piece I cut for NBA制造 2. This piece was used to sell the NBA-produced “basketball lifestyle” program to various provincial TV stations:

Man, that show was a challenge, as it featured many interview segments and I barely spoke any Mandarin at that point. My solution was to type in translations of everything as markers on each clip. Eventually I started understanding enough of the interview subjects to not have to look at every marker. The interesting thing about people’s speech is that it becomes possible to parse out the different blocks of meaning and cadences well enough to edit it even without perfect understanding.

But back to the new show; We Are Men will air Mondays at 8:30PM, starting on September 30, 2013. It’s exciting to be working on something with quick turnarounds that’ll actually be seen by the public within months or weeks of shooting. Most of the films on which I’ve worked featured more than a year of postproduction. It’s like being back in a newsroom, except we’re making a fictional comedy rather than rushing to cover breaking stories. It’s also fun working on a comedy, as whenever I pass either the writers room or the editor’s suite I hear plenty of laughter. It lightens the day.

  1. At 20% of its original length it ends up feeling very very hyper, an impression increased by the occasional whoosh transition –but it wouldn’t really be a promo piece if it were the same length and speed as the original. And we’re all raised on video games these days, right? It’d be fun to drop such a promo in front of tv-watchers of the late 50s and see if their heads explode from information overload. Blipverts! ↩︎
  2. literal translation: “Made In NBA”. A cute play on the phrase “Made In China”. ↩︎

Fitz and the Tantrums Video: “Out of my league”, crazy lo-fi 3D with Kinect and RGBDToolkit

Tuesday, April 23rd, 2013

Fitz and the Tantrums – Out of My League from Jordan Bahat on Vimeo.

My friend Jordan directed this music video for the band Fitz and the Tantrums (released on 4/22 on VH-1 and on the band’s web page and on vimeo in better quality), and I got to help plan and execute a technically unorthodox portion of the shoot. It’s a little odd for me to be involved on the production end of a project and to not work all the way through post-production (on films, post often lasts for more than a year) –but it was fun to shoot a bunch of stuff, hand it to the producer, and then see the final result weeks later. Now I know a little better how production folk must feel. Kudos to Jordan and producer Taylor for seeing the project through to the end.

A preview of the depth map as it was being recorded to a laptop during the shoot.
A preview of the depth map as it was being recorded to a laptop during the shoot. The different colors represent the depth at each point. Black spots represent holes in the data –areas in which no depth was recorded.
At around 30 seconds in, you’ll start to see the lo-fi 3D imagery I helped capture and visualize –point clouds and wire-mesh renditions of members of the band, rendered from various virtual camera positions.

The data was shot head-on from a fixed camera position 1, using a Canon 5DmkIII DSLR to capture video and a Microsoft Kinect sensor connected to a laptop to capture a video depth map. The DSLR and the Kinect were locked to one another with a 3D-printed mount. Jay Trautman 2 (thanks!) operated the laptop while I manned the DSLR.

The depth information for each pixel (or ‘D’) captured on the Kinect was recorded and later paired with the video info for that pixel (RGB) using a piece of free software 3 called RGBDToolkit. It’s fun to play with. If you’ve got a Kinect and a video camera, you might give it a try.

There were some even-more-ambitious 3D data capture techniques at play during the shoot, involving an array of kinects and cameras (thanks Cedric!), which I’ll talk about another time. The non-3D shots were also captured on a Red Epic camera by D.P. Andrew Wheeler and his team.

My cousin Jenny did some great storyboards for the video, if they make it into her portfolio I’ll link to ’em. A ton of other people worked on the video. I’ll link to the full credits soon if I can find them.

  1. i.e. the camera was locked into position using a tripod ↩︎
  2. I worked with him previously on The Man with the Iron Fists ↩︎
  3. free as in beer and as in “MIT license” ↩︎

The brief first flight and untimely end of my quadcopter

Thursday, January 3rd, 2013

Perhaps that title is a bit dramatic. As best I can tell, one of the engines is bad, shut down in flight, and then its pylon snapped free from the wing. The copter/plane is all patched back together now, and will be ready to fly again as soon as I receive a new motor and two replacement propellers.

Video was captured using a GoPro camera mounted to the Quadshot Mocha multicopter’s built-in tripod mount, and an 808 keychain camera #11 with D lens velcro’d to the Gopro (accidentally rotated to the vertical).

More to come.

Two deals on the Canon T3i, just for today

Monday, November 26th, 2012
People often ask me for recommendations for DSLRs with which they can shoot video. I think the Canon Rebel series of cameras (T2i, T3i, T4i) are the best bang-for-the-buck in that category. Today, perhaps in celebration of Ridiculous_Invented-name_Consumerism-holiday 1, a couple of very good deals on nice entry-level Canon DSLRs have popped up. I read about these deals on the site cheesycam, which is a site I would recommend to any budget-minded filmmaker who is looking to save money and can manage to not buy so many good deals as to render the idea of “saving money” a bad joke.

Deal 1: $499 for Canon T3i DSLR Kit (includes a lightweight and dim 18-55mm lens with built-in stabilization)

Deal 2: $669 for Canon T3i kit with 18-55mm kit lens and 2 additional lenses (55-250mm, 75-300mm). I tend not to recommend lenses that cover long ranges as there are so many design compromises that go into maximizing that range that other qualities of the lenses suffer, but in this case they come out to costing very little. If you don’t like them you could probably sell them on eBay afterward and cover a portion of the cost of the camera.

As far as I know, the video quality of the Canon T3i is identical to that of the T4i and T2i, and pretty indistinguishable from that of the 7D and 60D. If you need such a thing, both of the deals listed above seem pretty good to me.

  1. “Cyber Monday”, ew. ↩︎

The Curious Case of Benjamin Button Blu-ray is very cheap at Amazon

Monday, November 19th, 2012

It’s not every day I see a film I’ve worked on listed on the Fatwallet Hot Deals forum as a hot deal. But today’s that day.

Assuming the deal lasts at least until this link is clicked, Amazon’s selling The Curious Case Of Benjamin Button (The Criterion Collection) [Blu-ray] for $5.99. That’s a two-disc set full of tons of extras. Even if you’re just technically-minded, those extras alone are worth the cost, as it’s fun to see how the tons of VFX shots were executed. I’m not just talking about the head replacement –the boat floated in an impressive CG sea, actors were aged and youthened, foreign and domestic locations stood in for one another. Lots of groundbreaking VFX.

I’d previously posted when the film was at Amazon for $14.99 back in late ’09. I don’t really understand how film retaling works, I’d love to see a graph of its pricing over time, I wonder if this is a normal price decrease or if they’re hoping to spike Christmas sales.

Regardless the reason, this is a good deal. I think the DVD’s $1.99. But if you can play Blu-ray, go that route. It’s a great-looking film.

A collected list of links to Blackmagic’s CEO’s camera shipping updates

Friday, November 16th, 2012

Here’s a table of links to all of Blackmagic CEO Grant Petty’s posts to his company’s forums regarding the Blackmagic Cinema Camera‘s manufacturing delays. Apart from the whole “you’re not getting your camera yet” part, they’re a fun read; the sort of engineering details one gets access to as a backer of a kickstarter project. I found the 11/7 update to be full of particularly interesting details.

9/25/12 Update on Camera Shipments
10/19/12 Camera Shipping Update: 10/19
10/29/12 Camera Shipping Update: 10/29
11/7/12 Camera Shipping Update: 11/7
11/15/12 Camera Shipping Update: 11/15
12/14/12 Camera Shipping Update: 12/14

recent 3d prints: gopro naked housing, panelolu LCD panel housing

Tuesday, November 6th, 2012
3d-printed gopro housing
This naked gopro housing fit perfectly on the various gopro mounts. I need to modify the design to get it to better fit the gopro with Wifi Bacpac attached.
LCD panel and control housing for reprap
LCD panel in progress to control my printrbot+ without a computer.