Skip to content
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

Query-Handbrake-Log fails on all logs #257

Closed
BDaddyG opened this issue Feb 20, 2019 · 6 comments
Closed

Query-Handbrake-Log fails on all logs #257

BDaddyG opened this issue Feb 20, 2019 · 6 comments
Assignees
Labels

Comments

@BDaddyG
Copy link

BDaddyG commented Feb 20, 2019

Hello Don!

I've been using nwronski's batch-transcode-video but have run into an issue where the videos are transcoded, but then are deleted (see: https://github.com/nwronski/batch-transcode-video/issues/10)

After trying different things nwronske said that his script uses query-handbrake-log to get the bitrate which then determines if the conversion was successful. If a bitrate isn't returned, it's assumed that the conversion failed and the converted video is deleted.

Trying query-handbrake-log on any of my recent HandBrake log files produces:

redacted@avconvert2:~/Shared/Work/Done$ query-handbrake-log bitrate Test.mkv.log
/usr/local/rvm/gems/ruby-2.5.3/bin/query-handbrake-log: not a HandBrake-generated .log file: /home/redacted/Shared/Work/Done/Test.mkv.log

The same only with the verbose flag:

redacted@avconvert2:~/Shared/Work/Done$ query-handbrake-log -v bitrate Test.mkv.log
query-handbrake-log 0.23.0
Copyright (c) 2013-2019 Don Melton
Processing: Test.mkv.log...
Reading: /home/redacted/Shared/Work/Done/Test.mkv.log...
/usr/local/rvm/gems/ruby-2.5.3/bin/query-handbrake-log: not a HandBrake-generated .log file: /home/redacted/Shared/Work/Done/Test.mkv.log

This issue appeared after updating to HandBrake v1.20.

Could you take a look? I wish I had a HandBrake v1.1.2 log file to provide, but I must have deleted them. I've attached a HandBrake v1.20 log file that is failing for me.

Thanks!

HandBrakeCLI v1.20
video_transcoding v0.23.0
Test.mkv.log

@lisamelton lisamelton self-assigned this Feb 20, 2019
@lisamelton lisamelton added the bug label Feb 20, 2019
@lisamelton
Copy link
Owner

@BDaddyG Thanks for opening this issue! You found a interesting bug, sir!

But I'm so sorry you lost your transcoded files in the process. :(

First, let @nwronski know that it's much safer and faster to check whether the string "Encode done!" exists as a single line in the ".log" file to verify that HandBrake succeeded. That's what I do with some of my own scripts.

Second, if you look at the first few lines of that ".log" file you'll notice that it contains:

Cannot load libnvidia-encode.so.1
Cannot load libnvidia-encode.so.1
Cannot load libnvidia-encode.so.1
Cannot load libnvidia-encode.so.1

This is not normal and is apparently caused by a "bug" in HandBrakeCLI on certain Linux platforms.

And because you have four extra lines of garbage at the beginning of your ".log" files, a sanity test I put in query-handbrake-log is failing because it's not finding a line beginning with the string "HandBrake" within the first five lines of the file.

That string doesn't appear until the seventh line in your file.

Sorry about that. I didn't anticipate that HandBrakeCLI would ever be chatty about platform linkage issues.

Obviously I'll have to extend the scope of that sanity check. The question is by how much. Probably 10 lines would be more "lenient" but I'll need to think about that after coffee.

So, stay tuned for a patch later today. I was planning on doing a release this week anyway so I'll hold that version for this fix.

@lisamelton
Copy link
Owner

@BDaddyG OK, here's a patch, extending that sanity check to 10 lines, which fixes the failure with the file that you sent me:

diff --git a/bin/query-handbrake-log b/bin/query-handbrake-log
index ef70ae7..e8dd4c3 100755
--- a/bin/query-handbrake-log
+++ b/bin/query-handbrake-log
@@ -137,7 +137,7 @@ HERE
           File.foreach(log) do |line|
             found = true if not found and line =~ /^HandBrake/
             count += 1
-            fail "not a HandBrake-generated `.log` file: #{log}" if count > 5 and not found
+            fail "not a HandBrake-generated `.log` file: #{log}" if count > 10 and not found
             duration_line = line if duration_line.nil? and line =~ /\+ duration: /
             rate_line = line if line =~ /\+ frame rate: /
 

Can you verify for me that all of your failing ".log" files contain no more than four lines of that "Cannot load libnvidia-encode.so.1" console spew? Otherwise I may have to extend that check.

Thanks.

@BDaddyG
Copy link
Author

BDaddyG commented Feb 20, 2019

Thanks Don!

@BDaddyG
Copy link
Author

BDaddyG commented Feb 20, 2019

@donmelton I looked at a couple dozen log files and all have 4 lines of "Cannot load libnvidia-encode.so.1" at the beginning and Handbrake starting line 7.

I applied the patch, verified that query-handbrake-log now reports the log is valid, and ran a test with nwronski's batch-transcode-video which reported "Finished without error." and left the transcoded video.

Thanks for the quick turn around on the fix!

@lisamelton
Copy link
Owner

lisamelton commented Feb 20, 2019

@BDaddyG Thanks for all the testing! And you are very welcome!

I should be able to release this in the next few days after I complete testing on the other unrelated changes.

@lisamelton
Copy link
Owner

@BDaddyG Sorry it took so long but this is finally released. Thanks again for finding the bug!

Just gem update to get version 0.24.0 with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants