joakimfors / PyMasVis

Python implementation of MasVis
GNU General Public License v2.0
16 stars 3 forks source link

Add ability to handle 'all files in a folder', and/or a list like *.flac, and add option to place analysis in a subdirectory. #2

Closed HansJA closed 8 years ago

HansJA commented 8 years ago

This COULD be done in an external shell script, but repeatedly calling the python interpreter seems too expensive for analysing several thousand files.

Which I'd like to do with all the files on my UPnP server. For later inclusion in an image tag, so I can look at the analysis for a song while listening to it.

In order to avoid clutter, when doing mass analysis, it would be nice to have an option to place any analysis file in a subdir of the directory where the audio file was found.

So that given the command "python analyze.py -S MasVis /media/Music/*", and then having a set of audio files in /media/Music/Beethoven, analysis files for this set of audio files will be placed in /media/Music/Beethoven/MasVis. If nonexistent, MasVis/ must be created as needed.

joakimfors commented 8 years ago

It's already possible to use "globbing". That is, analyse all files in a folder python analyze foo/bar/*.flac or even deeper pattern matching like python analyze.py ~/Music/*/*.flac.

I'll take a look at adding options to place the resulting image in a subdir relative to the analysed file

HansJA commented 8 years ago

Unless analyze.py manages the globbing on its own, deep globbing is problematic; the max command line length quickly gets in the way for anything like a reasonable UPnP server source tree.

I think a "perfect" way to deal with analyzing an entire tree would be to have a "recursive" option (-R) and accept the top folder of the tree as a single argument.

If there could also be a way to say "only analyse audio that is newer than an existing analysis, or hasn't been analysed yet"..... then I wouldn't have to learn gmake again. ;-)

joakimfors commented 8 years ago

PyMasVis uses the glob module to do its own expansion (on quoted command line arguments). I'll look into a "no overwrite" feature.

HansJA commented 8 years ago

What environments are you using this in, yourself?? Windows is the only OS I know of where the "shell" doesn't glob by default.

So if I quote the wildcard expression, analyze.py would do the globbing???

HansJA commented 8 years ago

What would a "no overwrite" do???

joakimfors commented 8 years ago

I'm using it on OS X and Linux.

Let me restate: PyMasVis does its own glob/expansion of arguments, too. However, this requires that the argument is quoted on the command line to prevent the shell from doing the expansion:

https://github.com/joakimfors/PyMasVis/blob/master/src/analyze.py#L1017

The no overwrite option would prevent analysing/overwriting existing results.

HansJA commented 8 years ago

Could that be changed into "only update analysis file if audio file is newer than existing"?

joakimfors commented 8 years ago

Yes, I plan on providing different choices i.e. always update, never update and update if newer.

HansJA commented 8 years ago

Some way to say Recursively ?

HansJA commented 8 years ago

Like

analyze --top /a/b/c --recurse --files '*.{flac,wav,aac,m4a,ogg}' --andir '.masvis' --updated-only

???

Or maybe regex-es?

HansJA commented 8 years ago

This is more compact:

analyze --recurse /top/dir --resultdir '.masvis' --newer \ '*.{flac,aac,wav}'

to analyze all flac, wav and aac files, that are newer than existing analyses, in the tree under /top/dir, putting and looking for analysis files in the subdir .masvis in each direction with matching files.

I suppose always creating the analyses subdir as needed i s the reasonable thing.

I assume Python can use csh style {} alternative lists for globbing?

joakimfors commented 8 years ago

Recursion of directory inputs, result destination directories and jpeg output format are now supported.

https://github.com/joakimfors/PyMasVis/blob/master/doc/manual.md

HansJA commented 8 years ago

Då ska jag testa. Du är rätt snabb, faktiskt.

Hans J. Albertsson From my Nexus 5 Den 15 apr. 2016 13:10 skrev "Joakim Fors" notifications@github.com:

Closed #2 https://github.com/joakimfors/PyMasVis/issues/2.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/joakimfors/PyMasVis/issues/2#event-628765903