lisamelton / more-video-transcoding

More tools to transcode videos.
MIT License
45 stars 1 forks source link

Source File Name Copied to Output Name Throwing Error #1

Closed ste2w closed 1 year ago

ste2w commented 1 year ago

Hey! so i was trying out the av1 script along with the other ones earlier today and I'm not sure if its just user error or just my bad luck lol so i went to test out a file I had and when I put in the path and specified the output name and hit enter it said encode failed and then spat back the name of the file so I thought well that was a bit weird (On every single script) So upon further tinkering I found that no matter what I typed for the output filename it would always use the source file name ( I hope this makes sense) once I copy and pasted the handbrake cli arguments into notepad and changed it manually I then copied the whole command back to the command prompt it then worked normally.

(As a side note I also found out that if I don't put an underscore in the name it doesn't put it in the directory that I specified, although I'm not sure if that's just a bug or just me but once i put the underscore in the output name then it showed up as normal ) Sorry for the long winded text lol have a great day! :)

lisamelton commented 1 year ago

@ste2w Congratulations on opening the first issue for this project!

OK, did you look at the --help output for the scripts? I'm guessing no, because...

There is no way to specify the output path or name. None. It's not allowed.

Here's the relevant --help output for two-pass-transcode.rb:

Usage: two-pass-transcode.rb [OPTION]... [FILE]...

Creates a Matroska `.mkv` format file in the current working directory
with video in 8-bit H.264 format and audio in multichannel AAC format.
Forced subtitles are automatically burned or included.

You can specify one or more inputs but the output is always placed in the current working directory. That's by design for both batch processing and safety.

Does that help?

ste2w commented 1 year ago

OH actually believe it or not i did XD but i guess i didnt read it clear enough sorry! so is it a handbrake thing? cause im a bit confused especially because they arent even in the same folder i have the untouched rips in my "Videos" folder and the "converted" videos are in the directory with all the scripts and i tried it without specifying an output just put av1-transcode "PATH/TO/MOVIE" and i hit enter and it was still throwing the same error its still passing the source file name into the output name in the handbrake arguments. and also thats the other thing i was trying to mention if i didnt put the underscore between say for example The_Movie it wouldnt show up in the working directory either it was only when i put the underscore then it showed up in the working directory

lisamelton commented 1 year ago

@ste2w OK, I'm sorry but I have absolutely no idea what you mean. That didn't make any sense to me.

Can you please paste in the command line you're using here?

ste2w commented 1 year ago

yeah im sorry bout that maybe i should slow down XD

sure it was av1-transcode "Path/to/movie/movie.mkv"

then i would hit enter and it would say Transcoding... with the handbrake arguments and then it would say

D:/Video/Movie/more-video-transcoding-master/av1-transcode.rb: transcoding failed: movie.mkv

lisamelton commented 1 year ago

@ste2w OK, that's much clearer. Thanks!

Can you paste in those HandBrakeCLI arguments, please? BTW, you can add the --dry-run option to see those without transcoding.

ste2w commented 1 year ago

HandBrakeCLI --input D:\Video\NAMEofmovie\movie_t06.mkv --output movie_t06.mkv --encoder svt_av1_10bit --encoder-preset 8 --quality 30 --rate 60 --crop-mode conservative --audio 1 --aencoder opus --ab 320 --mixdown 5point1 and thats the commandline arguments i was reffering to it copies the source file name and puts it as the output file name as well thats the part im confused about it wasnt until after i changed the output name and pasted it back in after changing it then it worked without issue does that make a bit more sense??

lisamelton commented 1 year ago

@ste2w Yes, it makes a bit more sense.

What was the name you changed it to?

OK, what's the current directory when you invoke the command? Is it the same directory that the input file is in? And if that's not the case, are you sure you have write access to the current directory?

ste2w commented 1 year ago

oh ok so no the source files are not in the same directory they are in a separate folder on my machine and the directory that im invoking is the same folder i downloaded from github (more-video-transcoding-master) i just extracted it in its original folder and then i command prompt in from there and the name i changed it to was movie.mkv and then it worked but i had to modify the arguments to "Movie.mkv" for it to work

lisamelton commented 1 year ago

@ste2w That "folder" you downloaded? Try switching to a completely different directory and see if that works.

ste2w commented 1 year ago

OK so I put it on my D: drive and same thing still happens

lisamelton commented 1 year ago

@ste2w Then I'm sorry, but I have no idea what could be going wrong other than there might be a hidden character within the source file name that confuses HandBrakeCLI.

Does this happen for any other input file? And what happens if you change the name of the input file?

ste2w commented 1 year ago

It does that with all the files I've tried n if I rename the it just copies the source name (no matter what I change it too) to the output name in the handbrake arguments I was really confused lol but that's OK no worries I noticed it and thought I'd try to make ya aware of it :)

lisamelton commented 1 year ago

@ste2w Yes. It's supposed to use to the source filename as the basis of the output filename. That's by design. Sooooo... I was already aware.

My questions was: do you get the same error when you use a different input file? Whether you did is unclear from your response.

ste2w commented 1 year ago

Yes I'm sorry I do regardless of the input file it's the same error

lisamelton commented 1 year ago

@ste2w Just out of curiosity, which version of HandBrakeCLI are you using?

ste2w commented 1 year ago

Version 1.6.1 :)

ste2w commented 1 year ago

The latest version as far as I'm aware lol

lisamelton commented 1 year ago

@ste2w Thanks. And this error happens with all four of the scripts, not just av1-transcode.rb?

ste2w commented 1 year ago

Correct it happened with all four scripts on my end it gave me the same error I'm starting to wonder if handbrake didn't switch something up kinda like what ffmpeg did the last time I had an issue lol but I'm not sure

lisamelton commented 1 year ago

@ste2w Something odd is definitely going on but I have no idea what it is. I'm sorry that I've been unable to help you.

But thank you so much for trying my scripts!

ste2w commented 1 year ago

Yeah hey no problem I was really excited when I saw ya made these I was like well I know what I'm doing tomorrow lol but I appreciate trying to troubleshoot it! I'm sorry if I was confusing in the beginning I have a hard time explaining this stuff lol did you want me to close it out? Or leave it open??

lisamelton commented 1 year ago

@ste2w I'll close it as "can't repro" because.. I can't.

ste2w commented 1 year ago

Oh I forgot to mention if there is a space and no underscore like for example the movie.mkv it just shows up with the extension of (file) not mkv it acts like it isn't a video file

ste2w commented 1 year ago

And it's just the word the instead of the movie.mkv

lisamelton commented 1 year ago

@ste2w What? Example command line, please, because that didn't make sense to me.

ste2w commented 1 year ago

Right I'm sorry so like if it says in handbrake --output the movie.mkv it will create a file called the and that's it when I go to the working directory there is a file created called "the" instead of the movie.mkv and the extension is file not mkv or however it looks like a file without an extension

ste2w commented 1 year ago

It's only after I put the underscore or dash --output the-movie.mkv then the full name and the extension show up

ste2w commented 1 year ago

But if I put a space instead of a dash or underscore it will not show an extension I hope that makes a bit more sense

lisamelton commented 1 year ago

@ste2w You do realize that you have to put quotes, either single or double, around filenames with spaces, right?

ste2w commented 1 year ago

Yeah that's what I did for the source and even when I did single quotes around the source it still gave me the same error for example av1-transcode "path/to/movie/movie_t06.mkv" do you think it's throwing the error because handbrake thinks the source and the output is the same file? Or does that matter?? Maybe it's thinking "hey you already have a file with the same name and extension already" and just freaks out?? Cause once I change the --output from movie_t06.mkv (same as source name) to movie.mkv then it proceeds and transcodes it

lisamelton commented 1 year ago

@ste2w I have no idea because I don't have access to your filesystem. Something is either wrong there or something is wrong with your usage. Honestly, I give up at this point. Sorry.

skj-dev commented 1 year ago

@ste2w Instead of providing descriptive summaries of hypothesized reasons for behavior, it would be more helpful if you just provided a copy/paste of your environment, the command you're running, and the output you're receiving. For example:

❯ pwd                                                                                                                                                              
~/Rips 

❯ av1-transcode.rb /Path/to/the movie.mkv                                                                           
Scanning media...
/usr/local/bin/av1-transcode.rb: scanning media failed: /Path/to/the

❯ av1-transcode.rb /Path/to/the_movie.mkv                                                                                                                          
Scanning media...
/usr/local/bin/av1-transcode.rb: scanning media failed: /Path/to/the_movie.mkv

In those two examples, the problem is clear for folks who know what to look for.

The first problem involves the script taking the first argument that it expects to be a file, but our file is "the movie.mkv", not "the". Because the path wasn't wrapped in quotes or alternatively the space escaped, \, the script stopped at the first space, which happened to be the middle of the file, not the end of the line.

The second problem indicates that the source file either doesn't exist or is not readable.

In both of those cases extracting the Handbrake command and inserting an --output option isn't an appropriate solution. I think that's why this seems so confusing. The problem being presented has more to do with an attempted solution than the actual problem.

My strong suspicion is your first problem involved one or more unhandled spaces.

I also see you've sometimes used \ as a path separator and sometimes /, which means you're on a Windows system, but maybe not always in a Windows context. That can complicate things, especially since WSL will consider \ an escape character, not a path separator.

My next suspicion is after various attempts you might have an empty file sitting in your destination, which means if the path/space problem is addressed, there is now a new error because the destination file technically exists, even if it's zero bytes.

All of this is much easier to parse if we can see the actual commands being run, unedited, including the errors. Descriptive paraphrasing just means everyone involved has to make assumptions, and well ... surely we all remember that joke. 😎

ste2w commented 1 year ago

OK let me start over to clear up confusion lol let me try to break it down a bit easier (I'm still learning lol) A) I got the file to work as expected once I changed the handbrake arguments once I changed the output parameter that handbrake gave me it worked and I had a usable file

B) I didn't add an output command it came with it Meaning it looked like this HandbrakeCLI --input "movie_t06.mkv" --output "movie_t06.mkv and then the arguments followed I didn't add anything the only thing I changed was I took out the _t06 and it finished with a usable file

I hope this may make a bit more sense I'm sorry again there's a lot of this I don't understand I don't mean to sound rude or anything

ste2w commented 1 year ago

I took out the _t06 in the --output argument

ste2w commented 1 year ago

I was just afraid to post the full command line with the movie name I didn't know if I would violate anything on github if I'm clear to do that I'll post the full thing as it is. Is that OK to do??

ste2w commented 1 year ago

Also yes I'm on windows 10

skj-dev commented 1 year ago

It's possible to edit the pasted text before hitting the Comment button, while retaining relevant information. For example, The Big Lebowski.mkv could be edited to The Big Movie.mkv, which would provide obfuscation without removing relevant information.

Also, it helps to not treat GitHub comments like they are a chat stream. Even existing comments can be edited. So instead of having sparse information scattered across four comments, which also generated four emails, the additional information could have been added in as an edit to the first comment.

That improves readability.

Unfortunately, this still reads as a series of paraphrased explanations instead of providing the actual commands run with corresponding context and error messages.

However, if I understand correctly based on the four responses, you're not having the issue anymore? If so, then all this is moot anyway. 😄

ste2w commented 1 year ago

ok i apologize i wasnt aware of that so let me start from the top and run through how i started

av1-transcode.rb "D:\Video\Termatrator_Salvation\Termatrator_Salnation_t10.mkv"

which after hitting enter would result with this

Scanning media... Command line: HandBrakeCLI --input D:\Video\Termatrator_Salvation\Termatrator_Salnation_t10.mkv --output Termatrator_Salnation_t10.mkv --encoder svt_av1_10bit --encoder-preset 8 --quality 30 --rate 60 --crop-mode conservative --audio 1 --aencoder opus --ab 320 --mixdown 5point1 Transcoding... D:/more-video-transcoding-master/av1-transcode.rb: transcoding failed: Termatrator_Salnation_t10.mkv

and thats all i get it will not proceed with any transcoding and it stops there

and to answer the last sentence im still having the issue because once i change the --output Termatrator_Salnation_t10.mkv to --output Termatrator_Salnation.mkv in the CLI it works and is completed but if i use the av1-transcode.rb above it just throws the same transcoding failed error in essence i have to manually edit the handbrakeCLI --output argument everytime just to get it to transcode correctly

skj-dev commented 1 year ago

That's it? Based on that output HandBrakeCLI isn't even running. For example, this is the output I get right at the start. Granted, I'm not using Windows, but I would still expect to see some of the HandBrakeCLI preamble output. This is a snippet of what I get.

❯ av1-transcode.rb /Volumes/originals/The\ Movie\ \(2005\).4k.mkv                                                                                         
Scanning media...
Command line:
HandBrakeCLI --input /Volumes/originals/The\ Movie\ \(2005\).4k.mkv --output The\ Movie\ \(2005\).4k.mkv --encoder svt_av1_10bit --encoder-preset 8 --quality 30 --rate 60 --crop-mode conservative --audio 1 --aencoder opus --ab 320 --mixdown 5point1
Transcoding...
[11:34:24] Compile-time hardening features are enabled
[11:34:24] hb_init: starting libhb thread
[11:34:24] thread 16ff93000 started ("libhb")
HandBrake 20230307062323-dbeaa4698-master (2023030901) - Darwin arm64 - https://handbrake.fr
20 CPUs detected
Opening /Volumes/originals/The Movie (2005).4k.mkv...
[11:34:24] CPU: Unknown
[11:34:24]  - logical processor count: 20
ste2w commented 1 year ago

