android.media.MediaMuxer Java Examples

The following examples show how to use android.media.MediaMuxer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SurfaceEncoder.java    From AndroidVideoSamples with Apache License 2.0 7 votes vote down vote up
private void prepareEncoder() {
   mBufferInfo = new MediaCodec.BufferInfo();

   MediaFormat format = MediaFormat.createVideoFormat( MIME_TYPE, mSource.getWidth(), mSource.getHeight() );

   format.setInteger( MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface );
   format.setInteger( MediaFormat.KEY_BIT_RATE, mBitRate );
   format.setInteger( MediaFormat.KEY_FRAME_RATE, FRAME_RATE );
   format.setInteger( MediaFormat.KEY_I_FRAME_INTERVAL, IFRAME_INTERVAL );

   mEncoder = MediaCodec.createEncoderByType( MIME_TYPE );
   mEncoder.configure( format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE );
   mSurface = mEncoder.createInputSurface();
   mEncoder.start();

   try {
      mMuxer = new MediaMuxer( mUri.toString(), MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4 );
   } catch ( IOException ioe ) {
      throw new RuntimeException( "MediaMuxer creation failed", ioe );
   }

   mTrackIndex = -1;
   mMuxerStarted = false;
}
 
Example #2
Source File: AndroidMuxer.java    From cineio-broadcast-android with MIT License 6 votes vote down vote up
@Override
public void prepare(EncodingConfig config) {
    super.prepare(config);

    try {
        switch (config.getFormat()) {
            case MPEG4:
                mMuxer = new MediaMuxer(config.getOutputPath(), MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
                break;
            default:
                throw new IllegalArgumentException("Unrecognized format!");
        }
    } catch (IOException e) {
        throw new RuntimeException("MediaMuxer creation failed", e);
    }

}
 
Example #3
Source File: GPUEncoder.java    From LiveMultimedia with Apache License 2.0 6 votes vote down vote up
/********************************************************************************
 * Create a MediaMuxer.  We can't add the video track and start() the muxer here,
 * because our MediaFormat doesn't have the Magic Goodies.  These can only be
 * obtained from the encoder after it has started processing data.
 **********************************************************************************/
@SuppressWarnings("all")
private synchronized void createMuxer() {
    Log.d(TAG, "--->createMuxer()");
    if ( isExternalStorageWritable()) {
        File encodedFile = new File(OUTPUT_FILENAME_DIR, "/movies/EncodedAV" + "-" + mEncodingWidth + "x" + mEncodingHeight + ".mp4");
        if (encodedFile.exists()) {
            encodedFile.delete();
        }
        String outputPath = encodedFile.toString();
        int format = MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4;
        try {
            mMuxer = new MediaMuxer(outputPath, format);
        } catch (IOException e) {
            Log.e(TAG, e.getLocalizedMessage());
        }
        mVideoTrackIndex = -1;
        mMuxerStarted = false;
    }
}
 
Example #4
Source File: AudioEncoder.java    From LiveMultimedia with Apache License 2.0 6 votes vote down vote up
public synchronized void createAudioMuxer() throws IllegalStateException{
    if (Thread.currentThread().isInterrupted()) {
            release();
    }
    if ( isExternalStorageWritable()) {
        File encodedFile = new File(OUTPUT_FILENAME_DIR, "/movies/EncodedAudio.mp4");
        if (encodedFile.exists()) {
            boolean result = encodedFile.delete();
            if (!result)
                 throw new IllegalStateException("Unable to delete video file");
        }
        String outputPath = encodedFile.toString();
        int format = MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4;
        try {
            mAudioMuxer = new MediaMuxer(outputPath, format);
        } catch (IOException e) {
            Log.e(TAG, "Audio temp Muxer failed to create!!");
        }
    }
}
 
Example #5
Source File: SohuMediaMuxerManager.java    From GLES2_AUDIO_VIDEO_RECODE with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor
 *
 * @param ext extension of output file
 * @throws IOException
 */
public SohuMediaMuxerManager(String ext) throws IOException {
    if (TextUtils.isEmpty(ext)) {
        ext = ".mp4";
    }
    try {
        // 输出文件路径
        mOutputPath = getCaptureFile(ext).toString();
        //
    } catch (final NullPointerException e) {
        throw new RuntimeException("This app has no permission of writing external storage");
    }
    // 编码器
    mMediaMuxer = new MediaMuxer(mOutputPath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
    //
    mEncoderCount = mStatredCount = 0;
    //
    mIsStarted = false;
}
 
Example #6
Source File: MediaMuxerMediaTarget.java    From LiTr with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public MediaMuxerMediaTarget(@NonNull String outputFilePath, @IntRange(from = 1) int trackCount, int orientationHint, int outputFormat) throws MediaTargetException {
    this.outputFilePath = outputFilePath;
    this.trackCount = trackCount;

    try {
        mediaMuxer = new MediaMuxer(outputFilePath,  outputFormat);
        mediaMuxer.setOrientationHint(orientationHint);

        numberOfTracksToAdd = 0;
        isStarted = false;
        queue = new LinkedList<>();
        mediaFormatsToAdd = new MediaFormat[trackCount];
    } catch (IllegalArgumentException illegalArgumentException) {
        throw new MediaTargetException(INVALID_PARAMS, outputFilePath, outputFormat, illegalArgumentException);
    } catch (IOException ioException) {
        throw new MediaTargetException(IO_FAILUE, outputFilePath, outputFormat, ioException);
    }
}
 
Example #7
Source File: Mpeg4Muxer.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
public Mpeg4Muxer(String outputPath) {
    try {
        mMuxer = new MediaMuxer(outputPath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
    } catch (IOException ioe) {
        throw new RuntimeException("MediaMuxer creation failed", ioe);
    }
    mTrackIndex = -1;
}
 
Example #8
Source File: VideoEncoderCore.java    From OpenGLESRecorder with Apache License 2.0 5 votes vote down vote up
/**
 * Configures encoder and muxer state, and prepares the input Surface.
 */
public VideoEncoderCore(int width, int height, int bitRate, File outputFile)
        throws IOException {
    mBufferInfo = new MediaCodec.BufferInfo();

    MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, width, height);

    // Set some properties.  Failing to specify some of these can cause the MediaCodec
    // configure() call to throw an unhelpful exception.
    format.setInteger(MediaFormat.KEY_COLOR_FORMAT,
            MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
    format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate);
    format.setInteger(MediaFormat.KEY_FRAME_RATE, FRAME_RATE);
    format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, IFRAME_INTERVAL);
    if (VERBOSE) Log.d(TAG, "format: " + format);

    // Create a MediaCodec encoder, and configure it with our format.  Get a Surface
    // we can use for input and wrap it with a class that handles the EGL work.
    mEncoder = MediaCodec.createEncoderByType(MIME_TYPE);
    mEncoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
    mInputSurface = mEncoder.createInputSurface();
    mEncoder.start();

    // Create a MediaMuxer.  We can't add the video track and start() the muxer here,
    // because our MediaFormat doesn't have the Magic Goodies.  These can only be
    // obtained from the encoder after it has started processing data.
    //
    // We're not actually interested in multiplexing audio.  We just want to convert
    // the raw H.264 elementary stream we get from MediaCodec into a .mp4 file.
    mMuxer = new MediaMuxer(outputFile.toString(),
            MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);

    mTrackIndex = -1;
    mMuxerStarted = false;
}
 
Example #9
Source File: MediaMuxerWrapper.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * 出力先をOutputStreamで指定するコンストラクタ
 * @param output
 * @param format
 */
@RequiresApi(api = Build.VERSION_CODES.O)
public MediaMuxerWrapper(
	@NonNull final MediaStoreOutputStream output,
	final int format)
		throws IOException {

	mMuxer = new MediaMuxer(output.getFd(), format);
	mOutputStream = output;
	mOutputPath = output.getOutputPath();
}
 
Example #10
Source File: AndroidMuxer.java    From kickflip-android-sdk with Apache License 2.0 5 votes vote down vote up
private AndroidMuxer(String outputFile, FORMAT format){
    super(outputFile, format);
    try {
        switch(format){
            case MPEG4:
                mMuxer = new MediaMuxer(outputFile, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
                break;
            default:
                throw new IllegalArgumentException("Unrecognized format!");
        }
    } catch (IOException e) {
        throw new RuntimeException("MediaMuxer creation failed", e);
    }
    mStarted = false;
}
 
Example #11
Source File: VideoEncoderCore.java    From AndroidPlayground with MIT License 5 votes vote down vote up
/**
 * Configures encoder and muxer state, and prepares the input Surface.
 */
public VideoEncoderCore(int width, int height, int bitRate, File outputFile)
        throws IOException {
    mBufferInfo = new MediaCodec.BufferInfo();

    MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, width, height);

    // Set some properties.  Failing to specify some of these can cause the MediaCodec
    // configure() call to throw an unhelpful exception.
    format.setInteger(MediaFormat.KEY_COLOR_FORMAT,
            MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
    format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate);
    format.setInteger(MediaFormat.KEY_FRAME_RATE, FRAME_RATE);
    format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, IFRAME_INTERVAL);
    if (VERBOSE) Log.d(TAG, "format: " + format);

    // Create a MediaCodec encoder, and configure it with our format.  Get a Surface
    // we can use for input and wrap it with a class that handles the EGL work.
    mEncoder = MediaCodec.createEncoderByType(MIME_TYPE);
    mEncoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
    mInputSurface = mEncoder.createInputSurface();
    mEncoder.start();

    // Create a MediaMuxer.  We can't add the video track and start() the muxer here,
    // because our MediaFormat doesn't have the Magic Goodies.  These can only be
    // obtained from the encoder after it has started processing data.
    //
    // We're not actually interested in multiplexing audio.  We just want to convert
    // the raw H.264 elementary stream we get from MediaCodec into a .mp4 file.
    mMuxer = new MediaMuxer(outputFile.toString(),
            MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);

    mTrackIndex = -1;
    mMuxerStarted = false;
}
 
