Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (mCopyVideo) {
- videoExtractor = createExtractor();
- int videoInputTrack = getAndSelectVideoTrackIndex(videoExtractor);
- MediaFormat inputFormat = videoExtractor.getTrackFormat(videoInputTrack);
- Log.i("extractor_vid_in_format", inputFormat + "");
- if(inputFormat.containsKey(MediaFormat.KEY_FRAME_RATE))
- {
- originalVideoFrameRate = inputFormat.getInteger(MediaFormat.KEY_FRAME_RATE);
- timestampConstant = 1000000/originalVideoFrameRate;
- }
- else
- {
- videoExtractor.seekTo(33333, MediaExtractor.SEEK_TO_CLOSEST_SYNC);
- Log.i("no_framerate_variable", videoExtractor.advance()+"");
- videoExtractor.seekTo(0, MediaExtractor.SEEK_TO_CLOSEST_SYNC);
- //originalVideoFrameRate = inputFormat.getInteger(MediaFormat.KEY_FRAME_RATE);
- //timestampConstant = 1000000/originalVideoFrameRate;
- }
- int testBitRate = (int)((mWidth * mHeight * OUTPUT_VIDEO_FRAME_RATE) * 0.07 * 2);
- //the last variable is the motion factor, set to 4 just to be safe.
- MediaFormat outputVideoFormat = MediaFormat.createVideoFormat(
- OUTPUT_VIDEO_MIME_TYPE, mWidth, mHeight);
- outputVideoFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT,
- OUTPUT_VIDEO_COLOR_FORMAT);
- //outputVideoFormat.setInteger(MediaFormat.KEY_BIT_RATE, OUTPUT_VIDEO_BIT_RATE);
- outputVideoFormat.setInteger(MediaFormat.KEY_BIT_RATE, testBitRate);
- outputVideoFormat.setInteger(MediaFormat.KEY_FRAME_RATE, OUTPUT_VIDEO_FRAME_RATE);
- //outputVideoFormat.setInteger(MediaFormat.KEY_FRAME_RATE, testFrameRate);
- outputVideoFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, OUTPUT_VIDEO_IFRAME_INTERVAL);
- if (VERBOSE)
- Log.d(TAG, "projected_encoder_vid_out_format: " + outputVideoFormat);
- AtomicReference<Surface> inputSurfaceReference = new AtomicReference<Surface>();
- videoEncoder = createVideoEncoder(videoCodecInfo,
- outputVideoFormat, inputSurfaceReference);
- inputSurface = new InputSurface(inputSurfaceReference.get());
- inputSurface.makeCurrent();
- outputSurface = new OutputSurface();
- outputSurface.changeFragmentShader(FRAGMENT_SHADER);
- videoDecoder = createVideoDecoder(inputFormat, outputSurface.getSurface());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement