-
Notifications
You must be signed in to change notification settings - Fork 81
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
bytesPerSample or sampleBitDepth return confusing results for audio #36
Comments
@pps83 thanks for report! Could you please provide media sample? Just for local testing. |
According |
av::AudioSamples::sampleBitDepth() av::SampleFormat::bytesPerSample() always return 1 instead of actual sample size. Ref #36
Not sure. Sample data is welcomed. |
According FFmpeg code, it store FULL buffer size at the
And allocate it for each plane:
For other details, look into From FFmpeg docs:
|
I pulled all the change and it does not compile for me:
Also, I build with VS2015 and there is a few things that do not compile. I had to make a few changes: (I left some comments there). |
after I made latest code compile bytesPerSample and sampleBitDepth seem to return proper results now. doese bytesPerSample come directly from avcodec api? It's common for sound libs for bytes per sample to return channles * sampleSize. Perhaps in fmod it's like that (but I might be wrong). Clip that I used is temporarily committed to https://github.com/pps83/avcpp/tree/master3 (RobloxAnthemVideo384.mp4) |
Short answer: yes.
I deal with ALSA directly, UAC (USB Audio Class): in all this places you should calc full size like:
I have no complete answer. At least, it is not a bug in AAC: I describe above common utility code that uses to allocate buffers for audio AVFrame in all parts of FFmpeg. It is not a bug, but non-optimized way. In any case, you MUST make calculation in way, that described by me: AVFrame's and AVPacket's now reference-counted and can be reused in unpredictable way, so, real buffers can store more data that currently avail for give buffer. And, this buffer sizes like
Thanks, I take it.
According changes with
at the top of |
I think it was in fmod that it was like that, I don't remember where it was. I tried to find in docs, cannot find sample size related stuff. Perhaps it's in their headers. regarding size_t changes. I didn't have issues with size_t, but I don't see a point to use size_t there. I had lots of compilation warnings because of signed/unsigned mismatch, so I patched it. size_t -> unsigned wasn't really needed. IMO it's doesn't make sense to use size_t or ssize_t for things that have very small range of values like stream count etc; ffmpeg also uses plaint int or unsigned int for these things and avcpp should also do the same. all the changes done in that referenced fork are done for a quick one day project, that's why I have windows.h there and some other unrelated mess. |
Invalid data when decoding a youtube video. This is the youtube video that triggers this problem. Sample ffmpeg cmd line: this encodes and completes without any errors. However, when I run it through avcpp I get |
create new task, please. |
https://www.fmod.com/docs/api/content/generated/FMOD_CREATESOUNDEXINFO.html For example
I assure you that this parameter means channel-samples, as I had issues with that and once I converted to calculations to treat all samples as channel-samples all issues got sorted out. Similarly in many other cases it's not even specified, but assumed that all samples are channel-samples. |
I'm using avcpp and I really like it!
I'm decoding mp4 (h264+acc) and aac decoder returns AV_SAMPLE_FMT_FLTP (planar floats). In my case I have stereo aac and when I get a decoded audio
av::AudioSamples
frame values that I get for samples count size etc are all confusing.these are the values that I have:
aframe.raw.buf[0] and buf[1] both have size 8192, however, looking at the memory in debugger it seems that samples actually take half of that buffer. Either it's ffmpeg allocates more (padding, rounding) or it's a bug? For 1024 FLTP sample it should be 4K in each plane or total 8K for 2 channels.
IMO, aframe.size() should return size of actual samples stored, and but currently it seem to return size of allocated memory. In any case, bytes per sample seems to be completely wrong there (it should be 32 or 64 if a sample is counted for all channels).
The text was updated successfully, but these errors were encountered: