I began to care about this after we started showing music videos at DNA Pizza. It turns out that a lot of the videos in my collection are 640x480 with letterboxing, which, when you display it on a 16:9 TV, looks like:
That's annoying, so I'm going through and re-encoding a bunch of things when I can't find better copies of them to download.
Even with this script, it's still a distressingly manual process, because:
- mplayer is hella flaky, so the script fails a lot;
- MPEG Streamclip isn't scriptable, so I can't even automatically fill in the crop numbers;
- I don't know how to bulk-copy all of the metadata from one MOV file to another;
- There's no easy way to replace a file in iTunes and have the new version show up in all the same playlists, have the same ratings, etc. as the old file. (If you just overwrite the file, the lack of metadata is a problem (see point 3) and if an MP4 became a MOV, you'd be out of luck anyway since the file can't have the same name.)
It's not easy being an obsessive archivist. People don't even know.
Update: resize.pl does this more and better.
You can use HandbrakeCLI instead of MPEG Streamclip to crop and encode, and because it's just a command line tool you can script the fuck out of it.
Oh, also, it can automatically detect and crop the bounding box, as long as you know "this video needs cropping", it can figure out the rest on its own.
Oh. Sweet!
Just gotta say,I *love* handbrake.
I'm not sure about .mov but Atomic Parsley can do lots of fun stuff with .mp4 tags
I tried to use that once and A) it only does MP4, not MOV, and B) it was a huge pain in the ass and I couldn't get it to do anything anyway.
Ah, fair enough... I use it alongside get_iplayer to tag .m4a and .mp4 downloads.
Also, ffmpeg is CLI and has aspect ratio correction and cropping options
I have found that the less I try to do with either ffmpeg or mplayer, the happier I am. They are both fantastically flaky and hostile.
It's not easy being an obsessive archivist. People don't even know.
Every time I read something like this of yours I get a horrible, sinking feeling of guilt over having thrown away a collection of around one thousand floppy disks that I amassed in the early-to-mid nineties.
Feel a little better - by the time you would have realized you wanted an autoloader (and these in fact existed in 'desktop' form as a sort of clamp-on thing), you'd find out they stopped making that variety and the closest thing available would be massive surplus duplicators on eBay that might or might not actually have a convenient way to actually get data out to a computer with a HD.
And that data duplication firms have been tooled up for nothing but CDs since like 1999, apparently, because "I have a box of 300 floppies and want them dumped on a CD" has apparently not been a common request. (Well, I started looking late, in 2006 or so.)
These were a mix of old Mac and PC/DOS floppies, for which I was unable to locate any single piece of hardware that was capable of reading both. Some of the later model Macs with floppy drives could do PC disks, but getting a hold of one for this project turned out to be logistically impossible.
I did look into a few companies circa 2002 that still did the floppy-to-CD thing, but the price they charged was significantly more than sane. Something on the order of a dollar or more per floppy, if I recall correctly.
It turned out to be far easier and cheaper to just assume the disks contained only low-res porn and throw them away. I do still feel the guilt though.
I thank you, my music video collection thanks you, and my friends thank -- you for putting an end to the stream of disruptive expletives I spout when I start to play some hardcoded-letterboxed video.
I wonder how repeatably I can 'script' MPEG Streamclip by shoving clicks and typing at the UI. Sucky, but then again, the whole situation is a bit sucky.
AAAaaaand of course nothing automated helps with crap like the video-noise at the top (or bottom) of videos like this Bodyrock (Sunglasses version) video. Nevertheless, some help is better than none, and I can do the outliers by hand.
Mostly you can deal with that by tweaking $xoff, $yoff at line 80.
Thanks. I was just tinkering with those values. At 10, or even 20, it still mis-interprets the noisy-black area as real content. I'll try upping the blur and fuzz next.
HandbrakeCLI does appear saner for the cropping etc.
However, from the just-push-the-car-back-onto-the-road-and-try-again-dept, If I give HandbrakeCLI the crop values from video-bbox.pl, it crops as requested (which, again, for this copy of the Bodyrock video, isn't enough or right). Fine. Then if I ask HandbrakeCLI to autocrop the file it just generated and make a NEW one, it finds some more black to crop. It ALSO finds some more if you ask it AGAIN. After three passes, it can't find any more, but the video still isn't actually cropped right.
I think the solution is to do this particular video by hand, and do the rest of my videos automatedly with video-bbox + HandbrakeCLI. Not worth trying to make it 100.0% automated, when 99.5% will do, and it's mostly a one-time conversion effort.
What do you use for 'video jukebox' software? Still just iTunes? I sometimes try to fight it out with Cellulo, but mostly that makes me want to write my own, which is always a bad sign and usually a worse idea.
Yeah, some you just have to do by hand. You can get the proper crop values manually by taking a screen shot, or just try "Preview" until you get it right. Re-encoding multiple times is crazy.
I still use iTunes.
HandbrakeCLI seems to be a saner solution for this than MPEG Streamclip (and I think it's faster, too). I'm using these settings to auto-crop:
HandbrakeCLI --encoder x264 --quality 17.75 --previews 30 --loose-anamorphic --modulus 16 -O -i $in -o $out
Now -- since iTunes started ignoring the "Stop Time" option -- I'm pondering a way to flag videos that have N seconds of silent audio at the end, to detect those that have long credit-crawls after the music.
# Extract audio somehow
mplayer -really-quiet -vc null -vo null -ao pcm:fast:file=video.wav video.mp4
# Resample to 10Hz with maximum aliasing
sox video.wav -t ub -c 1 -r 10 video.ub rate -q
# Estimate the length of the quiet time at the end
perl -le '$_=<STDIN>; /([\x07f-\x81]*)$/; print length($1)/10' < video.ub
That Perl is some mad science.
I do have this which could be adapted, but, you know, that'd be work.
I've recently used mp3splt's "-s" (locate periods of configurably-defined silence) option for scripted silence detection and location ... in MP3 files ... which isn't what we were talking about here: video.
Still, a workflow with this might be a (good) alternative to jone's mplayer|sox|perl thing, much as I do love the 8-bit silence detection code. E.g., ffmpeg -i video.mp4 temp.mp3; mp3splt -s temp.mp3; parse and act on the nice "mp3splt.log" file that is generated.
Using a regexp to parse audio data? Now I've seen everything.
Not to mention jone now has two problems.
/you-knew-this-was-coming
"It's not easy being an obsessive archivist. People don't even know."
this librarian expresses her gratitude. bless you.
It's not easy being an obsessive archivist. People don't even know.
I know, and I sympathise. But I swear, no one else does.
I'm glad others have recommended Handbrake, much better than MPEG Streamclip.
Re: the iTunes mess, when you delete a file, but do not remove it from iTunes db, next time you try to access the item in iTunes, it will mark it with (!) and alert you that it cannot find the file, and would you like to locate it now (manually). This method, being manual and shitty as it is, does preserve metadata and playlists -- though I've only ever tried it with audio (I used it to switch out old mp3s with better quality rips).
Best of luck.