SnorreSelmer wrote:
Thanks a lot to ronnor for getting me started on this.
Now we could just use a few command-line options for maximum length, minimum length and input folder (and maybe even output folder).
Maybe something like:
-s "shorter than x minutes"
-l "longer than x minutes"
-i "input-folder"
-o "output-folder"
Actually, the "shorter than" and "longer than" setting shouldn't be necessary. I've been working on parsing the output from the "-t 0" option with perl, and I have something that seems to work now. I probably have to test it on a few more DVDs to make sure it works every time, though.
Anyway - as far as I understand, the shorter/longer than option is desired as a way to pick individual episodes from a TV-series. But, since most TV DVDs include a play all option, you can actually use the longest title to find the individual episodes.
Have look at these titles and chapters from a DVD:
+ title 1:
+ chapters:
+ 1: cells 0->0, 36725 blocks, duration 00:01:28
+ 2: cells 1->1, 239064 blocks, duration 00:11:21
+ 3: cells 2->2, 171542 blocks, duration 00:08:46
+ 4: cells 3->3, 196490 blocks, duration 00:09:42
+ 5: cells 4->4, 257910 blocks, duration 00:12:55
+ 6: cells 5->5, 10099 blocks, duration 00:00:46
+ 7: cells 6->6, 178 blocks, duration 00:00:01
+ title 2:
+ chapters:
+ 1: cells 0->0, 37217 blocks, duration 00:01:28
+ 2: cells 1->1, 130575 blocks, duration 00:06:13
+ 3: cells 2->2, 124021 blocks, duration 00:06:18
+ 4: cells 3->3, 188030 blocks, duration 00:09:17
+ 5: cells 4->4, 134835 blocks, duration 00:06:47
+ 6: cells 5->5, 288224 blocks, duration 00:14:19
+ 7: cells 6->6, 10198 blocks, duration 00:00:46
+ 8: cells 7->7, 178 blocks, duration 00:00:01
+ title 3:
+ chapters:
+ 1: cells 0->0, 36964 blocks, duration 00:01:29
+ 2: cells 1->1, 172055 blocks, duration 00:09:06
+ 3: cells 2->2, 208151 blocks, duration 00:10:00
+ 4: cells 3->3, 251951 blocks, duration 00:12:11
+ 5: cells 4->4, 241960 blocks, duration 00:11:52
+ 6: cells 5->5, 10052 blocks, duration 00:00:46
+ 7: cells 6->6, 178 blocks, duration 00:00:01
+ title 4:
+ chapters:
+ 1: cells 0->0, 36990 blocks, duration 00:01:28
+ 2: cells 1->1, 145986 blocks, duration 00:07:28
+ 3: cells 2->2, 122029 blocks, duration 00:06:26
+ 4: cells 3->3, 215773 blocks, duration 00:10:29
+ 5: cells 4->4, 386394 blocks, duration 00:18:51
+ 6: cells 5->5, 9889 blocks, duration 00:00:45
+ title 5:
+ chapters:
+ 1: cells 0->0, 36725 blocks, duration 00:01:28
+ 2: cells 1->1, 239064 blocks, duration 00:11:21
+ 3: cells 2->2, 171542 blocks, duration 00:08:46
+ 4: cells 3->3, 196490 blocks, duration 00:09:42
+ 5: cells 4->4, 257910 blocks, duration 00:12:56
+ 6: cells 5->5, 10099 blocks, duration 00:00:46
+ 7: cells 6->6, 37217 blocks, duration 00:01:28
+ 8: cells 7->7, 130575 blocks, duration 00:06:13
+ 9: cells 8->8, 124021 blocks, duration 00:06:18
+ 10: cells 9->9, 188030 blocks, duration 00:09:17
+ 11: cells 10->10, 134835 blocks, duration 00:06:47
+ 12: cells 11->11, 288224 blocks, duration 00:14:20
+ 13: cells 12->12, 10198 blocks, duration 00:00:46
+ 14: cells 13->13, 36964 blocks, duration 00:01:29
+ 15: cells 14->14, 172055 blocks, duration 00:09:06
+ 16: cells 15->15, 208151 blocks, duration 00:10:00
+ 17: cells 16->16, 251951 blocks, duration 00:12:11
+ 18: cells 17->17, 241960 blocks, duration 00:11:53
+ 19: cells 18->18, 10052 blocks, duration 00:00:46
+ 20: cells 19->19, 36990 blocks, duration 00:01:28
+ 21: cells 20->20, 145986 blocks, duration 00:07:28
+ 22: cells 21->21, 122029 blocks, duration 00:06:26
+ 23: cells 22->22, 215773 blocks, duration 00:10:29
+ 24: cells 23->23, 386394 blocks, duration 00:18:51
+ 25: cells 24->24, 9889 blocks, duration 00:00:45
The longest title is title 5, and every chapter in that title can be found in other titles as well. By looking at the block count of each chapter in the longest title, you can search through the other titles and see if you can find a title where all chapters (except perhaps the last) are included in the main title. This seems like a very good way of identifying the individual episodes and their order.
This might be a bit tricky to do in a shell script, though, which is why I made an effort to use perl to parse the output.
I'm also trying to automate cropping. Handbrake's autocropping is great for getting rid of the black bars, but I'm mostly encoding for the PSP, and I think the screen is a bit too small for 2.35:1 or 4:3 videos. So I've decided to shave a little bit off the sides or top and bottom from these videos. Not so much that the video fills the screen (that would sacrifice too much of the picture), though. Normally I aim for a 2:1 aspect ratio for the 2.35:1 movies (480x240 pixels) and 1.53:1 for the 4:3 videos (416x272 pixels).
I think I'm getting pretty close to getting a working script now. I basically have all the parts I need, I just need to put it all together.