Advertisement
Guest User

Paste for the problematic MediaExtractor

a guest
Aug 30th, 2016
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.71 KB | None | 0 0
  1.             if (mCopyVideo) {
  2.                 videoExtractor = createExtractor();
  3.                 int videoInputTrack = getAndSelectVideoTrackIndex(videoExtractor);
  4.  
  5.                 MediaFormat inputFormat = videoExtractor.getTrackFormat(videoInputTrack);
  6.                 Log.i("extractor_vid_in_format", inputFormat + "");
  7.  
  8.                 if(inputFormat.containsKey(MediaFormat.KEY_FRAME_RATE))
  9.                 {
  10.                     originalVideoFrameRate = inputFormat.getInteger(MediaFormat.KEY_FRAME_RATE);
  11.                     timestampConstant = 1000000/originalVideoFrameRate;
  12.                 }
  13.                 else
  14.                 {
  15.                     videoExtractor.seekTo(33333, MediaExtractor.SEEK_TO_CLOSEST_SYNC);
  16.                     Log.i("no_framerate_variable", videoExtractor.advance()+"");
  17.                     videoExtractor.seekTo(0, MediaExtractor.SEEK_TO_CLOSEST_SYNC);
  18.                     //originalVideoFrameRate = inputFormat.getInteger(MediaFormat.KEY_FRAME_RATE);
  19.                     //timestampConstant = 1000000/originalVideoFrameRate;
  20.                 }
  21.                 int testBitRate = (int)((mWidth * mHeight * OUTPUT_VIDEO_FRAME_RATE) * 0.07 * 2);
  22.                 //the last variable is the motion factor, set to 4 just to be safe.
  23.  
  24.                 MediaFormat outputVideoFormat = MediaFormat.createVideoFormat(
  25.                         OUTPUT_VIDEO_MIME_TYPE, mWidth, mHeight);
  26.                 outputVideoFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT,
  27.                         OUTPUT_VIDEO_COLOR_FORMAT);
  28.                 //outputVideoFormat.setInteger(MediaFormat.KEY_BIT_RATE, OUTPUT_VIDEO_BIT_RATE);
  29.                 outputVideoFormat.setInteger(MediaFormat.KEY_BIT_RATE, testBitRate);
  30.                 outputVideoFormat.setInteger(MediaFormat.KEY_FRAME_RATE, OUTPUT_VIDEO_FRAME_RATE);
  31.                 //outputVideoFormat.setInteger(MediaFormat.KEY_FRAME_RATE, testFrameRate);
  32.                 outputVideoFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, OUTPUT_VIDEO_IFRAME_INTERVAL);
  33.  
  34.                 if (VERBOSE)
  35.                     Log.d(TAG, "projected_encoder_vid_out_format: " + outputVideoFormat);
  36.  
  37.                 AtomicReference<Surface> inputSurfaceReference = new AtomicReference<Surface>();
  38.  
  39.                 videoEncoder = createVideoEncoder(videoCodecInfo,
  40.                         outputVideoFormat, inputSurfaceReference);
  41.  
  42.                 inputSurface = new InputSurface(inputSurfaceReference.get());
  43.                 inputSurface.makeCurrent();
  44.  
  45.                 outputSurface = new OutputSurface();
  46.                 outputSurface.changeFragmentShader(FRAGMENT_SHADER);
  47.  
  48.                 videoDecoder = createVideoDecoder(inputFormat, outputSurface.getSurface());
  49.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement