Skip to content
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

error -22: Could not encode audio packet. #1294

Closed
yuzhimin201 opened this issue Sep 6, 2019 · 11 comments
Closed

error -22: Could not encode audio packet. #1294

yuzhimin201 opened this issue Sep 6, 2019 · 11 comments
Labels

Comments

@yuzhimin201
Copy link

Hi guys!I got a problem here, when i use ffmpegframeRecorder, i input a mp3 audio and output as outputstream, but i will block at recorder.stop()the error is could not encode audio packet

Input #0, mp3, from 'hua.mp3':

Metadata:
encoder : Lavf58.11.101
Duration: 00:02:15.00, start: 0.069063, bitrate: 128 kb/s
Stream #0:0: Audio: mp3, 16000 Hz, mono, fltp, 128 kb/s
[mp3float @ 0x7f49f84b9f80] Could not update timestamps for skipped samples.
Output #0, mp3, to '':
Metadata:
TSSE : Lavf58.20.100
Stream #0:0: Audio: mp3, 16000 Hz, mono, fltp, 64 kb/s
[libmp3lame @ 0x7f49f8f8e280] inadequate AVFrame plane padding
[libmp3lame @ 0x7f49f8f8e280] 4 frames left in the queue on closing
[2019-09-06 17:30:00.321] ERROR [stream-service-1] StreamProcessService.java:131 - avcodec_encode_audio2() error -22: Could not encode audio packet.

The source code is :

FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(outputStream, 1);
recorder.setFormat("mp3");
recorder.setFrameRate(grabber.getFrameRate());
recorder.setAudioCodec(avcodec.AV_CODEC_ID_MP3);
recorder.setSampleRate(grabber.getSampleRate());
it will crash when i call recoder.stop()

@saudet
Copy link
Member

saudet commented Sep 6, 2019

Running that code doesn't result in any error message. You'll need to provide more than that.

@yuzhimin201
Copy link
Author

FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(url);
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(url);
grabber.startUnsafe();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(outputStream, 1);

recorder.setFormat("mp3");
recorder.setFrameRate(grabber.getFrameRate());
recorder.setAudioCodec(avcodec.AV_CODEC_ID_MP3);
recorder.setSampleRate(grabber.getSampleRate());

//doAudio, doVideo, doProcessing, keyFrames
frame = grabber.grabFrame(true, false, true, false);
recorder.startUnsafe();
recorder.record(frame);
recorder.stop();

@saudet
Copy link
Member

saudet commented Sep 6, 2019

Could you upload here a sample file that fails instead of "url"?

@yuzhimin201
Copy link
Author

hua.zip

@sep19w
Copy link

sep19w commented Sep 6, 2019

And if we remove: recorder.stop(), it will run.

@sep19w
Copy link

sep19w commented Sep 6, 2019

so if there is any risk when remove [recorder.stop]? or any other advise?

@saudet saudet added the bug label Sep 7, 2019
saudet added a commit that referenced this issue Sep 7, 2019
… (issue #1294)

 * Upgrade dependencies for OpenBLAS 0.3.7
@saudet
Copy link
Member

saudet commented Sep 7, 2019

I found the problem and it's now fixed.
Please give it a try with 1.5.2-SNAPSHOT:
http://bytedeco.org/builds/

@sep19w
Copy link

sep19w commented Sep 7, 2019

Thank you very much! It works! One more question, when will this version officially work? Then we can use mavenCentral

@saudet
Copy link
Member

saudet commented Sep 7, 2019 via email

@sep19w
Copy link

sep19w commented Sep 7, 2019

Ok! Got it! Thanks.

@saudet
Copy link
Member

saudet commented Nov 6, 2019

JavaCV 1.5.2 has been released with the fix! Enjoy and thanks for reporting this issue.

@saudet saudet closed this as completed Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants