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

Could not open audio codec #291

Closed
kostyaev opened this issue Dec 21, 2015 · 8 comments
Closed

Could not open audio codec #291

kostyaev opened this issue Dec 21, 2015 · 8 comments
Labels

Comments

@kostyaev
Copy link

After I call start() on a recorder, I get the following error:

org.bytedeco.javacv.FrameRecorder$Exception: avcodec_open2() error -22: Could not open audio codec.

This happens with a video having the following info:

Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 9732 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream #0:1: Audio: pcm_u8 ([1][0][0][0] / 0x0001), 11024 Hz, 1 channels, u8, 88 kb/s

Other media content was processed normally so far.
I've tried to not set audio codec as was suggested here: #72, unfortunately this didn't help. Could you give me any idea on how to fix it? Thank you in advance.

@saudet
Copy link
Member

saudet commented Dec 27, 2015

What happens if you call setAudioChannels(0) before calling start()?

@saudet
Copy link
Member

saudet commented Jan 16, 2016

Could you enable debug messages in the log and see if it gives us any clues as to why the audio codec doesn't want to open?

@kostyaev
Copy link
Author

If I setAudioChannels(0) before calling start() I will have the following output:

Input #0, avi, from 'video/5670049ce4b042b2edff5bf3.avi':
  Duration: 00:01:22.00, start: 0.000000, bitrate: 9823 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 9732 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
    Metadata:
      Make            : FUJIFILM
      Model           : FinePix S3400
      Orientation     :     1
      DateTime        : 2012:09:13 15:07:34
      JPEGInterchangeFormat:     672
      JPEGInterchangeFormatLength:    3444
      Copyright       :     
      DateTimeOriginal: 2012:09:13 15:07:34
      DateTimeDigitized: 2012:09:13 15:07:34
      MakerNote       : 
                      :  70,  85,  74,  73,  70,  73,  76,  77,  12,   0,   0,   0,  18,   0,   0,   0
                      :   7,   0,   4,   0,   0,   0,  48,  49,  51,  48,  16,   0,   2,   0,  31,   0
                      :   0,   0,   2,   1,   0,   0,   0,  16,   2,   0,   8,   0,   0,   0,  34,   1
                      :   0,   0,   1,  16,   3,   0,   1,   0,   0,   0,   3,   0,   0,   0,   2,  16
                      :   3,   0,   1,   0,   0,   0,   0,   0,   0,   0,  16,  16,   3,   0,   1,   0
                      :   0,   0,   2,   0,   0,   0,  17,  16,  10,   0,   1,   0,   0,   0,  42,   1
                      :   0,   0,  32,  16,   3,   0,   1,   0,   0,   0,   0,   0,   0,   0,  33,  16
                      :   3,   0,   1,   0,   0,   0,   0,   0,   0,   0,  48,  16,   3,   0,   1,   0
                      :   0,   0,   0,   0,   0,   0,  49,  16,   3,   0,   1,   0,   0,   0,   0,   0
                      :   0,   0,   0,  17,   3,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,  18
                      :   3,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,  19,   3,   0,   1,   0
                      :   0,   0,   0,   0,   0,   0,   1,  19,   3,   0,   1,   0,   0,   0,   0,   0
                      :   0,   0,   2,  19,   3,   0,   1,   0,   0,   0,   0,   0,   0,   0,  48,  20
                      :   7,   0, 129,   0,   0,   0,  50,   1,   0,   0,  49,  20,   4,   0,   1,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,  53,  57,  50,  68,  51,  56,  51,  55,  51,  51,  51,  49,  49,  49
                      :  48,  53,  50,  56,  69,  68,  55,  53,  49,  84,  82,  53,  56,  55,  53,  57
                      :   0,   0,  78,  79,  82,  77,  65,  76,  32,   0,   0,   0,   0,   0, 100,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0
      title           : FUJIFILM AVI STREAM 0100
    Stream #0:1: Audio: pcm_u8 ([1][0][0][0] / 0x0001), 11024 Hz, 1 channels, u8, 88 kb/s
640.0,480.0,30.00030000300003,8.0,9732656.0,65541.0,88192.0,1.0
Output #0, hls, to 'video/result.mp4':
    Stream #0:0: Video: h264 (libx264), yuv420p, 480x360, q=-1--1, 614 kb/s, 30 tbn, 30 tbc
[libx264 @ 0x7fad04303800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7fad04303800] profile High, level 3.0
Exception in thread "main" org.bytedeco.javacv.FrameRecorder$Exception: No audio output stream (Is audioChannels > 0 and has start() been called?)
    at org.bytedeco.javacv.FFmpegFrameRecorder.recordSamples(FFmpegFrameRecorder.java:812)
    at org.bytedeco.javacv.FFmpegFrameRecorder.record(FFmpegFrameRecorder.java:690)
    at org.bytedeco.javacv.FFmpegFrameRecorder.record(FFmpegFrameRecorder.java:679)

