Open suldashi opened 4 years ago
Hi, While I can't at the moment understand what is going wrong, I have a some suggestions for you that may help get past this.
Firstly, beamcoder.decoder creation doesn't do anything with request_sample_fmt
. You will need to set this property on the object after creation : decoder.request_sample_fmt = outFormat
.
Secondly, you are not checking the stream index of packets from the demuxer before decoding eg: if (packet && packet.stream_index == 0) try {...}
. The stream_index value you pass into decoder creation is only used to select the stream to be used for setting up the codec parameters and doesn't set up the decoder to ignore other streams. If your MP3 file has multiple streams this could cause some problems.
Finally I am concerned that the call stack appears to show two filterExecute calls in progress at the same time, which is not a good idea. I can't see a problem in your code but it would be worth checking that you only have one request outstanding at a time.
Good luck!
I believe there's something wrong with the MP3 decoder in particular. I solved my problem by adding a fake WAV header to the decoded data and running it through a WAV decoder. I finally got proper frame that I sent to the resampler and got the expected result.
However, I could not get the OPUS encoder to work, all packets had length 0. I think I am missing some options, but that's an issue for some other place.
I am making a universal audio converter using Beamcoder, and I have successfully managed to set up the audio decoder. The idea is also to take these decoded frames and run them through a resampler before encoding them in the final step (not shown here).
I am having trouble with Beamcoder crashing with some cryptic errors if the decoded frames come from an MP3 file. Frames from a FLAC file don't give me any issues.
Here's the code:
The
decodeAudioFile
function works properly, as it decodes the audio from MP3 or FLAC into PCM frames. When I put these PCM frames on the resampler, FLAC works fine but MP3 fails with the following console output:The output gets cut off at the end in the middle of the line, I made no mistake when copying.