Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c5ab239

Browse files
committed
Fix javadoc build
1 parent 92c2adc commit c5ab239

File tree

10 files changed

+57
-93
lines changed

10 files changed

+57
-93
lines changed

README.md

+13-90
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,25 @@
1-
# Note
1+
# Transcoder
22

3-
This project was forked recently from great [ypresto/android-transcoder](https://github.com/ypresto/android-transcoder).
4-
Lots of changes were made, so the information in this README is mostly false at the moment.
3+
This project is an improved fork of [ypresto/android-transcoder](https://github.com/ypresto/android-transcoder).
4+
Lots of changes were made, so the documentation must be rewritten. You can, however, take a look at the
5+
demo app which provides a working example of the new API.
56

7+
```groovy
8+
implementation 'com.otaliastudios:transcoder:0.1.0'
9+
```
610

7-
android-transcoder
8-
=================
9-
10-
Hardware accelerated transcoder for Android, written in pure Java.
11-
12-
## Why?
13-
14-
Android does not offer straight forward way to transcode video.
15-
16-
FFmpeg is the most famous solution for transcoding. But using [FFmpeg binary on Android](https://github.com/WritingMinds/ffmpeg-android) can cause GPL and/or patent issues. Also using native code for Android development can be troublesome because of cross-compiling, architecture compatibility, build time and binary size.
17-
18-
To transcode without any hassle written above, I created this library to provide hardware accelerated transcoding of H.264 (mp4) video without ffmpeg by using [MediaCodec](https://developer.android.com/intl/ja/reference/android/media/MediaCodec.html).
19-
20-
## Requirements
11+
## Setup
2112

22-
API Level 18 (Android 4.3, JELLY_BEAN_MR2) or later.
23-
If your app targets older Android, you should add below line to AndroidManifest.xml:
13+
This library requires API level 18 (Android 4.3, JELLY_BEAN_MR2) or later.
14+
If your app targets older versions, you can override the minSdkVersion by
15+
adding this line to your manifest file:
2416

2517
```xml
26-
<!-- Only supports API >= 18 -->
2718
<uses-sdk tools:overrideLibrary="com.otaliastudios.transcoder" />
2819
```
2920

30-
Please ensure checking Build.VERSION by your self.
31-
32-
## Usage
33-
34-
```java
35-
@Override
36-
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
37-
ParcelFileDescriptor parcelFileDescriptor = resolver.openFileDescriptor(data.getData(), "r");
38-
FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
39-
MediaTranscoder.Listener listener = new MediaTranscoder.Listener() {
40-
@Override
41-
public void onTranscodeProgress(double progress) {
42-
...
43-
}
44-
45-
@Override
46-
public void onTranscodeCompleted() {
47-
startActivity(new Intent(Intent.ACTION_VIEW).setDataAndType(Uri.fromFile(file), "video/mp4"));
48-
...
49-
}
50-
51-
@Override
52-
public void onTranscodeFailed(Exception exception) {
53-
...
54-
}
55-
};
56-
MediaTranscoder.getInstance().transcodeVideo(fileDescriptor, file.getAbsolutePath(),
57-
MediaFormatStrategyPresets.createAndroid720pStrategy(), listener); // or createAndroid720pStrategy([your bitrate here])
58-
}
59-
```
60-
61-
See `TranscoderActivity.java` in example directory for ready-made transcoder app.
62-
63-
## Quick Setup
64-
65-
### Gradle
66-
67-
Available from [JCenter](https://bintray.com/bintray/jcenter), which is default repo of gradle script generated by recent android studio.
68-
69-
```groovy
70-
repositories {
71-
jcenter()
72-
}
73-
```
74-
75-
```groovy
76-
compile 'net.ypresto.androidtranscoder:android-transcoder:0.2.0'
77-
```
78-
79-
## Note (PLEASE READ FIRST)
80-
81-
- This library raises `RuntimeException`s (like `IlleagalStateException`) in various situations. Please catch it and provide alternate logics. I know this is bad design according to Effective Java; just is TODO.
82-
- Currently this library does not generate streaming-aware mp4 file.
83-
Use [qtfaststart-java](https://github.com/ypresto/qtfaststart-java) to place moov atom at beginning of file.
84-
- Android does not gurantees that all devices have bug-free codecs/accelerators for your codec parameters (especially, resolution). Refer [supported media formats](http://developer.android.com/guide/appendix/media-formats.html) for parameters guaranteed by [CTS](https://source.android.com/compatibility/cts-intro.html).
85-
- This library does not support video files recorded by other device like digital cameras, iOS (mov files, including non-baseline profile h.264), etc.
86-
87-
88-
## More information about internals
89-
90-
There is a blog post about this library written in Japanese.
91-
http://qiita.com/yuya_presto/items/d48e29c89109b746d000
92-
93-
While it is Japanese, diagrams would be useful for understanding internals of this library.
94-
95-
## References for Android Low-Level Media APIs
96-
97-
- http://bigflake.com/mediacodec/
98-
- https://github.com/google/grafika
99-
- https://android.googlesource.com/platform/frameworks/av/+/lollipop-release/media/libstagefright
21+
In this case you should check at runtime that API level is at least 18, before
22+
calling any method here.
10023

10124
## License
10225

lib/src/main/java/com/otaliastudios/transcoder/MediaTranscoder.java

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public static MediaTranscoderOptions.Builder into(@NonNull String outPath) {
102102
* Transcodes video file asynchronously.
103103
*
104104
* @param options The transcoder options.
105+
* @return a Future that completes when transcoding is completed
105106
*/
106107
@SuppressWarnings("WeakerAccess")
107108
public Future<Void> transcode(@NonNull final MediaTranscoderOptions options) {
@@ -173,6 +174,7 @@ public interface Listener {
173174

174175
/**
175176
* Called when transcode failed.
177+
* @param exception the failure exception
176178
*/
177179
void onTranscodeFailed(@NonNull Throwable exception);
178180
}

lib/src/main/java/com/otaliastudios/transcoder/engine/MediaTranscoderEngine.java

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public void setProgressCallback(ProgressCallback progressCallback) {
7878

7979
/**
8080
* NOTE: This method is thread safe.
81+
* @return the current progress
8182
*/
8283
public double getProgress() {
8384
return mProgress;

lib/src/main/java/com/otaliastudios/transcoder/engine/TrackStatus.java

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ public enum TrackStatus {
88
* in MediaExtractor, and add this track to MediaMuxer.
99
* Basically if it should be read and written or not
1010
* (no point in just reading without writing).
11+
*
12+
* @return true if transcoding
1113
*/
1214
public boolean isTranscoding() {
1315
switch (this) {

lib/src/main/java/com/otaliastudios/transcoder/strategy/DefaultVideoStrategies.java

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ private DefaultVideoStrategies() {}
1111
* A {@link DefaultVideoStrategy} that uses 720x1280.
1212
* This preset is ensured to work on any Android &gt;=4.3 devices by Android CTS,
1313
* assuming that the codec is available.
14+
*
15+
* @return a default video strategy
1416
*/
1517
public static DefaultVideoStrategy for720x1280() {
1618
return DefaultVideoStrategy.exact(720, 1280)
@@ -24,6 +26,8 @@ public static DefaultVideoStrategy for720x1280() {
2426
* A {@link DefaultVideoStrategy} that uses 360x480 (3:4),
2527
* ensured to work for 3:4 videos as explained by
2628
* https://developer.android.com/guide/topics/media/media-formats
29+
*
30+
* @return a default video strategy
2731
*/
2832
public static DefaultVideoStrategy for360x480() {
2933
return DefaultVideoStrategy.exact(360, 480)

lib/src/main/java/com/otaliastudios/transcoder/strategy/DefaultVideoStrategy.java

+10
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ private Options() {}
4545
/**
4646
* Creates a new {@link Builder} with an {@link ExactResizer}
4747
* using given dimensions.
48+
*
49+
* @param firstSize the exact first size
50+
* @param secondSize the exact second size
4851
* @return a strategy builder
4952
*/
5053
public static Builder exact(int firstSize, int secondSize) {
@@ -54,6 +57,8 @@ public static Builder exact(int firstSize, int secondSize) {
5457
/**
5558
* Creates a new {@link Builder} with a {@link FractionResizer}
5659
* using given downscale fraction.
60+
*
61+
* @param fraction the downscale fraction
5762
* @return a strategy builder
5863
*/
5964
public static Builder fraction(float fraction) {
@@ -63,6 +68,8 @@ public static Builder fraction(float fraction) {
6368
/**
6469
* Creates a new {@link Builder} with an {@link AtMostResizer}
6570
* using given constraint.
71+
*
72+
* @param atMostSize size constraint
6673
* @return a strategy builder
6774
*/
6875
public static Builder atMost(int atMostSize) {
@@ -72,6 +79,9 @@ public static Builder atMost(int atMostSize) {
7279
/**
7380
* Creates a new {@link Builder} with an {@link AtMostResizer}
7481
* using given constraints.
82+
*
83+
* @param atMostMajor constraint for the major dimension
84+
* @param atMostMinor constraint for the minor dimension
7585
* @return a strategy builder
7686
*/
7787
public static Builder atMost(int atMostMinor, int atMostMajor) {

lib/src/main/java/com/otaliastudios/transcoder/strategy/OutputStrategy.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface OutputStrategy {
1818
* Create the output format for this track (either audio or video).
1919
* Implementors can:
2020
* - throw a {@link OutputStrategyException} if the whole transcoding should be aborted
21-
* - return {@param inputFormat} for remuxing this track as-is
21+
* - return {@code inputFormat} for remuxing this track as-is
2222
* - returning {@code null} for removing this track from output
2323
*
2424
* @param inputFormat the input format

lib/src/main/java/com/otaliastudios/transcoder/transcode/opengl/InputSurface.java

+12
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ public class InputSurface {
3838
private EGLContext mEGLContext = EGL14.EGL_NO_CONTEXT;
3939
private EGLSurface mEGLSurface = EGL14.EGL_NO_SURFACE;
4040
private Surface mSurface;
41+
4142
/**
4243
* Creates an InputSurface from a Surface.
44+
* @param surface the surface
4345
*/
4446
public InputSurface(Surface surface) {
4547
if (surface == null) {
@@ -48,6 +50,7 @@ public InputSurface(Surface surface) {
4850
mSurface = surface;
4951
eglSetup();
5052
}
53+
5154
/**
5255
* Prepares EGL. We want a GLES 2.0 context and a surface that supports recording.
5356
*/
@@ -132,38 +135,47 @@ public void makeUnCurrent() {
132135
}
133136
/**
134137
* Calls eglSwapBuffers. Use this to "publish" the current frame.
138+
* @return the output of eglSwapBuffers
135139
*/
136140
public boolean swapBuffers() {
137141
return EGL14.eglSwapBuffers(mEGLDisplay, mEGLSurface);
138142
}
143+
139144
/**
140145
* Returns the Surface that the MediaCodec receives buffers from.
146+
* @return the surface
141147
*/
142148
public Surface getSurface() {
143149
return mSurface;
144150
}
151+
145152
/**
146153
* Queries the surface's width.
154+
* @return surface width
147155
*/
148156
public int getWidth() {
149157
int[] value = new int[1];
150158
EGL14.eglQuerySurface(mEGLDisplay, mEGLSurface, EGL14.EGL_WIDTH, value, 0);
151159
return value[0];
152160
}
161+
153162
/**
154163
* Queries the surface's height.
164+
* @return surface height
155165
*/
156166
public int getHeight() {
157167
int[] value = new int[1];
158168
EGL14.eglQuerySurface(mEGLDisplay, mEGLSurface, EGL14.EGL_HEIGHT, value, 0);
159169
return value[0];
160170
}
171+
161172
/**
162173
* Sends the presentation time stamp to EGL. Time is expressed in nanoseconds.
163174
*/
164175
public void setPresentationTime(long nsecs) {
165176
EGLExt.eglPresentationTimeANDROID(mEGLDisplay, mEGLSurface, nsecs);
166177
}
178+
167179
/**
168180
* Checks for EGL errors.
169181
*/

lib/src/main/java/com/otaliastudios/transcoder/transcode/opengl/OutputSurface.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ public class OutputSurface implements SurfaceTexture.OnFrameAvailableListener {
5555
private boolean mFrameAvailable;
5656
private TextureRender mTextureRender;
5757
/**
58-
* Creates an OutputSurface backed by a pbuffer with the specifed dimensions. The new
58+
* Creates an OutputSurface backed by a pbuffer with the specified dimensions. The new
5959
* EGL context and surface will be made current. Creates a Surface that can be passed
6060
* to MediaCodec.configure().
61+
*
62+
* @param width surface width
63+
* @param height surface height
6164
*/
6265
public OutputSurface(int width, int height) {
6366
if (width <= 0 || height <= 0) {
@@ -185,12 +188,17 @@ public void makeCurrent() {
185188
}
186189
/**
187190
* Returns the Surface that we draw onto.
191+
*
192+
* @return the output surface
188193
*/
189194
public Surface getSurface() {
190195
return mSurface;
191196
}
197+
192198
/**
193199
* Replaces the fragment shader.
200+
*
201+
* @param fragmentShader the new shader
194202
*/
195203
public void changeFragmentShader(String fragmentShader) {
196204
mTextureRender.changeFragmentShader(fragmentShader);
@@ -223,9 +231,10 @@ public void awaitNewImage() {
223231
mTextureRender.checkGlError("before updateTexImage");
224232
mSurfaceTexture.updateTexImage();
225233
}
234+
226235
/**
227236
* Wait up to given timeout until new image become available.
228-
* @param timeoutMs
237+
* @param timeoutMs timeout in ms
229238
* @return true if new image is available. false for no new image until timeout.
230239
*/
231240
public boolean checkForNewImage(int timeoutMs) {

lib/src/main/java/com/otaliastudios/transcoder/utils/AvcCsdUtils.java

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class AvcCsdUtils {
3232
private static final byte AVC_SPS_NAL_3 = 71; // 0<<7 + 2<<5 + 7<<0
3333

3434
/**
35+
* @param format the input format
3536
* @return ByteBuffer contains SPS without NAL header.
3637
*/
3738
public static ByteBuffer getSpsBuffer(MediaFormat format) {

0 commit comments

Comments
 (0)