• Most new users don't bother reading our rules. Here's the one that is ignored almost immediately upon signup: DO NOT ASK FOR FANEDIT LINKS PUBLICLY. First, read the FAQ. Seriously. What you want is there. You can also send a message to the editor. If that doesn't work THEN post in the Trade & Request forum. Anywhere else and it will be deleted and an infraction will be issued.
  • If this is your first time here please read our FAQ and Rules pages. They have some useful information that will get us all off on the right foot, especially our Own the Source rule. If you do not understand any of these rules send a private message to one of our staff for further details.
  • Please read our Rules & Guidelines

MPEG Streamclip not BFF with MKV

ssj

Well-known member
Donor
Faneditor
Messages
3,883
Reaction score
2
Trophy Points
53
Next project: Turning a movie that's dear to my heart into something profane and absurd. I'm going to give Crouching Tiger, Hidden Dragon the Tiger Lily treatment via subtitles.

The bulk of my efforts will go to creating what I hope will be entertaining subs, but first, I need to pare down the running time, preferably with free tools. I want to keep the editing simple--i.e., without having to edit audio--so the cuts occur when there's no music playing in the background.

Here's been my trial-and-error experience so far:

Source: an HD, 1920 x 800 mkv file, 2.77GB in size on OS 10.4.11 (2.98GB per Snow Leopard). Doesn’t play properly in QuickTime, but plays just dandily via MPlayer and VLC; also looks smashing on my Samsung TV. C'mon, Apple—get with it.

Tried loading the mkv file into MPEG Streamclip (MPEGSC), which pleaded no contest to file type, but then proceeded to load the file anyway, albeit with the time markers all incorrect. Also, when playing back video, only a second of audio could be heard, then there was silence. Every time the video was paused and resumed, about a second of audio would play. No biggie. Most important, I could still edit video by identifying scene start and end frames, and Streamclip was superstable—I hadn't a single crash.

One of the idiosyncrasies of MPEGSC: when selecting a clip to cut, the first frame (IN) to select is obvious. However, selecting the last frame (OUT) of the selection will leave that last frame untouched; one has to select the following frame to remove the desired clip in its entirety.

In preferences, I opted to have only one audio track exported; I have no need for the English soundtrack.

Once I edited out about 26 minutes from the mkv file, I was ready to export the result to mp4. The time markers, though, indicate the movie is about 5:13:40 long, when it should only be about 94 minutes. That won't bother me if the encoding comes out straight. (Both Perian and MPEGSC inhabit the same hard drive, but they obviously aren't playing in the same sandbox.)

Still waiting on the encode. As I chronicle this, I'm almost 24 hours into the encoding on my iMac, but the dialogue box says I'm only 63% of the way there. That means it'll take about 36 fucking hours to complete the encoding, assuming there's no second pass. Perhaps I should've chosen a lower file target size. (I went with ~8GB, since the lower file sizes had ridiculously low bit rates for an HD file, though in retrospect the bit rate might have been declared low because of the time marker goofiness.)

While awaiting the MPEGSC encoding, I did some research and found that QuickTime and Handbrake could export MKV to mp4, and neither would take that long. Quicktime could also perform simple cuts. On the MacBook Pro, I now have Handbrake cooking up an encode (target 3.6GB = ~3900 kbps for video; 6-channel surround was reduced to 256 kbps Dolby Prologic II, in case 6-channel surround was gumming up the QuickTime playback), and the conversion will take about five hours—a burp and a fart compared to the MPEG Streamclip grind. If the MPEGSC export turns out damaged (e.g., extra frames, persistence of goofy time markers, etc.), then I'll simply use the Handbrake-generated mp4 file for editing.

The HB encoding target of 3.6GB is obviously larger than the source file, but by shooting for a larger file size, I'll hopefully have very little loss in resolution from the mkv file. (Loss of resolution from original Blu-ray to mkv is a different matter, but I'm content to work with HD lite—beats standard def any day.) Also, the 3.6GB size falls under that narsty, narsty 4GB limit for MS-DOS formatted hard drives and memory cards.

Whether I work with an 8GB or 3.6GB file, my plan is to have the final encode (with burnt-in subtitles) weigh in at a reasonable 2 to 2.5GB.
 

theslime

Well-known member
Messages
1,234
Reaction score
1
Trophy Points
41
Sorry I didn't read the whole thing, but if you have an Intel Mac you really should upgrade your OS. Whereas on Windows XP you can still do pretty much anything, Apple (and even most third-party developers) have always had the planned obsolence approach to OS development, and Tiger is now utterly crippled. I have Snow Leopard, and I estimate that a good 90 percent of my programmes require Leopard or higher.

Also, QuickTime is like Windows media player. It doesn't play anything unless it's augmented by codec packs. On Windows there's K-Lite. On OSX there's Perian.
 

ssj

Well-known member
Donor
Faneditor
Messages
3,883
Reaction score
2
Trophy Points
53
Thanks for the suggs, Slime.

One machine runs 10.4.11, the other Snow Leopard. Perian is on both, but even so, QuickTime has a hard time with MKV files that carry surround audio.

I prefer to keep one machine with 10.4.11, because--this is key--I haven't tested whether Neverwinter Nights and Baldur's Gate II and Icewind Dale work on 10.5/10.6 :oops:

As for the encoding, screw me--MPEGSC is making a second pass, so digestion'll take roughly 72 hours. And I have no guarantees that the end product will be a usable file. So goes the learning process.

Handbrake delivered a beautiful mp4, but that's an unedited file. I'll chop that if MPEGSC doesn't deliver.
 

L8wrtr

Well-known member
Faneditor
Messages
3,355
Reaction score
281
Trophy Points
108
I'm not sure if Thunderclap is following this thread, but you may also want to PM him directly, I know he's ventured into this territory before (but his normal workflow is to edit his HD in PC mode rather than OSX) but I believe he wrote up the rather insane way you get working MKV files for editing on a Mac.
 

ssj

Well-known member
Donor
Faneditor
Messages
3,883
Reaction score
2
Trophy Points
53
Cool. Thanks, L8. I'll dig up his old thread and read it before bugging him.

Within a day, my MPEGSC MKV to mp4 conversion should be complete, so I'll know whether it was all for naught--except that others can learn from my experience.

Although I've had problems with Avidemux before, I'll try using it again to pare down the HB-produced mp4 file, if MPEGSC fails to deliver.

Edit: I seem to have found the thread; now let's see if I can get my brain around it. Will link here for future reference:
http://www.fanedit.org/forums/showt...l-Cut-w-No-quality-loss&highlight=thunderclap
 

ssj

Well-known member
Donor
Faneditor
Messages
3,883
Reaction score
2
Trophy Points
53
Otay, the MKV file was causing problems for both MPEGSC and QT via corrupt time markers, which made the movie seem about 3.5x longer than it actually was. Also, I foolishly selected multipass for the encode, so it was going to take an insane 130 hours for four passes. I'z couldn't takes it no more, so I smacked the STOP button at about 116 hours--yeah, i know, what took me so long. . . .

Proceeded to mess with the Handbrake-encoded mp4 file, and it worked beautifully. No audio issues during editing. Had to re-edit the entire movie in MPEGSC, but my cuts were very simple and could be redone in about an hour. I had the movie down to ~94 minutes, and a 5 Mbps encoding without multipass took about six hours.

The MPEGSC-encoded edit played well without any A/V sync issues or snaps/crackles/pops. Most of the spliced scenes melded together nicely, and in the couple places where the cuts weren't pleasing to the eye, the fault was my own. (Back to the chopping block for those couple scenes.)

The Handbrake mp4 offering was a bit dark, and the volume a bit low; MPEGSC allowed me to adjust, prior to encoding, picture brightness and sound volume.

Summaries:
1) MKV to mp4 via Handbrake; mp4 to edited mp4 via MPEGSC.
2) MPEGSC proved to be a powerful tool for simple cutting. The encoding options include multiple formats and some basic audio/visual adjustments. Pretty good for freeware.
 

geminigod

Well-known member
Faneditor
Messages
2,389
Reaction score
1
Trophy Points
46
theslime said:
Sorry I didn't read the whole thing.

Lol. Yeah, I couldn't quite make it either. :p But ditto everything else theslime said too!

Also glad you worked out your encoding problem. Now don't ever do it again. The thought of that transcode and file size 4x as large as the source will give me nightmares tonight.

Oh, and the reason why QT won't play nice with MKV is because apple doesn't recognize mkv. Remember the good ole days when everyone was on PC's and apple was the pioneers of computer multimedia? Well they're gone. But at least all of apple's shit codecs are proprietary. Sorry, this late hour is making me punchy. What I meant to say is Apple is the greatest! And Windows sucks!
 

theslime

Well-known member
Messages
1,234
Reaction score
1
Trophy Points
41
This might be a daft question, but have you tried a simple remux of the MKV into MOV with ffmpeg? Often Mac/QuickTime has problems with the container, but not the actual encoder used. On my mac not even VLC can play my Panasonic camcorder output, but once I quickly remux (i.e. not even reencode) the file, Bob's my uncle.

I recommend the newest macports build, but if you have Tiger, you might have to go with FfmpegX as it uses a Tiger-compatible ffmpeg build (or the just use the latest unstable Fink build for Tiger.

Then use a Terminal window and write:
Code:
ffmpeg -i FILE.mkv -acodec copy -vcodec copy NEW_FILE.mov

If that doesn't work, you can try the same, only end it with NEW_FILE.mp4 instead.

This comment is probably a couple of days late, sorry. :)
 

ssj

Well-known member
Donor
Faneditor
Messages
3,883
Reaction score
2
Trophy Points
53
No worries, slime; appreciate the suggestions, despite my longwindedness. The newest Handbrake build under Snow Leopard did an awesome job converting an MKV into an mp4.
 

theslime

Well-known member
Messages
1,234
Reaction score
1
Trophy Points
41
Handbrake is indeed awesome, but the thing is that Handbrake re-encodes/transcodes while that Ffmpeg command only remuxes - i.e. keeps the source completely identical. Also, there's no quality loss included. (While the quality loss of Handbrake is negligible, it's still there.)

A re-encode will typically take about a 100 times longer than a remux. No exaggeration. Remuxing a 100 megabyte 720p x264/MTS file into an mp4 took me less than one minute. A 3gb file should take about ten minutes.
 

geminigod

Well-known member
Faneditor
Messages
2,389
Reaction score
1
Trophy Points
46
What theslime is trying to say is that based on your described workflow, you probably never needed to re-encode it at all. There are elementary video files and there are containers. The two types are easily confused. mp4 and mkv are containers that contain within them a video and an audio file. So probably all you needed to do was pull the video out of one container and import into your editing app, or stick it into a different container like mp4 that your editing app can work with.
 

geminigod

Well-known member
Faneditor
Messages
2,389
Reaction score
1
Trophy Points
46
Its all good so long as you are happy with what you have. Live and learn.
 

ssj

Well-known member
Donor
Faneditor
Messages
3,883
Reaction score
2
Trophy Points
53
>Light bulb going off<

Thanks, slime & gem; I get it. I didn't know one could extract the video straight out of the MKV container. Cool maneuver, but is there a way to do that without command lines--in either OS 10.4 or 10.6? Macports seems to be a command-line-driven tool.
 

theslime

Well-known member
Messages
1,234
Reaction score
1
Trophy Points
41
MKVtoolNIX is good, but that will only give you a video file plus a sound file. You also need something to remux it as something OSX-compatible (MOV/M4V/MP4). Especially for Tiger, good GUI frontends are hard to come by. I have no idea how you would go about to even attempt this. QuickTime Pro, possibly, but it's a waste of money when there are free tools that are better.

Command line isn't as hard as you would think. You can pretty much google search for the commands you need in each case. I don't know Ffmpeg by heart myself - I search for the commands I need. Using 20 minutes to find the correct command may be annoying, but the 10 hours (more for HD content) you save makes it totally worth it.

You use either Macports or Fink. They are packaging/source tools for OSX that automate builds from the latest sources for you (i.e. they basically compile the ffmpeg sources (codecs and whatnot) into a usable application while you sit back and relax). I prefer Macports since I'm used to it, but both are available on Tiger and both come with frontends for installing the applications you need. I know the Fink Ffmpeg build for Tiger works, so I suggest that version. To say Macports/Fink is command line is only partly true. They both come with graphical frontends, and both contain loads of applications that result in a GUI experience, like, say, Gimp or Inkscape. Sadly, Ffmpeg does not come in a GUI experience apart from the badly outdated and incomplete FfmpegX.

Recipe for success:
- Install Apple XCode from your original OSX installation disc (or find it on the web). You don't actually use it, but Macports and Fink use it as a framework.
- Install the Fink for Tiger .DMG file.
- Install the FinkCommander graphical frontend
- Choose ffmpeg unstable version 0.6 or higher (don't let unstable fool you, it's safe)
- Then open a Terminal window. Navigate to where you keep your MKV file by "cd .." and "cd FOLDER".
- When you're in the right spot, type the ffmpeg command above. Voilà!
 

theslime

Well-known member
Messages
1,234
Reaction score
1
Trophy Points
41
And let me repeat the key benefits of this method: :)

- Lossless. (Even high quality Handbrake settings result in loss, This does not.)
- Processes about 500 megabytes per minute or faster (i.e. ridiculously faster than transcoding the video).
 

ssj

Well-known member
Donor
Faneditor
Messages
3,883
Reaction score
2
Trophy Points
53
Gnarly gnowledge. Thanks, stank & slime. I'll give this a spin.
 

ssj

Well-known member
Donor
Faneditor
Messages
3,883
Reaction score
2
Trophy Points
53
photostream
for all (four:oops:) of you reading this thread, here's a sneak preview:

photostream
 

ssj

Well-known member
Donor
Faneditor
Messages
3,883
Reaction score
2
Trophy Points
53
otay, a more mubi-like preview/excerpt for those visiting this obscure nether thread:


work to be done:
*hammer out plenty more subs. ain't anywhere near done.
*constantly edit subs--tighten wording, up the absurdity a notch, etc.
*decrease image brightness a bit.
*find a free vid editing program that properly uses .ass and .ssa subs. current program (Submerge by bitfield) doesn't properly differentiate italicized text or text of different sizes. might have to migrate to windows for this part, unless a kind soul here has a suggestion.
*satisfyingly squeeze out a 1920x800 encoding.

edit: drats and dagnabbit. youtube jacked up the sound sync. (no problems with the source mp4.)
edit: deleted the video. messed up sound simply isn't acceptable. will try to UL an .avi file.
edit: avi didn't work. but mp4-to-flv conversion did.
 
Top Bottom