Comments (8)
Hi,
I'm guessing that your AAC encoding problem that is causing the garbles is that the encoder requires data to be submitted as (typically) 1024 samples. In the past I have written a 'dicer' buffer to achieve this. You will find an example in beamstreams.js (Line 28 onwards) if that is any help.
As for the encoder creation crash, I have found that the AAC codec doesn't provide an array of supported profiles as normally expected and the code doesn't handle this correctly, hence the crash. I'll fix the crash in a future update but using the numeric value (1 in this case) avoids this problem and worked for me, giving the correct profile when read back from the encoder and the codecpar in the resulting muxer stream having used your creation code.
I'm afraid you will also run into the problem pointed out in #35 - I haven't done the work to support the bitstream filters.
Good luck!
from beamcoder.
Thanks for the hint. That dicer helps a little bit. On one stream it at least renders an audio stream that somewhat resembles the original (but with distortion). On another stream it gives me the same problems I had when I tried to transcode to AAC using the pipeline config: it starts spewing [aac @ 0x6d6fc0] Queue input is backward in time
and [aac @ 0x6d6fc0] Input contains (near) NaN/+-Inf
after the first couple of frames.
So then I tried adding a asetnsamples=n=1024:p=1
filter instead, which works better; the resulting frames are all 1024 samples and there are no errors with either input stream. The sound is perfect this time, but the video is still sped up.
EDIT: I found the issue with the incorrect profile in codecpar when opening the resulting file. Copying the extradata
property from the encoder to the codecpar in the stream fixes it.
from beamcoder.
After my comment yesterday I tried to use my scratch mp4 maker and found the same Nan/Inf problem. I eventually tracked it down to a line of code in the dicer that presumably is getting different data with the updated version of FFmpeg. I have fixed that now and it all seems to work as expected with clean audio.
asetnsamples=n=1024:p=1
is a good choice to replace the hand rolled dicer - I hadn't found that filter when I was last playing here but I have used it successfully since.
The crash at the end is annoying. I had a brief look at the code and apart from a cryptic comment next to it I can't get much idea of what is causing it to go wrong. I had a quick look at your latest code and wondered if it could be caused by you having missed an await on the recodeAndWrite
call at the end so the flush might be getting in before the last encode.
from beamcoder.
Yup, it's the await. Just found it too. Still looking into the video timing issue. I'm logging the pts for each packet upon writing and it seems to look fine, so I'm not sure yet what's going wrong.
from beamcoder.
Found the issue with the timing as well now. Apparently the timebase is forcefully set to [1,16000] by the muxer. Compensating for that fixes it. Strange that the stream resulting from muxer.newStream doesn't reflect that new timebase correctly, but hardcoding it to [1,16000] works.
from beamcoder.
Great - I'm glad its all working now.
from beamcoder.
Me too, thanks for the assistance!
from beamcoder.
I'm sorry.. I'm decoding aac frames from raw pcm and raw video frames. I receive the same error message "Input contains (near) NaN/+-Inf" I tried to make an example to reproduce the issue with a virgin frame of 1024 samples. If you try to run it you receive this error. Not always but often.. I don't understand what I'm doing wrong.. can you help me?
const beamcoder = require('beamcoder');
let encParamsAudio = {
name: 'aac',
time_base: [1, 48000],
sample_fmt: 'fltp',
sample_rate: 48000,
bit_rate: 192000,
channel_layout: 'stereo',
channels: 2
}
async function run() {
let encoderAudio = await beamcoder.encoder(encParamsAudio);
for (var i = 0; i < 200; i++) {
let destFrameAudio = beamcoder.frame({
channels: 2,
nb_samples: 1024,
format: 'fltp',
channel_layout: 'stereo',
sample_rate: 48000,
pkt_size: 1024 * 4 * 2
}).alloc();
let packetsAudio = await encoderAudio.encode(destFrameAudio);
}
}
run();
from beamcoder.
Related Issues (20)
- Decoder hwaccel flag is too simplified
- Ubuntu 20.04 npm install fails, can't find PPA HOT 3
- Installation instructions HOT 3
- Permission to fork and create a LGPL variant of your project HOT 1
- Encoder message error catching HOT 1
- Releasing beamcoder-stream Nodejs Stream API HOT 1
- Why is the project abandoned? HOT 2
- Is there a way to get AAC data out of audio as ADTS?
- Is there a limit on number of demuxers? HOT 1
- Hardware Encoding Example Needed
- Please create encode_aac.js example to show how to create AAC frames from raw PCM data. HOT 3
- Will support arm64? HOT 1
- Memory leak on Windows 10/Ubuntu 20.04 LTS - x64
- Error splitting the input into NAL units. HOT 2
- How to use av_rescale_q_rnd/av_rescale_q in beamcoder ?
- Using pkg-config or similar for link dependencies
- Memory error: double free or corruption at format.cc HOT 1
- failed to install version v0.7.1 HOT 1
- A Typescript port ready for testing.
- Hardware accelerated filters are not working
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 beamcoder.