@saudet
Copy link
Member

saudet commented Jan 18, 2016

And what does it look like when you do setAudioChannels(1)?

@kostyaev
Copy link
Author

It outputs the following in that case (setAudioChannels(1)):

Input #0, avi, from 'video/5670049ce4b042b2edff5bf3.avi':
  Duration: 00:01:22.00, start: 0.000000, bitrate: 9823 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 9732 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
    Metadata:
      Make            : FUJIFILM
      Model           : FinePix S3400
      Orientation     :     1
      DateTime        : 2012:09:13 15:07:34
      JPEGInterchangeFormat:     672
      JPEGInterchangeFormatLength:    3444
      Copyright       :     
      DateTimeOriginal: 2012:09:13 15:07:34
      DateTimeDigitized: 2012:09:13 15:07:34
      MakerNote       : 
                      :  70,  85,  74,  73,  70,  73,  76,  77,  12,   0,   0,   0,  18,   0,   0,   0
                      :   7,   0,   4,   0,   0,   0,  48,  49,  51,  48,  16,   0,   2,   0,  31,   0
                      :   0,   0,   2,   1,   0,   0,   0,  16,   2,   0,   8,   0,   0,   0,  34,   1
                      :   0,   0,   1,  16,   3,   0,   1,   0,   0,   0,   3,   0,   0,   0,   2,  16
                      :   3,   0,   1,   0,   0,   0,   0,   0,   0,   0,  16,  16,   3,   0,   1,   0
                      :   0,   0,   2,   0,   0,   0,  17,  16,  10,   0,   1,   0,   0,   0,  42,   1
                      :   0,   0,  32,  16,   3,   0,   1,   0,   0,   0,   0,   0,   0,   0,  33,  16
                      :   3,   0,   1,   0,   0,   0,   0,   0,   0,   0,  48,  16,   3,   0,   1,   0
                      :   0,   0,   0,   0,   0,   0,  49,  16,   3,   0,   1,   0,   0,   0,   0,   0
                      :   0,   0,   0,  17,   3,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,  18
                      :   3,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,  19,   3,   0,   1,   0
                      :   0,   0,   0,   0,   0,   0,   1,  19,   3,   0,   1,   0,   0,   0,   0,   0
                      :   0,   0,   2,  19,   3,   0,   1,   0,   0,   0,   0,   0,   0,   0,  48,  20
                      :   7,   0, 129,   0,   0,   0,  50,   1,   0,   0,  49,  20,   4,   0,   1,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,  53,  57,  50,  68,  51,  56,  51,  55,  51,  51,  51,  49,  49,  49
                      :  48,  53,  50,  56,  69,  68,  55,  53,  49,  84,  82,  53,  56,  55,  53,  57
                      :   0,   0,  78,  79,  82,  77,  65,  76,  32,   0,   0,   0,   0,   0, 100,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
                      :   0,   0,   0,   0
      title           : FUJIFILM AVI STREAM 0100
    Stream #0:1: Audio: pcm_u8 ([1][0][0][0] / 0x0001), 11024 Hz, 1 channels, u8, 88 kb/s
640.0,480.0,30.00030000300003,8.0,9732656.0,65541.0,88192.0,1.0
Output #0, hls, to 'video/result.mp4':
    Stream #0:0: Video: h264 (libx264), yuv420p, 480x360, q=-1--1, 614 kb/s, 30 tbn, 30 tbc
    Stream #0:1: Audio: aac, 11024 Hz, mono, fltp, 65 kb/s
[libx264 @ 0x7fbbc3b42000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7fbbc3b42000] profile High, level 3.0
[aac @ 0x7fbbc3345a00] Specified sample rate 11024 is not supported
[libx264 @ 0x7fbbc3b42000] final ratefactor: 27.01
Exception in thread "main" org.bytedeco.javacv.FrameRecorder$Exception: avcodec_open2() error -22: Could not open audio codec.
    at org.bytedeco.javacv.FFmpegFrameRecorder.startUnsafe(FFmpegFrameRecorder.java:583)
    at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:288)

@saudet
Copy link
Member

saudet commented Jan 18, 2016

It explains quite clearly why it fails:

[aac @ 0x7fbbc3345a00] Specified sample rate 11024 is not supported

So, try to use a different sample rate or another codec that supports that sample rate.

@saudet saudet closed this as completed Jan 18, 2016
@vvavepacket
Copy link

how do we enable debug messages? Mine only shows audio codec issue but no debug messages similar to above

@saudet
Copy link
Member

saudet commented May 21, 2017 via email

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