Open samhutchins opened 7 years ago
Thanks, @samhutchins, for filing this based on our initial Twitter conversation. I'll post a link to this on Twitter now to try and get more feedback.
I would like global settings for these settings, along with the ones already mentioned:
I already kind of do my own global settings, as I made a separate script that I always call (because I'm on Windows, if I was on some Unix variant I could probably put it in my .bash_profile
). This script then only takes a input file as argument. All the other settings are already specified in it. So when I transcode videos, I don't do transcode-video bla.mkv --add-subtitle swe --add-audio 2="Commentary" --add-audio 3="Commentary" --prefer-ac3 --target 1080p=9000 --target 720p=5000 --target 480p=2000 --main-audio 1 --audio-width all=surround --no-auto-burn --output d:\transcodes\ --crop detect --fallback-crop mplayer
. Instead I do transcode bla.mkv
.
As for place to put the config file, I guess the home directory is a good start. I feel like most things put their config file there, usually hidden (prefixed with a dot).
I was just thinking about this yesterday. My regular flags are --mp4 --no-log
(your first and third points).
I don’t think we have to complicate this much, though. No need to translate every option to an option on a config file. On homebrew-cask we have a simple solution: you can export a HOMEBREW_CASK_OPTS
shell variable with all the flags you want.
So if we add such a variable to the shell’s startup files (or even if we have a specified config file), we need only populate it with the flags themselves. That way there’s little messing around when options are added/removed/changed: just change the flags in your configuration.
That’s the easiest and most complete option to build and maintain. Considering how complex flags can be, that’s huge.
I'd be wary of using environment variables for this. It's super easy to set them on Unix-like operating systems but it's quite obtuse on Windows, it's a few dialogs deep
It might be interesting to have a config file where you just write the command line options you want though:
--mp4 --no-log
Probably a bit more user friendly than
---
format: mp4
log: false
---
Certainly more discoverable for what options you can put there, and it's how youtube-dl does it
On unix, it's quite easy to create an alias for the default options and only pass additional ones. I'm not sure about Windows though, do shell aliases work/exist in a similar way there?
If shell aliases won't reasonably work cross-platform, and the config comes, then there should be an option to ignore the config file for special/corner cases.
As @JMoVS has suggested, we already have this feature and it's called a shell alias.
I originally added a :)
to the end of that first paragraph but the truth is that I'm being completely serious here.
For example, on Unix systems @vitorgalvao could add --mp4 --no-log
to his command line like this:
alias transcode-video='transcode-video --mp4 --no-log'
And he could store that alias
line in a ~/.bashrc
file (or the equivalent for other shells) so that would be set up automatically.
Using alias
and ~/.bashrc
takes care of the entire feature proposal, too.
I believe a similar thing thing can be done on Windows with doskey
but @samhutchins would know for sure.
But even better way to do this is what @lambdan described and what I do myself, and that's to use a wrapper script. In fact, mine is deceptively called wrap-transcode-video.sh
. :)
Why is a full script better? Because you can not only pass static arguments, you can make them dynamic much like I do in my "Batch control for transcode-video
" example from the "README" document.
So, I am not inclined to add this feature to the tools in our video_transcoding
Gem when there are existing and better ways to achieve the same goals.
Especially since I would have to come up with a versioning scheme for those configuration files to deal with the fact that we change the API every few months. That's why the tools are still not "1.0" yet. Anyway, that's just more code, more testing and more maintenance.
That's my two cents. :)
Shell aliases are what I've always used for this, and it makes it quite simple, requiring no additional functionality to be added to the main gem.
@DaveHamilton Exactly!
Huh, I didn't know about doskey
. Looks pretty neat, and with a bit of hacking it's possible to get a .bash_profile type thing on Windows too: http://www.notonlyanecmplace.com/aliases-for-windows-and-clink/.
Seems then like the solutions we have are good enough, so adding a config file isn't worth the engineering effort
@samhutchins Interesting! I didn't realize doskey
was actually quite that powerful.
Maybe I should consider adding a section to the "Guide" section of the "README" document to document how to do these alias tricks on Unix and Windows?
BTW, even though the config file feature as originally described is off the table, I'll leave this issue open for awhile longer to collect comments.
From my messing around doskey
is the same as alias
. If one modifies the Windows registry to call a batch script when CMD starts you can set those aliases every time CMD opens, in the same way the putting aliases in .bashrc or .bash_profile works. I've modified my registry to call an env.bat
on startup, and I've put doskey transcode-video=transcode-video --mp4 --aac-encoder fdk_aac $*
, which replaces the local patch I had to change these defaults.
It's cool stuff, slowly but surely I'm making my Windows set up a bit more Unix-like
For any other Windows users, clink makes CMD a lot more bearable, it adds proper command history and completion among other things. You can also get most Unix tools compiled for Windows (I use gow).
If you decide to add information about this that'd be awesome, and if you'd rather not put the information in for both platforms I can write something up in the Windows install guide JMoVS and I have
@samhutchins Both "Clink" and "Gow" sound awesome! I didn't know about either.
I agree, also add options for detelecine, and forcing the framerate to specific values. Basically any option that can be used from the command line, should be able to be set as a global option, so the command line can be simply transcode-video, and you get all the regular options specified already.
I locally patch the video_transcoding gem to change the default output format and aac encoder so that I don't have to specify them every time on the command line. I think having these defaults, and potentially others, being user-configurable would be a nice feature for others as well
I hacked in some rudimentary support just to see how it might work. (I'm a Java developer, never written a line of Ruby in my life. Please forgive me)
Potentially useful configurable defaults:
What other things do people think would be useful to configure? And where'd be a good place for the config file?