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

Limit processing when using pixels-per-second #165

Open
xeruf opened this issue Apr 12, 2022 · 9 comments
Open

Limit processing when using pixels-per-second #165

xeruf opened this issue Apr 12, 2022 · 9 comments

Comments

@xeruf
Copy link

xeruf commented Apr 12, 2022

When using pixels-per-second, one cannot add --end - understandable, since it is redundant to --width then. But unfortunately, --end is the only flag that limits the time of audio that is processed, so that even on a short width, long audio files take a long time to process with pixels-per-second. Through a simple division this should be limited internally :)

@sgloe
Copy link

sgloe commented Jan 4, 2024

I am creating a json data file and only need a specific piece of my whole audio file as waveform.
I use the --pixels-per-second 15 to reduce the filesize. For the whole file, this works perfectly.
Now I tried to only get the part between 00:10 and 00:40 by using --start 10 --end 40. But this fails due with the message Specify either --end or --pixels-per-second but not both. I do not understand why. Is there a way to achieve this?

@chrisn
Copy link
Member

chrisn commented Jan 5, 2024

Now I tried to only get the part between 00:10 and 00:40 by using --start 10 --end 40. But this fails due with the message Specify either --end or --pixels-per-second but not both. I do not understand why. Is there a way to achieve this?

I think this should be allowed, i.e., set --start, --end, and --pixels-per-second, and use these to determine the width. I'll work on a fix.

As a workaround, you can set the --width option instead of --pixels-per-second. So in your example, you want a 30 second waveform at 15 pixels per second, so the width is 450 pixels: --start 10 --end 40 --width 450.

@xeruf
Copy link
Author

xeruf commented Jan 7, 2024

It would also be nice to automatically calculate the end from the width.
From the behavior I observed when setting width it still processes the audio file till the end and then cuts it off, incurring significant extra processing.

@sgloe
Copy link

sgloe commented Jan 8, 2024

Hey Chris, I tried your suggested workaround. It does work, if I output a PNG file. The image looks correct and does fit the audio.
But as far as I can see, it does not work, if I output a JSON data file. The JSON data always contains the peaks for the complete length of the original audio file.
@xeruf what output format do you use?

@chrisn
Copy link
Member

chrisn commented Jan 8, 2024

Ah, sorry, I should have checked that would actually work before suggesting it. The options are handled differently for creating images vs creating data files, hence the discrepancy - for historical reasons, as we only needed full duration data files, whereas images could be any period within the audio.

@xeruf
Copy link
Author

xeruf commented Jan 8, 2024

output as image for display with timg

@sgloe
Copy link

sgloe commented Jan 10, 2024

Ok, I understand. Unfortunately, I am not a CPP Developer, so I am unable to contribute here. But is there a chance, you and your contributors could implement that feature, that enables me to create Waveform JSON Files, the same way as it is possible for PNG Images respecting --start and --end arguments? I can create a dedicated Issue here, if that helps. Otherwise I will find a way to workaround this limitation by using an already shortened WAV File.

@chrisn
Copy link
Member

chrisn commented Jan 11, 2024

Well, it's just me in my spare time really - but yes. There's no need to create an issue.

@chrisn
Copy link
Member

chrisn commented Jan 12, 2024

I'm going to look at this together with #157, as they're related.

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

No branches or pull requests

3 participants