-
-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic Target File Path #1346
Comments
Whatever solution I might think of, it will be very complex to implement and hard to use. Every encoder has to be supported, names have to be unique, path length should be less than 260 ... and what if file name exists?
Sure, but why?? Right now I don't see any advantage that would come with your request, despite the fact, that you would not have to add some characters to the target file name. I do it often, but it never bothered me that much to do so. |
I see, for me creating a new type of Event and call it something like Anyway, I think for this task, is more useful to create a Powershell script with for-loops iterating over the encoder settings I want to test (e.g.: iterating over an array of crfs [20,25,30]) and creating a Job for each one. That is if I insist in using StaxRip, because this looks more like job for a shell script at this point 😅 |
It might take a while, but I will see if I can properly add an encoder options based event. But in case I'm not missing anything: Even with an event like that, you still have only the whole parameters, no delta. StaxRip itself has no ability to put code inside, so you would end up creating event commands for each encoder parameter, because you can call a PowerShell script, but that script won't be able to set the target file name. 🤔 Indeed. 😅 |
I'll leave here an example powershell script that can be added to StaxRip scripts in case it's useful for anyone, I still need to figure out a cleaner way to add more encoder options (since for each new one, you have to add another nested foreach...), but since I have an initial script I thought about posting it here anyway (and because couldn't spend more time on this the past week). 😄 $crfs = 45,50,55
$fgs = 15,20
$activeProject = [ShortcutModule]::p;
$enc = ($activeProject.VideoEncoder.Name | Out-String) -replace "SvtAv1EncApp","av1" -replace "`n|`r"
if ($enc.Contains("av1")) {
$enc = "av1"
}
if ($enc.Contains("x265")) {
$enc = "x265"
}
$tg = $activeProject.TargetFile;
$source = $activeProject.SourceFile;
$target_dir = ([System.IO.DirectoryInfo]$tg).Parent.FullName
$base_file = [System.IO.Path]::GetFileNameWithoutExtension(([System.IO.DirectoryInfo]$source).BaseName)
$mux_ext = $activeProject.VideoEncoder.Muxer.OutputExt
foreach ($crf in $crfs) {
$params = "Q$crf-p4-fg8"
switch($enc){
"av1" { $activeProject.VideoEncoder.Params.ConstantRateFactor.Value = $crf; break; }
"x265" { $activeProject.VideoEncoder.Params.Quant.Value = $crf; break; }
}
foreach ($fg in $fgs) {
$params = "Q$crf-p4-fg$fg"
switch($enc){
"av1" { $activeProject.VideoEncoder.Params.FilmGrain.Value = $fg; break; }
}
$out_text = "{0}\{1}_{3}_{4}.{2}" -f $target_dir,$base_file,$mux_ext,$enc,$params
$out_text = $out_text -replace "`n|`r";
# [MainModule]::MsgInfo($out_text);
$activeProject.TargetFile = $out_text;
([ShortcutModule]::g).MainForm.AddJob($False);
}
}
([ShortcutModule]::g).MainForm.ShowJobsDialog(); |
I will try to add an |
The
|
I have also added a question when adding a job, that already exists. 😁 We will see how it works, |
Don't forget to give me some feedback on this one. 😉 |
Thank you so much, |
Is your feature request related to a problem? Please describe.
I'm trying to "imitate" the feature of handbrake where the target filepath gets automatically updated after you change any encoder option like CRF or preset, etc. For now I managed to use the Event Command but I feel limited for one thing. I can set up the event trigger to be on Before Job Processed or After Source Loaded, but still not quite optimal because:
After Source Loaded: once it loads, the target filepath and project name remains the same as the default Project or Template config. After you change some setting in the encoder, it won't update anymore and remain as is (I mean, the filename changes to x265_crf18.mkv but doesn't update anymore).
Before Job Processed or Before Processing: this address the previous problem, but this only applies when starting the Job.
What I want is being able to schedule multiple Jobs with different CRF or encoder settings and then at the end launch all of them and compare the results afterwards.
So I managed to get the filepath to be how I like it, ending with
_av1_crf34_preset8.mkv
for example. But I'm failing at trying to update somehow the target filepath "dynamically" in some way, without resorting to powershell scripting.Describe the solution you'd like
It would be nice to have a new event triggered by
VideoEncoder.OnStateChange()
for example, so when you close the Encoder Options window, you can trigger an event like EncoderSettingsUpdated and put that into the Event Commands Editor.The only limitation I find myself is I cannot create multiple jobs with different settings because the filepath remains the same (until the job is finally launched that is) and wouldn't add a new Job when clicking Add Job.
Describe alternatives you've considered
The only alternative I can think to this would be using a Powershell script and launching it manually after I have got all my encoder settings set.
For example
Explain why the feature matters to you
I thinks this would be a nice addition for batch encoding the same file with different settings, so you can experiment quickly by letting StaxRip launching all jobs and coming back later and comparing the results. It's tedious to wait for the job to launch/finish and then modify the settings again.
Additional context
Of course, I might missing something with how StaxRip manages the target file or updates, and maybe the solution is simpler than adding anything to the code. I just discovered the Event Command today (I only knew about PS scripting) and seems a much simpler and awesome way to do powerful stuff in StaxRip rather than using powershell.
PS. The target file path expression I come up for the event command in case someone finds this thread while searching:
%target_dir%\%source_name%_%eval:"%encoder%" -replace "SvtAv1EncApp","av1"%_%eval:((Select-String -InputObject "%encoder_settings%" -Pattern "(crf \S+)|(preset \S+)|(film-grain \S+)" -AllMatches | Foreach {$_.Matches.Value}) -join "_") -replace "\s",'' -replace "film-grain","fg" %.%muxer_ext%
The -Pattern option is for specifying what encoder settings I want in the filename.
The text was updated successfully, but these errors were encountered: