-
Notifications
You must be signed in to change notification settings - Fork 91
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
Use soxi instead of gstreamer to determine a track's length #67
Use soxi instead of gstreamer to determine a track's length #67
Conversation
I think this should go in morituri/program/ - like arc.py and sox.py |
ac4629b
to
eff9cb9
Compare
thanks @MerlijnWajer, i've moved the code to a soxi.py in the appropriate location. (this might also form a handy base when soxi is used for more; sample rate and metadata extraction are the only other uses that seem practical to me in the whipper context). |
self._path = path | ||
self.logName = os.path.basename(path).encode('utf-8') | ||
|
||
self.command = [SOXI, '-s', self._path] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to learn as little about morituri.common.task as possible; do we need to assign self._path = path here if we only use it once?
self._output = [] | ||
|
||
def commandMissing(self): | ||
raise common.MissingDependencyException('sox') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this say soxi
instead of sox
? I'm aware that the package is named sox
on almost every system (if not every), but the command in particular we care about is soxi
.
So the reason tests fail is that However, I did notice that Extending |
i was originally on the plain as for the failing tests, i'd argue that as long as the presented file thus, i see two paths forward:
unless this changed your mind about which is the way to go in soxi vs |
I'm happy with using *If and only if you can prove to me that And as an aside, we already divide by common.SAMPLES_PER_FRAME— not a magic number but definitely a constant. Sorry for the comment/editing thrashing here, I should not github immediately after waking up. |
@chrysn |
@JoeLametta ad close: Sorry, i missed the last post and was waiting for feedback on mine. @RecursiveForest ad proof (output abbreviates):
(Replace -c1 with -c5 or an arbitrary number of channels, results are equivalent). i'll add a patch that uses a .flac name for the file in the unit test, then it should pass. |
* Use extensions soxi understands (ie. ".flac") * Actually test for result correctness on files with odd characters in their names by copying the test track * Relax the requirements on the "track absent" task to only raise some TaskError (the previously tested behavior was backend dependent, and the application did not actually depend on that behavior)
eff9cb9
to
bacda81
Compare
The updated branch contains one code change (catch- and testable |
Sorry for how long this took, there was a miscommunication about who would merge it. |
this patch changes the AudioLengthTask to use the external
soxi
program (part of sox) instead of running a gst pipeline. after this patch (and dropping theimport gst
in morituri/common/checksum.py -- the way to do this properly is probably to make all the GstPipelineTask subclasses useself.gst
instead ofgst
, but what to do in__init__
when it's not available yet?), i could do an image verification on a system without agst
module.the patch is rather simplistic in that it just replaces the gst AudioLengthTask with a sox one; for other tasks it seems that whipper has different implementations, but being new to the whipper tasks system didn't right now find how to do that. more potential for improvement seems to be status reporting (could there be progress on such short tasks?) and parallelization (the new implementation has no explicit locking but seems to be executed in series anyway).
please let me know in which areas the patch would need enhancement, and (for the known shortcomings above if they are actual issues) where in the code to look for examples.