Exactly but the funny thing as soon as I change the --output argument it runs normal and looks like yours but it doesn't start if I just copy the path and hit enter I'm so confused xD

skj-dev commented 1 year ago

So it sounds like the problem is that the av1-transcode.rb script is unable to find or run HandBrakeCLI for some reason. I'm largely unfamiliar with how Windows works these days, so I don't know if there's a PATH issue or something else going on that doesn't manifest when calling HandBrakeCLI from the terminal directly (assuming maybe a PowerShell terminal?). Or maybe Windows cares about what directory you're running the script from?

Unfortunately, this does seem to be some strangeness with Windows which I'm unable to try to reproduce, since I don't have any Windows systems.

Changing the --output argument is outside the scope of the av1-transcode.rb script, so any result from that action is irrelevant. It's a little like saying that your car isn't working, but if you remove the emergency brake it rolls downhill just fine.

ste2w commented 1 year ago

I'm wondering if there is a way to maybe (as a test) somebody could change the output in the .rb to maybe include a _1 at the end before the .mkv so that it's different then the source filename??

I just use the standard command prompt from windows not powershell but when I call the cli directly with the modified --output it runs without a hitch I'm not sure why either I'm definitely interested though cause this stumped me

skj-dev commented 1 year ago

av1-transcode.rb is a text file, so somebody can be you. 😄

I don't understand why changing the options to HandBrakeCLI would make any difference when HandBrakeCLI doesn't appear to be getting called in the first place.

The file name is irrelevant, unless you're running the script in the same directory that the source file exists, or a file matching the name of the source file is in your current directory. In both of those cases that's not a problem with the script, and not overwriting an existing file is intended behavior. However, the script also detects that, and produces an error message explicitly stating such, which you are not seeing.

ste2w commented 1 year ago

but see thats the thing i actually managed to change it and added an _1 to the .mkv from this line in the code output = File.basename(path, '.*') + '.mkv'

and that still didnt work it still gave the same error i got originally

(as a side not the source file is not in the same directory as the scripts its in a whole different directory) but see the funny thing is i went back to basics and ran it again except this time i took the command line arguments

HandBrakeCLI --input D:\Video\Termatrator_Salvation\Termatrator_Salvation_t10.mkv --output Termatrator_Salvation_t10.mkv --encoder svt_av1_10bit --encoder-preset 8 --quality 30 --rate 60 --crop-mode conservative --audio 1 --aencoder opus --ab 320 --mixdown 5point1

and directly copied and pasted it without changing the output and it worked like it was supposed to.. im even more confused so that means the the .rb isnt calling the CLI right?

skj-dev commented 1 year ago

Yes.

So it sounds like the problem is that the av1-transcode.rb script is unable to find or run HandBrakeCLI for some reason.

😄

ste2w commented 1 year ago

WHOO HOO lmao man i gotta admit this is a bit fun to trouble shoot sorry for the massive amount of details btw i try to get as much info as possible but sometimes its an overload but thank you for the clarifications :) and thanks to you both for attempting to help me i really appreciate it :D im glad we potentially found a fix lol and ill try to make sure if i ever have another problem to be a bit more precise lol instead of treating it like a chat room ;) but im still learning haha

lisamelton commented 1 year ago

@ttyS0 Thank you so much for jumping in here while I was away! ❤️

@ste2w OK, I'm closing this as resolved now.

lisamelton commented 1 year ago

@ste2w BTW, I checked in a change to all the scripts last night that will give a better error message if you don't have HandBrakeCLI in your path and the shell can't find it. So thanks for bringing that issue to my attention.

Also thanks to @ttyS0 for helping me figure out that solution!

ste2w commented 1 year ago

Awesome! [edited handbrakecli.exe is in the same folder as the 4 scripts] I figured it out yesterday lol all I did was add an .exe at the end of handbrakeCLI (inside the script where it tries to call Handbrake command [ 'HandbrakeCLI'

once I added that .exe and it looked like this Handbrake command [ 'HandbrakeCLI.exe' Then I saved it, retried it, and it correctly called handbrakecli and worked as intended I don't think I've ever been so excited to see a wall of text run up my window as much as it was last night I almost couldn't believe it! 🤣 but thank you for your patience BTW I hope both of yall have a great day I'm happy I could help! 😀