Skip to content

Add PCMU for decoder #7

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

yujonglee
Copy link

I'm working on a project that requires decoding PCMU to PCM. I've attempted to add this feature, but I'm encountering an issue. When I run mix test, my new test fails and I'm unsure as to why.

For reference, input.ul was created using the ffmpeg -i input.al -c:a pcm_mulaw input.ul command.

I would appreciate any insights or suggestions you may have.

Thank you.

@sgfn
Copy link
Member

sgfn commented Mar 27, 2024

Hey @yujonglee, thanks for the contribution! Apologies for the late response.

The issue you've encountered is caused by the different assumptions made by PCMU and PCMA decoders used in ffmpeg. Since G.711 is a lossy codec, part of the information gets lost when encoding, and the decoders choose to "fill in the gaps" in different ways, making the result files slightly different.

To fix it, rename reference-s16le.raw e.g. to pcma-reference-s16le.raw and create the new set of PCMU fixtures like this:

ffmpeg -f s16le -ar 8000 -ac 1 -i test/fixtures/encode/input-s16le.raw -c:a pcm_mulaw test/fixtures/encode/reference.ul
cp test/fixtures/encode/reference.ul test/fixtures/decode/input.ul
ffmpeg -f mulaw -ar 8000 -ac 1 -i test/fixtures/decode/input.ul -c:a pcm_s16le -f s16le test/fixtures/decode/pcmu-reference-s16le.raw

Verify both of these files play correctly (e.g. using ffplay) and you're good to go.

Would you be willing to implement this feature for the encoder as well? We'd be really grateful, as it would help us ensure the integrity of this library by adding corresponding features to both elements at the same time.

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

Successfully merging this pull request may close these issues.

2 participants