Example #12
Source File: MediaMuxerWrapper.java    From ScreenRecordingSample with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor
 * @param _ext extension of output file
 * @throws IOException
 */
public MediaMuxerWrapper(final Context context, final String _ext) throws IOException {
	String ext = _ext;
	if (TextUtils.isEmpty(ext)) ext = ".mp4";
	try {
		mOutputPath = FileUtils.getCaptureFile(context, Environment.DIRECTORY_MOVIES, ext, 0).toString();
	} catch (final NullPointerException e) {
		throw new RuntimeException("This app has no permission of writing external storage");
	}
	mMediaMuxer = new MediaMuxer(mOutputPath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
	mEncoderCount = mStatredCount = 0;
	mIsStarted = false;
}
 
Example #13
Source File: MediaMuxerWrapper.java    From EZFilter with MIT License 5 votes vote down vote up
/**
 * @param outPath 视频输出路径
 * @throws IOException
 */
public MediaMuxerWrapper(String outPath) throws IOException {
    mOutputPath = outPath;
    mMediaMuxer = new MediaMuxer(mOutputPath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
    mEncoderCount = mStartedCount = 0;
    mIsStarted = false;
}
 
Example #14
Source File: VideoEncoderCore.java    From pause-resume-video-recording with Apache License 2.0 5 votes vote down vote up
/**
 * Configures encoder and muxer state, and prepares the input Surface.
 */
public VideoEncoderCore(int width, int height, int bitRate, File outputFile)
        throws IOException {
    mBufferInfo = new MediaCodec.BufferInfo();

    MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, width, height);

    // Set some properties.  Failing to specify some of these can cause the MediaCodec
    // configure() call to throw an unhelpful exception.
    format.setInteger(MediaFormat.KEY_COLOR_FORMAT,
            MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
    format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate);
    format.setInteger(MediaFormat.KEY_FRAME_RATE, FRAME_RATE);
    format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, IFRAME_INTERVAL);
    if (VERBOSE) Log.d(TAG, "format: " + format);

    // Create a MediaCodec encoder, and configure it with our format.  Get a Surface
    // we can use for input and wrap it with a class that handles the EGL work.
    mEncoder = MediaCodec.createEncoderByType(MIME_TYPE);
    mEncoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
    mInputSurface = mEncoder.createInputSurface();
    mEncoder.start();

    // Create a MediaMuxer.  We can't add the video track and start() the muxer here,
    // because our MediaFormat doesn't have the Magic Goodies.  These can only be
    // obtained from the encoder after it has started processing data.
    //
    // We're not actually interested in multiplexing audio.  We just want to convert
    // the raw H.264 elementary stream we get from MediaCodec into a .mp4 file.
    mMuxer = new MediaMuxer(outputFile.toString(),
            MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);

    mTrackIndex = -1;
    mMuxerStarted = false;
}
 
