Sunday, December 23, 2012

Proposed Handbrake improvement.

I've been busy ripping DVDs from my collection and I've run into an improvement for handbrake.

While converting TV episodes on DVD, I wanted to autoname the new file using output pattern S01-E0{title+offset}  like {title+5} for disc 2 in a DVD set where the title-1 is episode 6.

Handbrake - HandBrake is an open-source, GPL-licensed, multiplatform, multithreaded video transcoder, available for MacOS X, Linux and Windows

So I downloaded the codebase and found where in Windows code tree auto naming occurs.  HandBrakeCS its in Main.cs and Handbreake WPF autoNameHelper.cs

I have this code compiled and working locally great!

Now a commentary:

Dear SourceForge:

You have to be kidding! Separate logins for main site and forums site.  What is going on?
SourceForge also give lip service only to OpenID.  I initially created my user account with OpenID and  only to find I have limited permissions and I would need to create 'real' account to do anything useful.

SourceForge your site is terrible and I would recommend handbrake moving to another open source hosting site.

destinationFilename = UserSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat);

                    //Add ability to auto name file using {title-offset} or {title+offset}
                    // example {title-1} or {title+3]
                    // This is extremely useful when ripping DVD of tv show episodes.
                    #region AutoName based on {title-offset} or {title+offset}

                    int startPos = 0;
                    int stopPos = 0;
                    string offsetTag;
                    var iDvdTitle = Convert.ToInt32(dvdTitle);

                    if (destinationFilename.Contains("{title-"))
                    {
                        offsetTag = "{title-";
                        startPos = destinationFilename.IndexOf(offsetTag, StringComparison.InvariantCulture);
                        stopPos = destinationFilename.IndexOf("}", startPos, StringComparison.InvariantCulture);
                        string tag = destinationFilename.Substring(startPos, stopPos - startPos + 1);
                        string offset = destinationFilename.Substring(startPos + offsetTag.Length, stopPos - startPos - offsetTag.Length);
                        int iOffset = 0;
                        try
                        {
                            iOffset = Convert.ToInt32(offset);
                        }
                        catch { }
                        destinationFilename = destinationFilename.Replace(tag, (iDvdTitle - iOffset).ToString(CultureInfo.InvariantCulture));

                    }

                    if (destinationFilename.Contains("{title+"))
                    {
                        offsetTag = "{title+";

                        startPos = destinationFilename.IndexOf(offsetTag, StringComparison.InvariantCulture);
                        stopPos = destinationFilename.IndexOf("}", startPos, StringComparison.InvariantCulture);
                        string tag = destinationFilename.Substring(startPos, stopPos - startPos + 1);
                        string offset = destinationFilename.Substring(startPos + offsetTag.Length, stopPos - startPos - offsetTag.Length);
                        int iOffset = 0;
                        try
                        {
                            iOffset = Convert.ToInt32(offset);
                        }
                        catch { }
                        destinationFilename = destinationFilename.Replace(tag, (iDvdTitle + iOffset).ToString(CultureInfo.InvariantCulture));

No comments:

Post a Comment