Closed zhoutian94 closed 1 year ago
It depends on what is in that byte[] array.
It depends on what is in that byte[] array.
hi saudet! thanks for you reply, the data in byte array is the container data which name is 'dhav'
That sounds like something supported by FFmpeg.
Try to call recorder.start()
instead of recorder.start(grabber.getFormatContext())
yeah , you are right.
But when i replaced with recorder.start()
,the new error has occurred,
org.bytedeco.javacv.FFmpegFrameRecorder$Exception: No audio output stream (Is audioChannels > 0 and has start() been called?) (For more details, make sure FFmpegLogCallback.set() has been called.)
at org.bytedeco.javacv.FFmpegFrameRecorder.recordSamples(FFmpegFrameRecorder.java:1154)
at org.bytedeco.javacv.FFmpegFrameRecorder.record(FFmpegFrameRecorder.java:1021)
at org.bytedeco.javacv.FFmpegFrameRecorder.record(FFmpegFrameRecorder.java:1010)
at org.jfjy.jvc.Test.convertDHAVtoRTSP(Test.java:55)
at org.jfjy.jvc.Test$1.apply(Test.java:22)
at org.jfjy.jvc.Test$1.apply(Test.java:19)
at org.jfjy.ch2ji.ecctv.dh.module.RealPlayModule$1.invoke(RealPlayModule.java:35)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:585)
at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:616)
then ,I changed recorder.setAudioChannels(0);
to recorder.setAudioChannels(1);
but the error msg is same.
then I tried to ignore audio data by remove recorder.setAudioChannels
and change recorder.setAudioCodec(avcodec.AV_CODEC_ID_AAC);
to recorder.setAudioCodec(avcodec.AV_CODEC_ID_NONE);
but still the same
Please make sure that FFmpegLogCallback.set()
has been called.
What's the messages that you get in the log?
Thanks for your good patience, when i set recorder.setAudioCodec(avcodec.AV_CODEC_ID_NONE);
the logs is :
Info: Input #0, dhav, from 'java.io.ByteArrayInputStream@1e38d9e9':
Info: Duration:
Info: N/A
Info: , start:
Info: 1688981687.000000
Info: , bitrate:
Info: N/A
Info:
Info: Stream #0:0
Info: : Audio: pcm_s16le, 16000 Hz, 1 channels, s16, 256 kb/s
Info:
Warning: [libopenh264 @ 00000256caf5efc0] [OpenH264] this = 0x00000256caf5f940, Warning:layerId(0) doesn't support profile(578), change to UNSPECIFIC profile
Warning: [libopenh264 @ 00000256caf5efc0] [OpenH264] this = 0x00000256caf5f940, Warning:bEnableFrameSkip = 0,bitrate can't be controlled for RC_QUALITY_MODE,RC_BITRATE_MODE and RC_TIMESTAMP_MODE without enabling skip frame.
Info: Output #0, rtsp, to 'rtsp://127.0.0.1:8554/live':
Info: Metadata:
Info: encoder :
Info: Lavf60.3.100
Info:
Info: Stream #0:0
Info: : Video: h264 (Constrained Baseline), yuv420p, 1280x720, q=2-31, 400 kb/s
Info: ,
Info: 30 fps,
Info: 90k tbn
Info:
org.bytedeco.javacv.FFmpegFrameRecorder$Exception: No audio output stream (Is audioChannels > 0 and has start() been called?) (For more details, make sure FFmpegLogCallback.set() has been called.)
……
when i replace it to recorder.setAudioChannels(1); recorder.setAudioCodec(avcodec.AV_CODEC_ID_PCM_S16LE);
, the log is
Info: Input #0, dhav, from 'java.io.ByteArrayInputStream@1e38d9e9':
Info: Duration:
Info: N/A
Info: , start:
Info: 1688982097.000000
Info: , bitrate:
Info: N/A
Info:
Info: Stream #0:0
Info: : Audio: pcm_s16le, 16000 Hz, 1 channels, s16, 256 kb/s
Info:
Warning: [libopenh264 @ 000002735a23efc0] [OpenH264] this = 0x000002735a23e6c0, Warning:layerId(0) doesn't support profile(578), change to UNSPECIFIC profile
Warning: [libopenh264 @ 000002735a23efc0] [OpenH264] this = 0x000002735a23e6c0, Warning:bEnableFrameSkip = 0,bitrate can't be controlled for RC_QUALITY_MODE,RC_BITRATE_MODE and RC_TIMESTAMP_MODE without enabling skip frame.
Info: Output #0, rtsp, to 'rtsp://127.0.0.1:8554/live':
Info: Metadata:
Info: encoder :
Info: Lavf60.3.100
Info:
Info: Stream #0:0
Info: : Video: h264 (Constrained Baseline), yuv420p, 1280x720, q=2-31, 400 kb/s
Info: ,
Info: 30 fps,
Info: 90k tbn
Info:
Info: Stream #0:1
Info: : Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
Info:
Info: Input #0, dhav, from 'java.io.ByteArrayInputStream@6221f555':
Info: Duration:
Info: N/A
Info: , start:
Info: 1688982097.000000
Info: , bitrate:
Info: N/A
Info:
Info: Stream #0:0
Info: : Audio: pcm_s16le, 16000 Hz, 1 channels, s16, 256 kb/s
Info:
org.bytedeco.javacv.FFmpegFrameRecorder$Exception: No audio output stream (Is audioChannels > 0 and has start() been called?) (For more details, make sure FFmpegLogCallback.set() has been called.)
looks still the same
You might want to try libx264 instead of libopenh264.
Is there a possible to convert byte[] of container data that continually received to RTSP using JavaCV。
I tried as follow but got an error i can't fix it :
can anyone tell me how to do please