Example #15
Source File: MuxerMP4.java    From Android-Audio-Recorder with Apache License 2.0 5 votes vote down vote up
public void create(EncoderInfo info, MediaFormat format, File out) {
    this.info = info;

    try {
        encoder = MediaCodec.createEncoderByType(format.getString(MediaFormat.KEY_MIME));
        encoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
        encoder.start();

        muxer = new MediaMuxer(out.getAbsolutePath(), MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example #16
Source File: MediaMuxerWrapper.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * 出力先をファイルパス文字列で指定するコンストラクタ
 * @param outputPath
 * @param format
 * @throws IOException
 */
public MediaMuxerWrapper(@NonNull final String outputPath, final int format)
	throws IOException {

	mMuxer = new MediaMuxer(outputPath, format);
	mOutputStream = null;
	mOutputPath = outputPath;
}
 
Example #17
Source File: MediaMuxerWrapper.java    From AudioVideoRecordingSample with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor
 * @param ext extension of output file
 * @throws IOException
 */
public MediaMuxerWrapper(String ext) throws IOException {
	if (TextUtils.isEmpty(ext)) ext = ".mp4";
	try {
		mOutputPath = getCaptureFile(Environment.DIRECTORY_MOVIES, ext).toString();
	} catch (final NullPointerException e) {
		throw new RuntimeException("This app has no permission of writing external storage");
	}
	mMediaMuxer = new MediaMuxer(mOutputPath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
	mEncoderCount = mStatredCount = 0;
	mIsStarted = false;
}
 
Example #18
Source File: MainActivity.java    From AudioVideoCodec with Apache License 2.0 5 votes vote down vote up
private void initMediaCodec() {
    String currentDate = new SimpleDateFormat("yyyyMMdd_HHmm", Locale.CHINA).format(new Date());
    String fileName = "/VID_".concat(currentDate).concat(".mp4");
    String filePath = FileUtils.getDiskCachePath(this) + fileName;
    int mediaFormat = MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4;
    //String audioType = MediaFormat.MIMETYPE_AUDIO_AAC;
    String audioType = "audio/mp4a-latm";
    //String videoType = MediaFormat.MIMETYPE_VIDEO_AVC;
    String videoType = "video/avc";
    int sampleRate = 44100;
    int channelCount = 2;//单声道 channelCount=1 , 双声道  channelCount=2
    //AudioCapture.class类中采集音频采用的位宽:AudioFormat.ENCODING_PCM_16BIT ,此处应传入16bit,
    // 用作计算pcm一帧的时间戳
    int audioFormat = 16;
    //预览
    int width = cameraSurfaceView.getCameraPreviewHeight();
    int height = cameraSurfaceView.getCameraPreviewWidth();

    mediaEncodeManager = new MediaEncodeManager(new VideoEncodeRender(this,
            cameraSurfaceView.getTextureId(), cameraSurfaceView.getType(), cameraSurfaceView.getColor()));

    mediaEncodeManager.initMediaCodec(filePath, mediaFormat, audioType, sampleRate,
            channelCount, audioFormat, videoType, width, height);

    mediaEncodeManager.initThread(this, cameraSurfaceView.getEglContext(),
            GLSurfaceView.RENDERMODE_CONTINUOUSLY);
}
 
Example #19
Source File: MediaMuxerWrapper.java    From AndroidUSBCamera with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public MediaMuxerWrapper(String path) throws IOException {
	try {
		// 保存到自定义路径还是手机默认Movies路径
		if (TextUtils.isEmpty(path))
			mOutputPath = getCaptureFile(Environment.DIRECTORY_MOVIES, ".mp4").toString();
		mOutputPath = path;

	} catch (final NullPointerException e) {
		throw new RuntimeException("This app has no permission of writing external storage");
	}
	mMediaMuxer = new MediaMuxer(mOutputPath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
	mEncoderCount = mStatredCount = 0;
	mIsStarted = false;
}
 
Example #20
Source File: MediaMuxerWrapper.java    From MegviiFacepp-Android-SDK with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor
 * @param ext extension of output file
 * @throws IOException
 */
public MediaMuxerWrapper(String ext) throws IOException {
	if (TextUtils.isEmpty(ext)) ext = ".mp4";
	try {
		mOutputPath = getCaptureFile(Environment.DIRECTORY_MOVIES, ext).toString();
	} catch (final NullPointerException e) {
		throw new RuntimeException("This app has no permission of writing external storage");
	}
	mMediaMuxer = new MediaMuxer(mOutputPath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
	mEncoderCount = mStatredCount = 0;
	mIsStarted = false;
}
 
Example #21
Source File: IMuxer.java    From libcommon with Apache License 2.0 5 votes vote down vote up
@SuppressLint("NewApi")
		public IMuxer createMuxer(@NonNull final Context context,
			final boolean useMediaMuxer,
			@NonNull final DocumentFile file) throws IOException {

			IMuxer result = null;
			if (useMediaMuxer) {
				if (BuildCheck.isOreo()) {
					result = new MediaMuxerWrapper(context.getContentResolver()
						.openFileDescriptor(file.getUri(), "rw").getFileDescriptor(),
						MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
				} else {
					final String path = UriHelper.getPath(context, file.getUri());
					final File f = new File(UriHelper.getPath(context, file.getUri()));
					if (/*!f.exists() &&*/ f.canWrite()) {
						// 書き込めるファイルパスを取得できればそれを使う
						result = new MediaMuxerWrapper(path,
							MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
					} else {
						Log.w("IMuxer", "cant't write to the file, try to use VideoMuxer instead");
					}
				}
			}
			if (result == null) {
				throw new IOException("Unsupported muxer type");
//				result = new VideoMuxer(context.getContentResolver()
//					.openFileDescriptor(file.getUri(), "rw").getFd());
			}
			return result;
		}
 
Example #22
Source File: RecordController.java    From rtmp-rtsp-stream-client-java with Apache License 2.0 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
public void startRecord(String path, Listener listener) throws IOException {
  mediaMuxer = new MediaMuxer(path, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
  this.listener = listener;
  status = Status.STARTED;
  if (listener != null) listener.onStatusChange(status);
}
 
Example #23
Source File: MMediaMuxer.java    From Fatigue-Detection with MIT License 5 votes vote down vote up
public MMediaMuxer(File outputFile) {
    // Create a MediaMuxer.  We can't add the video track and start() the muxer here,
    // because our MediaFormat doesn't have the Magic Goodies.  These can only be
    // obtained from the encoder after it has started processing data.
    try {
        mMuxer = new MediaMuxer(outputFile.toString(),
                MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
        startCount=0;
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example #24
Source File: MediaMuxerWraper.java    From AAVT with Apache License 2.0 5 votes vote down vote up
public MediaMuxerWraper(String path, int format) throws IOException {
    mMuxer=new MediaMuxer(path,format);
    datas=new LinkedBlockingQueue<>(30);
    recycler=new Recycler<>();
    ThreadFactory factory= Executors.defaultThreadFactory();
    mExec=new ThreadPoolExecutor(1,1,1,TimeUnit.MINUTES,new LinkedBlockingQueue<Runnable>(16),factory);
}
 
Example #25
Source File: StrengthenMp4MuxStore.java    From AAVT with Apache License 2.0 5 votes vote down vote up
@Override
public int addTrack(MediaFormat mediaFormat) {
    int ret=-1;
    synchronized (Lock){
        if(!muxStarted){
            if(audioTrack==-1&&videoTrack==-1){
                try {
                    mMuxer=new MediaMuxer(path,MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
                } catch (IOException e) {
                    e.printStackTrace();
                    AvLog.e("create MediaMuxer failed:"+e.getMessage());
                }
            }
            String mime=mediaFormat.getString(MediaFormat.KEY_MIME);
            if(mime.startsWith("audio")){
                audioTrack=mMuxer.addTrack(mediaFormat);
                ret=audioTrack;
            }else if(mime.startsWith("video")){
                videoTrack=mMuxer.addTrack(mediaFormat);
                ret=videoTrack;
            }
            startMux();
        }
    }
    return ret;
}
 
Example #26
Source File: MediaMuxerWrapper.java    From PLDroidShortVideo with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @throws IOException
 */
public MediaMuxerWrapper(String filePath) throws IOException {
    mOutputPath = filePath;
    mMediaMuxer = new MediaMuxer(mOutputPath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
    mEncoderCount = mStatredCount = 0;
    mIsStarted = false;
}
 
Example #27
Source File: VideoAppendEncodeThread.java    From VideoProcessor with Apache License 2.0 5 votes vote down vote up
public VideoAppendEncodeThread(MediaExtractor extractor, MediaMuxer muxer,
                               int bitrate, int resultWidth, int resultHeight, int iFrameInterval,
                               int videoIndex, AtomicBoolean decodeDone,
                               long baseMuxerFrameTimeUs, boolean isFirst, boolean isLast, int muxerVideoTrackIndex) {
    super("VideoProcessEncodeThread");
    mMuxer = muxer;
    mDecodeDone = decodeDone;
    mExtractor = extractor;
    mBitrate = bitrate;
    mResultHeight = resultHeight;
    mResultWidth = resultWidth;
    mIFrameInterval = iFrameInterval;
    mVideoIndex = videoIndex;
    mEglContextLatch = new CountDownLatch(1);
    mBaseMuxerFrameTimeUs = baseMuxerFrameTimeUs;
    mLastFrametimeUs = baseMuxerFrameTimeUs;
    mIsFirst = isFirst;
    mIsLast = isLast;
    mMuxerVideoTrackIndex = muxerVideoTrackIndex;
}
 
Example #28
Source File: VideoEncodeThread.java    From VideoProcessor with Apache License 2.0 5 votes vote down vote up
public VideoEncodeThread(MediaExtractor extractor, MediaMuxer muxer,
                         int bitrate, int resultWidth, int resultHeight, int iFrameInterval,
                         int frameRate, int videoIndex,
                         AtomicBoolean decodeDone, CountDownLatch muxerStartLatch) {
    super("VideoProcessEncodeThread");
    mMuxer = muxer;
    mDecodeDone = decodeDone;
    mMuxerStartLatch = muxerStartLatch;
    mExtractor = extractor;
    mBitrate = bitrate;
    mResultHeight = resultHeight;
    mResultWidth = resultWidth;
    mIFrameInterval = iFrameInterval;
    mVideoIndex = videoIndex;
    mFrameRate = frameRate;
    mEglContextLatch = new CountDownLatch(1);
}
 
Example #29
Source File: AudioProcessThread.java    From VideoProcessor with Apache License 2.0 5 votes vote down vote up
public AudioProcessThread(Context context, VideoProcessor.MediaSource mediaSource, MediaMuxer muxer,
                          @Nullable Integer startTimeMs, @Nullable Integer endTimeMs,
                          @Nullable Float speed, int muxerAudioTrackIndex,
                          CountDownLatch muxerStartLatch

) {
    super("VideoProcessDecodeThread");
    mMediaSource = mediaSource;
    mStartTimeMs = startTimeMs;
    mEndTimeMs = endTimeMs;
    mSpeed = speed;
    mMuxer = muxer;
    mContext = context;
    mMuxerAudioTrackIndex = muxerAudioTrackIndex;
    mExtractor = new MediaExtractor();
    mMuxerStartLatch = muxerStartLatch;
}
 
Example #30
Source File: MediaMuxerCaptureWrapper.java    From CameraRecorder-android with MIT License 5 votes vote down vote up
/**
 * Constructor
 */
public MediaMuxerCaptureWrapper(final String filePath) throws IOException {
    mediaMuxer = new MediaMuxer(filePath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
    encoderCount = startedCount = 0;
    isStarted = false;

}