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

Bug during mp3 write from the temp file #7

Closed
python4d opened this issue Dec 31, 2012 · 5 comments
Closed

Bug during mp3 write from the temp file #7

python4d opened this issue Dec 31, 2012 · 5 comments

Comments

@python4d
Copy link

For my side I will need to modify the access to the output file (export method):

change line 262 from:
output = NamedTemporaryFile(mode="w+", delete=False)

to:
output = NamedTemporaryFile(mode="wb+", delete=False)

regards,
-damien

@jiaaro
Copy link
Owner

jiaaro commented Dec 31, 2012

Thanks Damien,

Can you tell me a little more about the problem you were having and how you came to this solution? line 262 is not the only use of a NamedTemporaryFile(…) so I just want to make sure this change isn't needed elsewhere as well.

@python4d
Copy link
Author

hi,
I've just tried your module and I've got no error but the export mp3 has
been not created properly (tiny bad mp3 file).

I found out that temporary MP3 file was good but when you read it and copy
it to the MP3 "out_f" file => out_f.write (output.read()) <= it seems that
the reader stop after a zero-byte string...

I know, It's weird that I'm the only one with this malfunction...
But I wonder why the "output" file is the only file open as not binary
file...

I used v2.7 of python under pydev+eclipse env. (win7).

hope it helps,
-damien
HAPPY NEW YEAR

2012/12/31 James Robert notifications@github.com

Thanks Damien,

Can you tell me a little more about the problem you were having and how
you came to this solution? line 262 is not the only use of a
NamedTemporaryFile(…) so I just want to make sure this change isn't
needed elsewhere as well.


Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-11781330.

@python4d
Copy link
Author

hi again James,
Probably with windows you have to open as binary the mp3 file:
I read:
"On Windows, 'b' appended to the mode opens the file in binary mode, so
there are also modes like 'rb', 'wb', and 'r+b'. Python on Windows makes a
distinction between text and binary files; the end-of-line characters in
text files are automatically altered slightly when data is read or written.
This behind-the-scenes modification to file data is fine for ASCII text
files, but it’ll corrupt binary data like that in JPEG or EXE files. Be
very careful to use binary mode when reading and writing such files. On
Unix, it doesn’t hurt to append a 'b' to the mode, so you can use it
platform-independently for all binary files."

hope it helps,
-damien
HAPPY NEW YEAR

2012/12/31 James Robert notifications@github.com

Thanks Damien,

Can you tell me a little more about the problem you were having and how
you came to this solution? line 262 is not the only use of a
NamedTemporaryFile(…) so I just want to make sure this change isn't
needed elsewhere as well.


Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-11781330.

jiaaro added a commit that referenced this issue Jan 2, 2013
@jiaaro
Copy link
Owner

jiaaro commented Jan 2, 2013

@python4d would you mind running from the latest rev in github to confirm that this fixes your issue? (and as an aside would you mind letting me know if you're able to export a file as mp3?)

@python4d
Copy link
Author

python4d commented Jan 3, 2013

I've tested your new build and it works like a charm :-)
thanks!
-damien

@jiaaro jiaaro closed this as completed Jan 3, 2013
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

2 participants