Comments (12)
@pps83 thanks for report! Could you please provide media sample? Just for local testing.
from avcpp.
According size()
call. It just accumulate buf[x]->size
and relative this field. Seems that new API call that make difference between actual size and capacity is needed. I know, that best solution have a pair size()
/capacity()
like std::vector
, but it can break existing code silently.
from avcpp.
Either it's ffmpeg allocates more (padding, rounding) or it's a bug?
Not sure. Sample data is welcomed.
from avcpp.
@pps83 could you please check 21018d2.
Actual data size should be calculated like:
auto planeSize = aframe.sampleFormat().bytesPerSample() * aframe.samplesCount();
auto totalSize = planeSize * aframe.channelsCount();
from avcpp.
Either it's ffmpeg allocates more (padding, rounding) or it's a bug?
Not sure. Sample data is welcomed.
According FFmpeg code, it store FULL buffer size at the linesize[0]
:
ret = av_samples_get_buffer_size(&frame->linesize[0], channels,
frame->nb_samples, frame->format,
align);
And allocate it for each plane:
frame->buf[i] = av_buffer_alloc(frame->linesize[0]);
For other details, look into static int get_audio_buffer(AVFrame *frame, int align)
at the libavutil/frame.c
From FFmpeg docs:
* For audio, only linesize[0] may be set. For planar audio, each channel
* plane must be the same size.
from avcpp.
I pulled all the change and it does not compile for me:
avcpp\src\audioresampler.cpp(11): error C2512: 'av::SampleFormat': no appropriate default constructor available
Also, I build with VS2015 and there is a few things that do not compile. I had to make a few changes:
pps83@717efdb
(I left some comments there).
from avcpp.
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).
regarding planar audio and linesize[0]: I know all of that. Still what I see kind of strange, all these linesize seem to be pointless (as they do not seem to have any relationship to actual samples stored). It's either a bug in ffmpeg, bug in aac decoder, or weird api that makes these values pointless and actual data sizes have to be calculated from samples count, number of channels and size of each sample.
Clip that I used is temporarily committed to https://github.com/pps83/avcpp/tree/master3 (RobloxAnthemVideo384.mp4)
from avcpp.
doese bytesPerSample come directly from avcodec api?
Short answer: yes.
It's common for sound libs for bytes per sample to return channles * sampleSize.
I deal with ALSA directly, UAC (USB Audio Class): in all this places you should calc full size like: get_bytes_per_sample_for_format(SOME_FORMAT_LIKE_S16BE) * channels * samples_count
. Can you provide some examples of described APIs?
It's either a bug in ffmpeg, bug in aac decoder, or weird api that makes these values pointless and actual data sizes have to be calculated from samples count, number of channels and size of each sample.
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 std::vector::capacity
. I think, that I will provide some API that helps to get actual data size in buffer.
Clip that I used is temporarily committed
Thanks, I take it.
Also, I build with VS2015 and there is a few things that do not compile. I had to make a few changes:
According changes with size_t
... Could you please revert it and try to add:
#include <stddef.h>
at the top of frame.h
? GCC 7.3.1 has no problems with such code.
from avcpp.
Can you provide some examples of described APIs?
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.
from avcpp.
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 Invalid data found when processing input
return from audio decoder at the end of the movie. Last audio packet that goes to decoder produces this error. The packet does not look suspicious or broken.
from avcpp.
Invalid data when decoding a youtube video.
create new task, please.
from avcpp.
.... Can you provide some examples of described APIs?
https://www.fmod.com/docs/api/content/generated/FMOD_CREATESOUNDEXINFO.html
For example decodebuffersize
field is described as:
[w] Optional. Specify 0 to ignore. For streams. This determines the size of the double buffer (in PCM samples) that a stream uses. Use this for user created streams if you want to determine the size of the callback buffer passed to you. Specify 0 to use FMOD's default size which is currently equivalent to 400ms of the sound format created/loaded.
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.
from avcpp.
Related Issues (20)
- CMake: INTERFACE_LIBRARY targets may only have whitelisted properties. HOT 2
- FFmpeg 5.1: fix channel_layout API HOT 1
- Is this project still alive? HOT 1
- Spelling Mistake in Content - "insormation" should be "information" in README HOT 1
- Broken Link in CONTRIBUTING.md - 404 Error
- `api2-decode-encode-video.cpp` example and correct stream tear-down sequence HOT 3
- Decoded frames have invalid PTS
- Copy a stream without transcoding HOT 3
- Take into account the filter size when calculating the delay HOT 1
- Memory leak (duplicate initialization) of all `CodecContext2` derived classes
- example api2-decode fail HOT 9
- Error when using code from api2-remux.cpp sample. HOT 9
- It seems that ffmpeg7.0 is not supported? HOT 4
- About GPU decoding and encoding HOT 8
- How to just use avcpp to write externally compressed data into an output stream? HOT 1
- Missing lookup for dependency Threads
- Why are all the video frames in the output marked as I-frames? HOT 1
- How to decode a buffer of h264 data?
- Can you provide an example of encoding image sequence into video file HOT 1
- Av::Timestamp overflow
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avcpp.