hello
I try to push the local mp4 file into rtmp.But the following error occurred:
org.bytedeco.javacv.FrameRecorder$Exception: avformat_write_header error() error -1094995529: Could not write header to 'null' at org.bytedeco.javacv.FFmpegFrameRecorder.startUnsafe(FFmpegFrameRecorder.java:952) at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:431) at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:426) at com.junction.Test.main(Test.java:53)
This is my code:
InputStream in = new FileInputStream("C:\\Users\\Administrator\\Desktop\\test1.mp4");
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(in, 0);
grabber.setOption("stimeout", "2000000");
grabber.setVideoOption("vcodec", "copy");
grabber.setFormat("mpeg");
grabber.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
grabber.setVideoCodec(avcodec.AV_CODEC_ID_H264);
grabber.start();
System.out.println("width:" + grabber.getImageWidth() + " height:" + grabber.getImageHeight());
FFmpegFrameRecorder recorder = new FFmpegFrameRecorder("rtmp://127.0.0.1:1935/live/stream33",
grabber.getImageWidth(), grabber.getImageHeight(), 0);
recorder.setInterleaved(true);
recorder.setVideoOption("crf", "25");
recorder.setVideoBitrate(grabber.getVideoBitrate());
recorder.setVideoCodec(grabber.getVideoCodec());
recorder.setFormat("flv");
recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
recorder.setFrameRate(grabber.getFrameRate());
recorder.setGopSize((int) grabber.getFrameRate() * 2);
AVFormatContext fc = null;
fc = grabber.getFormatContext();
recorder.start(fc);
This is the print log:
Error: [mov,mp4,m4a,3gp,3g2,mj2 @ 0000000000501b00] stream 0, offset 0x30: partial file
Warning: [mov,mp4,m4a,3gp,3g2,mj2 @ 0000000000501b00] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 1920x1080, 1075 kb/s): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Info: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'java.io.BufferedInputStream@724af044':
Info: Metadata:
Info: major_brand :
Info: isom
Info:
Info: minor_version :
Info: 512
Info:
Info: compatible_brands:
Info: isomiso2avc1mp41
Info:
Info: encoder :
Info: Lavf57.25.100
Info:
Info: Duration:
Info: 00:02:42.38
Info: , start:
Info: 0.000000
Info: , bitrate:
Info: N/A
Info:
Info: Stream #0:0
Info: (und)
Info: : Video: h264 (avc1 / 0x31637661), none, 1920x1080, 1075 kb/s
Info: ,
Info: 30 fps,
Info: 30 tbr,
Info: 15360 tbn,
Info: 30720 tbc
Info: (default)
Info:
Info: Metadata:
Info: handler_name :
Info: VideoHandler
Info:
Info: Stream #0:1
Info: (und)
Info: : Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 193 kb/s
Info: (default)
Info:
Info: Metadata:
Info: handler_name :
Info: SoundHandler
Info:
width:1920 height:1080
rtmp://127.0.0.1:1935/live/stream33
Warning: [flv @ 0000000059067ac0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Error: [flv @ 0000000059067ac0] Tag avc1 incompatible with output codec id '27' ([7][0][0][0])
org.bytedeco.javacv.FrameRecorder$Exception: avformat_write_header error() error -1094995529: Could not write header to 'null'
at org.bytedeco.javacv.FFmpegFrameRecorder.startUnsafe(FFmpegFrameRecorder.java:952)
at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:431)
at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:426)
at com.junction.Test.main(Test.java:53)
hello I try to push the local mp4 file into rtmp.But the following error occurred:
org.bytedeco.javacv.FrameRecorder$Exception: avformat_write_header error() error -1094995529: Could not write header to 'null' at org.bytedeco.javacv.FFmpegFrameRecorder.startUnsafe(FFmpegFrameRecorder.java:952) at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:431) at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:426) at com.junction.Test.main(Test.java:53)
This is my code:
This is the print log:
Can you help me? Thanks!