Skip to content

Commit

Permalink
can be started from fragment,custom file name added
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowtham committed Oct 29, 2020
1 parent 4180902 commit 85b7db1
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ public class ActVideoTrimmer extends AppCompatActivity {

private CustomProgressView progressView;

private String path;

private String path,fileName;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -195,6 +194,7 @@ private void validate() {
assert trimVideoOptions != null;
trimType = TrimmerUtils.getTrimType(trimVideoOptions.trimType);
destinationPath = trimVideoOptions.destination;
fileName=trimVideoOptions.fileName;
hidePlayerSeek = trimVideoOptions.hideSeekBar;
isAccurateCut = trimVideoOptions.accurateCut;
compressOption = trimVideoOptions.compressOption;
Expand Down Expand Up @@ -435,9 +435,11 @@ private void validateVideo() {
if (destinationPath != null)
path = destinationPath;
int fileNo = 0;
String fileName = "trimmed_video_";
String fName = "trimmed_video_";
if (fileName!=null && !fileName.isEmpty())
fName=fileName;
File newFile = new File(path + File.separator +
(fileName + fileNo) + "." + TrimmerUtils.getFileExtension(this, uri));
(fName) + "." + TrimmerUtils.getFileExtension(this, uri));
while (newFile.exists()) {
fileNo++;
newFile = new File(path + File.separator +
Expand Down Expand Up @@ -472,6 +474,8 @@ private String[] getCompressionCommand() {
String width = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
int w = TrimmerUtils.clearNull(width).isEmpty() ? 0 : Integer.parseInt(width);
int h = Integer.parseInt(height);

//Default compression option
if (compressOption.getWidth()!=0 || compressOption.getHeight()!=0
|| !compressOption.getBitRate().equals("0k")){
return new String[]{"-ss", TrimmerUtils.formatCSeconds(lastMinValue),
Expand All @@ -483,6 +487,7 @@ private String[] getCompressionCommand() {
"22050","-t",
TrimmerUtils.formatCSeconds(lastMaxValue - lastMinValue), outputPath};
}
//Dividing high resolution video by 2(taken with camera)
else if (w >= 800) {
w = w / 2;
h = Integer.parseInt(height) / 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public ActivityBuilder setCompressOption(final CompressOption compressOption) {
return this;
}

public ActivityBuilder setFileName(final String fileName) {
options.fileName = fileName;
return this;
}

public ActivityBuilder setAccurateCut(final boolean accurate) {
options.accurateCut = accurate;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class TrimVideoOptions implements Parcelable {

public String destination;

public String fileName;

public TrimType trimType = TrimType.DEFAULT;

public long minDuration, fixedDuration;
Expand All @@ -30,6 +32,7 @@ public int describeContents() {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.destination);
dest.writeString(this.fileName);
dest.writeInt(this.trimType == null ? -1 : this.trimType.ordinal());
dest.writeLong(this.minDuration);
dest.writeLong(this.fixedDuration);
Expand All @@ -41,6 +44,7 @@ public void writeToParcel(Parcel dest, int flags) {

protected TrimVideoOptions(Parcel in) {
this.destination = in.readString();
this.fileName = in.readString();
int tmpTrimType = in.readInt();
this.trimType = tmpTrimType == -1 ? null : TrimType.values()[tmpTrimType];
this.minDuration = in.readLong();
Expand Down

0 comments on commit 85b7db1

Please sign in to comment.