0

fadden I hope you're listening.

So I've been trying to encode some preview frames from the camera, to eventually stream over rtmp as flv. However, when filling out the avcdecoderconfigurationrecord in the avc sequence header, I have to give the SPS and PPS bytes. BUT, the SPS given to me from the encoder is missing the VUI Params (the flag is set to 0), which dictate the frame rate, etc. So I am wondering, does the encoder ever give this information, or is there any other way to get my little paws on this info?

mEncoder = MediaCodec.createEncoderByType("video/avc");//MediaCodec.createByCodecName(info.getName());

MediaFormat mediaFormat = MediaFormat.createVideoFormat("video/avc", 1920, 1080);
mediaFormat.setInteger(MediaFormat.KEY_BIT_RATE, BIT_RATE);
mediaFormat.setInteger(MediaFormat.KEY_FRAME_RATE, FPS);
mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar);
mediaFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 5);

mEncoder.configure(mediaFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
mEncoder.start();

I am able to get the dimensions in the SPS, but the frames per second always says infinity when I view it with my VLC player.

fadden
  • 51,356
  • 5
  • 116
  • 166
  • MediaCodec supports variable-frame-rate video. As far as I know, the frame timing is only in the .mp4, not in the H.264 stream. KEY_FRAME_RATE and KEY_I_FRAME_INTERVAL work together to determine how often sync frames appear, but don't otherwise affect the output. – fadden Dec 16 '15 at 17:09
  • Thanks for letting me know. Oddly enough, I was able to get the h264 video data to play as an flv (without vui params), but only in VLC on Mac OSX, it will not play in VLC on Linux. – user2324417 Dec 17 '15 at 21:03

0 Answers0