当我使用JavaCV库(FFmpegFrameGrabber + FFmpegFrameRecorde)尝试将dhav码流转为rtsp的时候,出现了以下报错:文章来源:https://www.toymoban.com/news/detail-602726.html
Error: [rtsp @ 0000002318df7c30] AAC with no global headers is currently not supported.
Exception in thread "pool-1-thread-2" java.lang.RuntimeException: org.bytedeco.javacv.FFmpegFrameRecorder$Exception: avformat_write_header error() error -1094995529: Could not write header to 'rtsp://127.0.0.1:8554/myapp/orange2' (For more details, make sure FFmpegLogCallback.set() has been called.)
at org.jfjy.jvc.GetBytes2PipedStreamAndPushRTMP$2.run(GetBytes2PipedStreamAndPushRTMP.java:116)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.bytedeco.javacv.FFmpegFrameRecorder$Exception: avformat_write_header error() error -1094995529: Could not write header to 'rtsp://127.0.0.1:8554/myapp/orange2' (For more details, make sure FFmpegLogCallback.set() has been called.)
at org.bytedeco.javacv.FFmpegFrameRecorder.startUnsafe(FFmpegFrameRecorder.java:969)
at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:437)
at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:432)
at org.jfjy.jvc.GetBytes2PipedStreamAndPushRTMP.grabAndPush(GetBytes2PipedStreamAndPushRTMP.java:215)
at org.jfjy.jvc.GetBytes2PipedStreamAndPushRTMP$2.run(GetBytes2PipedStreamAndPushRTMP.java:100)
... 3 more
意思就是缺少全局头部信息的AAC编码器不被支持,那么給它添加一些配置信息即可。文章来源地址https://www.toymoban.com/news/detail-602726.html
//我在这个的基础上
recorder.setAudioCodec(AV_CODEC_ID_AAC);
//添加了这行配置就好了
recorder.setAudioBitrate(grabber.getAudioBitrate());
到了这里,关于JavaCV error AAC with no global headers is currently not supported的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!