• AnyStream is having some DRM issues currently, Netflix is not available in HD for the time being.
    Situations like this will always happen with AnyStream: streaming providers are continuously improving their countermeasures while we try to catch up, it's an ongoing cat-and-mouse game. Please be patient and don't flood our support or forum with requests, we are working on it 24/7 to get it resolved. Thank you.

Writing Your Own Tools

DrXenos

Well-Known Member
Thread Starter
Joined
Jun 6, 2014
Messages
1,054
Likes
853
Does anyone else enjoy writing their own tools? I love doing so because I can tweak it just for me, and have whatever options and features I want.

I just updated my GUI media transcoder which handles all my transcoder jobs. I added a really neat feature I haven't seen anywhere else. When the power goes out, it will automatically pause all running jobs as to not drain the UPS' battery. When the power comes back up, it will resume all the paused jobs.

Just thought it was neat...

DrX
 
Does anyone else enjoy writing their own tools? I love doing so because I can tweak it just for me, and have whatever options and features I want.

I just updated my GUI media transcoder which handles all my transcoder jobs. I added a really neat feature I haven't seen anywhere else. When the power goes out, it will automatically pause all running jobs as to not drain the UPS' battery. When the power comes back up, it will resume all the paused jobs.

Just thought it was neat...

DrX
Very cool Doc, assuming everyone has a UPS. And you are correct, I have not seen that anyplace else. I assume you have this patent pending. :cautious:
 
Very cool Doc, assuming everyone has a UPS. And you are correct, I have not seen that anyplace else. I assume you have this patent pending. :cautious:

HAHA. No, actually, I'm much against so-call intellectual property, especially software patents.
 
HAHA. No, actually, I'm much against so-call intellectual property, especially software patents.
Software patents are almost impossible to enforce. If you make a great program and you patent the code. Someone will just reverse engineer that code and call it a different name and voila, guess what. I remember when Sun Micro used to patent their update systems, they went to court for years and lost. It's not that easy to patent anything that is software.
 
I might would like to write something myself, but I don't understand code (or tried to learn it).
But your tool looks nice.
 
Spend my holiday vacation adding a neat feature to my transcoder. Here's the scenario: I'm in the middle of transcoding a bunch of files, when I get a new Blu-ray in the mail that I want to watch tonight. I could just add it to the queue as the very next item, but I want to start it now to ensure it finishes in time. Normally, I would just pause the current item, start the new stuff, and when it's done, resume the previous job. But I don't like having to keep checking its progress in order to resume as soon as possible and not waste any time.

So, I added a priority flag to the items' option menu. If I mark a title or task as a priority, a currently running, non-priority job is paused (preempted), the priority task (and all the tasks in the same title) are executed in order. When there are no more priority tasks, the preempted one is resumed automatically.

Below is a screenshot of it running a test (I have a "test" job type, where I can specify such things as how long it runs, when/if it fails, etc.). In the test, the first task of the first title was running. I marked the 4th task of the 5th title as a priority as indicated by the orange dot in its status icon (by inheritance its title and sibling tasks also become a priority). The running job is preempted and paused, and the 1st task of title 5 is started (because all tasks under the same title are executed in order). When all the tasks in title 5 have completed, the preempted job will be resumed.

This process also works if I increase the max. number of concurrent processes (which is currently at 1). If it were set to 2, the first task of titles 1 and 2 would have been running and one of them would have gotten preempted, while the other continued on.

tc.jpg
 
I just ran into another issue that reinforces why I like having my own tools. As I may have said before (I'm lucky I can remember yesterday), my main goal in processing DVDs and Blu-rays for transcoding is to preserve all the information gleaned from analyzing them to determine what needs to be done. Then, years later, if I need/want to retranscode them, it's all recorded.

To facilitate this, years ago a wrote a scripting language specifically tailored to manipulating and processing audio/video files. It divides the processing in to two time phases, now and later. Steps to be done immediately are in the now category. Steps to be done later generate queue entries for my GUI tool I've explained above. Stuff designated "later" are things that either take a long time, like transcoding, or must happen after transcoding.

The scripting engine handles all the laborious steps involved in creating the resultant media files that go on my NAS. A common example is when the commentary tracks on the disc are put into a separate title from the normal audio. Keeping both titles is a waste of time and space, as the only difference is the audio tracks. I use to have to extract both titles from the disc, extract the commentary audio from the one, and mux it into the other (imagine doing an entire TV series of this!). With my tool, I simply give it both titles: "1+2", and it know what to do.

Another example is deleted scenes. Often, they are in separate titles, but I like them all combined. As above, I simply give it all the title: "1-5+7" (that is, titles 1 through 5, plus 7), and tell it to concatenate instead of merge. I can also tell it to concatenate after transcoding (which has the advantage of not have to pre-extract them all).

Anyway, the problem I ran into now was a foreign movie where the foreign language audio was labeled as English. Not a big deal, but I'm anal and little things bother me. :)

So, in my script for the movie, I have:
Code:
# Audio track is Japanese but is labeled as English. need to extract title and fix it.
dst1 := "{@sandbox}\{@line}\t4"
extract:"{src}",4,"{dst1}.mkv",title-type(dvd)
mkvmerge:"{dst1}.mkv","{dst1}.remux.mkv",now,track-info(1,2,,,jpn)
"{dst1}.remux.mkv",1,"{dst_dir}\{title} ({title_yr}).mkv",dvd,chg-subtitle(1,1,0,1),crop(68,68,2,2),audio-lang(jpn)

Each line of this snippet does thusly:
1. Set the variable "dst1" to a path on the previously defined sandbox folder. This is used in the other commands to indicate where to place their files. "{@line}" resolves to the current line number, guaranteeing the path is unique relative to the script.
2. Extract title 4 from the DVD (the movie). The extract command can use various tool to extract titles from DVDs and Blu-rays (MakeMKV, mkvmerge, ffmpeg, etc.). The default tool is MakeMKV. "title-type" tells it that "4" is the DVD title number. The default is whatever numbering system the tool uses. By telling it to use the DVD title number, I don't have to open MakeMKV and figure out what its title number for the movie is. My tool will create a mapping between the two.
3. Calls mkvmerge to change the language of the 2nd track of the 1st file to "jpn". All numbers in the script are 1-based to make it easier, even if the tool uses 0-based (which mkvmerge does). "now" indicates to run mkvmerge now instead of adding a task to the transcoder queue.
4. This creates an entry in the trancoder queue to transcode the file using HandBrake (if no tool is specified, it defaults to HandBrake). The options tell handbrake to: use the predefined DVD profile, burn-in the first subtitle track, crop the video, and select audio tracks of the given language (by default, it would have selected English tracks, of which there are none).

A more common issue I run into is tracks where the language is "undefined" (und). Since this happens a lot, I have shortcut options for the HandBrake command to fix them. For example, "undefined-audio(LANG)" will tell HandBrake to select the "und" audio track(s), and will add an entry to the transcoder queue to remux the file after transcoding, changing all audio tracks defined as "und" to LANG.

This scripting method has worked out so well, I have what I call my "oh, sh*t!" backup. It is simply the scripts for all my discs and the source code for my tools, on a thumb drive. If my NAS ever dies and its backups fail (unlikely, but possible), I can recreate everything with the scripts and my disc backups (or the discs, themselves, if those backups also fail).

DrX
 
Back
Top