Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
dstukalov committed Jun 22, 2019
1 parent c3c53d9 commit 3c35e2e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ VideoConverter is installed by adding the following dependency to your build.gra
}

## Usage
mConverter = new Converter();
mConverter.setInput(context, uri);
mConverter.setOutput(outputStream);
mConverter.setTimeRange(timeFrom, timeTo);
mConverter.setVideoResolution(360);
mConverter.setVideoBitrate(2000000);
mConverter.setAudioBitrate(128000);
MediaConverter converter = new MediaConverter();
converter.setInput(context, uri);
converter.setOutput(outputStream);
converter.setTimeRange(timeFrom, timeTo);
converter.setVideoResolution(360);
converter.setVideoBitrate(2000000);
converter.setAudioBitrate(128000);

mConverter.setListener(percent -> {
converter.setListener(percent -> {
publishProgress(percent);
return isCancelled();
});

mConverter.convert();
converter.convert();
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import android.widget.Toast;

import com.dstukalov.videoconverter.BadVideoException;
import com.dstukalov.videoconverter.Converter;
import com.dstukalov.videoconverter.MediaConverter;
import com.innovattic.rangeseekbar.RangeSeekBar;

import java.io.File;
Expand Down Expand Up @@ -568,12 +568,12 @@ private static Bitmap getVideoThumb(final String filePath, final long timeUs) {

private class ConversionTask extends AsyncTask<Void, Integer, Boolean> {

final Converter mConverter;
final MediaConverter mConverter;
long mStartTime;

ConversionTask(final File input, final File output, final long timeFrom, final long timeTo, final ConversionParameters conversionParameters) {

mConverter = new Converter();
mConverter = new MediaConverter();
mConverter.setInput(input);
mConverter.setOutput(output);
mConverter.setTimeRange(timeFrom, timeTo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class AudioTrackConverter {
private Muxer mMuxer;

static @Nullable AudioTrackConverter create(
final @NonNull Converter.Input input,
final @NonNull MediaConverter.Input input,
final long timeFrom,
final long timeTo,
final int audioBitrate) throws IOException {
Expand All @@ -86,7 +86,7 @@ private AudioTrackConverter(
mAudioExtractor = audioExtractor;
mAudioBitrate = audioBitrate;

final MediaCodecInfo audioCodecInfo = Converter.selectCodec(OUTPUT_AUDIO_MIME_TYPE);
final MediaCodecInfo audioCodecInfo = MediaConverter.selectCodec(OUTPUT_AUDIO_MIME_TYPE);
if (audioCodecInfo == null) {
// Don't fail CTS if they don't have an AAC codec (not here, anyway).
Log.e(TAG, "Unable to find an appropriate codec for " + OUTPUT_AUDIO_MIME_TYPE);
Expand Down Expand Up @@ -412,7 +412,7 @@ void verifyEndState() {
* @param inputFormat the format of the stream to decode
*/
private static @NonNull MediaCodec createAudioDecoder(@NonNull MediaFormat inputFormat) throws IOException {
MediaCodec decoder = MediaCodec.createDecoderByType(Converter.getMimeTypeFor(inputFormat));
MediaCodec decoder = MediaCodec.createDecoderByType(MediaConverter.getMimeTypeFor(inputFormat));
decoder.configure(inputFormat, null, null, 0);
decoder.start();
return decoder;
Expand All @@ -435,7 +435,7 @@ private static int getAndSelectAudioTrackIndex(MediaExtractor extractor) {
for (int index = 0; index < extractor.getTrackCount(); ++index) {
if (VERBOSE) {
Log.d(TAG, "format for track " + index + " is "
+ Converter.getMimeTypeFor(extractor.getTrackFormat(index)));
+ MediaConverter.getMimeTypeFor(extractor.getTrackFormat(index)));
}
if (isAudioFormat(extractor.getTrackFormat(index))) {
extractor.selectTrack(index);
Expand All @@ -446,6 +446,6 @@ private static int getAndSelectAudioTrackIndex(MediaExtractor extractor) {
}

private static boolean isAudioFormat(MediaFormat format) {
return Converter.getMimeTypeFor(format).startsWith("audio/");
return MediaConverter.getMimeTypeFor(format).startsWith("audio/");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import com.dstukalov.videoconverter.muxer.StreamingMuxer;

@SuppressWarnings("WeakerAccess")
public class Converter {
public class MediaConverter {
private static final String TAG = "video-converter";
private static final boolean VERBOSE = false; // lots of logging

Expand Down Expand Up @@ -67,7 +67,7 @@ public interface Listener {
boolean onProgress(int percent);
}

public Converter() {
public MediaConverter() {
}

@SuppressWarnings("unused")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class VideoTrackConverter {
private Muxer mMuxer;

static @Nullable VideoTrackConverter create(
final @NonNull Converter.Input input,
final @NonNull MediaConverter.Input input,
final long timeFrom,
final long timeTo,
final int videoResolution,
Expand Down Expand Up @@ -91,7 +91,7 @@ private VideoTrackConverter(
mTimeTo = timeTo;
mVideoExtractor = videoExtractor;

final MediaCodecInfo videoCodecInfo = Converter.selectCodec(videoCodec);
final MediaCodecInfo videoCodecInfo = MediaConverter.selectCodec(videoCodec);
if (videoCodecInfo == null) {
// Don't fail CTS if they don't have an AVC codec (not here, anyway).
Log.e(TAG, "Unable to find an appropriate codec for " + videoCodec);
Expand Down Expand Up @@ -481,7 +481,7 @@ private static String createFragmentShader(int srcWidth, int srcHeight, int dstW
* @param surface into which to decode the frames
*/
private @NonNull MediaCodec createVideoDecoder(@NonNull MediaFormat inputFormat, @NonNull Surface surface) throws IOException {
MediaCodec decoder = MediaCodec.createDecoderByType(Converter.getMimeTypeFor(inputFormat));
MediaCodec decoder = MediaCodec.createDecoderByType(MediaConverter.getMimeTypeFor(inputFormat));
decoder.configure(inputFormat, surface, null, 0);
decoder.start();
return decoder;
Expand Down Expand Up @@ -512,7 +512,7 @@ private static String createFragmentShader(int srcWidth, int srcHeight, int dstW
private static int getAndSelectVideoTrackIndex(@NonNull MediaExtractor extractor) {
for (int index = 0; index < extractor.getTrackCount(); ++index) {
if (VERBOSE) {
Log.d(TAG, "format for track " + index + " is " + Converter.getMimeTypeFor(extractor.getTrackFormat(index)));
Log.d(TAG, "format for track " + index + " is " + MediaConverter.getMimeTypeFor(extractor.getTrackFormat(index)));
}
if (isVideoFormat(extractor.getTrackFormat(index))) {
extractor.selectTrack(index);
Expand All @@ -523,6 +523,6 @@ private static int getAndSelectVideoTrackIndex(@NonNull MediaExtractor extractor
}

private static boolean isVideoFormat(MediaFormat format) {
return Converter.getMimeTypeFor(format).startsWith("video/");
return MediaConverter.getMimeTypeFor(format).startsWith("video/");
}
}

0 comments on commit 3c35e2e

Please sign in to comment.