lisamelton / other_video_transcoding

Other tools to transcode videos.
MIT License
543 stars 24 forks source link

batch script from wiki fails to start #129

Closed zenodotus280 closed 2 years ago

zenodotus280 commented 2 years ago

On Windows 10 (not using Docker nor WSL). I have a functioning setup using executables in a C:\bin directory. Able to use NVENC without issue.

I have copied the script into a batch.rb and created a queue.txt (both on my desktop). The first and only entry in the queue.txt is a path to an mkv that works in cmd.exe without issue on its own. When I run the script (.\batch.rb --any-option-I-try) I get cmd.exe for a split second before it terminates. Ultimately I am trying to call the Ruby script from within PowerShell so that I can use UNC paths for my source and destination (UNC is not supported in cmd.exe)

lisamelton commented 2 years ago

@zenodotus280 I'm sorry you're having this problem. Okay...

First, don't ever use cmd.exe. :) Seriously, it doesn't play nice with Ruby. And always invoke the batch script from within PowerShell.

Second, can you copy the contents of your queue.txt file here? It's possible that there's a string quoting issue.

Thanks.

klogg416 commented 2 years ago

If you want to do it from the desktop with a mouse, the easiest option is likely to create a Windows shortcut. When prompted for the "location" enter a version of:

powershell.exe -noexit "ruby.exe C:\Users\<account>\desktop\batch.rb"

That will open a PowerShell window, call Ruby and run the script. This assumes Ruby is in your PATH, which by default it adds itself unless you unchecked that. If it isn't, you need to put the full path to Ruby and then the full path to your .rb file. Or put the .rb in your C:\bin directory.

lisamelton commented 2 years ago

@klogg416 Thanks! Yeah, that will work.

klogg416 commented 2 years ago

I know it will @donmelton , I just tested it. You know how much I hate walking back a confident answer. :-)

lisamelton commented 2 years ago

@klogg416 LOL! Yes, I do. :D

zenodotus280 commented 2 years ago

Speedy responses!

Firstly: my queue.txt just contains a test file S:\MEDIA-RECODES\test\test.mkv where S: is a local hard drive. Currently running some transcodes without the batch file using the regular other-transcode --blah command.

With respect to cmd.exe... I try not to use it! But I get the same thing and am left at the PowerShell prompt. When I change the path for the queue.txt within batch.rb from the full path I get a "no such file or directory". Using the full path seems appropriate here.

lisamelton commented 2 years ago

@zenodotus280 Yes, you need to use the full path. But is that the exact contents of your queue.txt file? I need to see the exact text to make sure you didn't quote anything. Putting quotes around the pathname won't work. And I need to discount that as a possibility.

zenodotus280 commented 2 years ago

Just tried again with a different file. The only line in the file is S:\MEDIA-RECODES\R1\RogueOne.mkv and I copy-pasted the path into a manual other-transcode command just to be sure.

lisamelton commented 2 years ago

@zenodotus280 Thanks for verifying that!

OK, next question: What is the line termination for your queue.txt file? There is a carriage return at the end of the path, right?

It might be useful if you just upload your batch script and queue.txt file here.

klogg416 commented 2 years ago

If you are uploading, might as well upload the batch.rb file too.

zenodotus280 commented 2 years ago

Progress! I added a blank line and it immediately started running. Unfortunately I think I created another problem by ungracefully killing the manual transcode I started with aggressive CTRL-Cing:

Verifying "ffprobe" availability...
Verifying "ffmpeg" availability...
Verifying "mkvpropedit" availability...
Finding encoders...
Trying "h264_nvenc" video encoder...
Scanning media...
duration = 02:13:57.279
Stream mapping:
 0 = h264_nvenc / 6000 Kbps
 1 = ac3
Command line:
ffmpeg -loglevel error -stats -i S:\MEDIA-RECODES\R1\RogueOne.mkv -map 0:0 -c:v h264_nvenc -b:v 6000k -maxrate:v 20000k -bufsize:v 20000k -profile:v high -color_primaries:v bt709 -color_trc:v bt709 -colorspace:v bt709 -metadata:s:v title= -disposition:v default -map 0:1 -c:a:0 ac3 -metadata:s:a:0 title= -disposition:a:0 default -sn -metadata:g title= -default_mode passthrough RogueOne.mkv
Transcoding...
Failed to open report "_ffmpeg_17170_7712.mkv.log": Permission denied
RogueOne.mkv: Permission denied
C:/Ruby30-x64/bin/other-transcode: transcoding failed: RogueOne.mkv
PS C:\Windows\System32\WindowsPowerShell\v1.0>

I cleared the logs in the output folder but no change. Currently looking for the named log file.

Edit: Re-ran as Administrator and all appears functional with the batch script.

klogg416 commented 2 years ago

Weird, Admin privileges absolutely shouldn't be needed. My first guess is that your user does not have write permission to that network path. Are you mounting the S: drive through a system service or something else outside of user space?

[edit: autocorrect continues to haunt my life]

zenodotus280 commented 2 years ago

Okay, all squared away. Tips for future Windows users trying to use PowerShell:

  1. ensure there is at least one empty line in your queue.txt
  2. give the full path to your queue.txt in your batch.rb
  3. ensure you set your output directory in the powershell shortcut described above in the "Start in" field below the target or you will drop your files in /system32
  4. if you have an ungraceful exit and have issues with _ffmpeg logs it is likely because you dumped some files in /system32... run the script as admin to clear it up and then go to number 3 above.
zenodotus280 commented 2 years ago

Weird, Admin privileges absolutely shouldn't be needed. My first guess is that your user does not have write permission to that network path. Are you mounting the S: drive through a system server or something else outside of user space?

Likely the result of an earlier error: not setting my shortcut up correctly with no "start in" set correctly. Thanks for your help - the missing carriage return in my queue.txt would have stumped me indefinitely.

klogg416 commented 2 years ago

Ha! Writing to ./system32 will definitely give you heart burn. And I'm pretty sure the rule is to always use full paths, once it is working you can test relative pathing, but until then, be specific and be absolute. Glad you got there @zenodotus280.