Skip to content

Commit faedc82

Browse files
authored
Add getters to FFmpegOutputBuilder and deprecate property access (bramp#320)
* Add getters to Builders and Options and deprecate property access * Make package-private fields private where unused by other classes * Update usage and documentation * Make AbstractFFmpegStreamBuilder#getMetaTags() return Immutable copy
1 parent 1374982 commit faedc82

22 files changed

+775
-44
lines changed

src/main/java/net/bramp/ffmpeg/builder/AbstractFFmpegStreamBuilder.java

Lines changed: 181 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,54 +53,117 @@
5353
*
5454
* @param <T> A concrete class that extends from the AbstractFFmpegStreamBuilder
5555
*/
56+
@SuppressWarnings({"DeprecatedIsStillUsed"})
5657
public abstract class AbstractFFmpegStreamBuilder<T extends AbstractFFmpegStreamBuilder<T>> {
5758

5859
private static final String DEVNULL = SystemUtils.IS_OS_WINDOWS ? "NUL" : "/dev/null";
5960

60-
final FFmpegBuilder parent;
61+
protected final FFmpegBuilder parent;
6162

62-
/** Output filename or uri. Only one may be set */
63+
/* Output filename or uri. Only one may be set */
64+
/** @deprecated Use {@link #getFilename()} instead */
65+
@Deprecated
6366
public String filename;
6467

68+
/** @deprecated Use {@link #getUri()} instead */
69+
@Deprecated
6570
public URI uri;
6671

72+
/** @deprecated Use {@link #getFormat()} instead */
73+
@Deprecated
6774
public String format;
6875

76+
/** @deprecated Use {@link #getStartOffset()} instead */
77+
@Deprecated
6978
public Long startOffset; // in milliseconds
79+
/** @deprecated Use {@link #getDuration()} instead */
80+
@Deprecated
7081
public Long duration; // in milliseconds
7182

83+
/** @deprecated Use {@link #getMetaTags()} instead */
84+
@Deprecated
7285
public final List<String> meta_tags = new ArrayList<>();
7386

87+
/** @deprecated Use {@link #isAudioEnabled()} instead */
88+
@Deprecated
7489
public boolean audio_enabled = true;
90+
/** @deprecated Use {@link #getAudioCodec()} instead */
91+
@Deprecated
7592
public String audio_codec;
93+
/** @deprecated Use {@link #getAudioChannels()} instead */
94+
@Deprecated
7695
public int audio_channels;
96+
/** @deprecated Use {@link #getAudioSampleRate()} instead */
97+
@Deprecated
7798
public int audio_sample_rate;
99+
/** @deprecated Use {@link #getAudioPreset()} instead */
100+
@Deprecated
78101
public String audio_preset;
79102

103+
/** @deprecated Use {@link #isVideoEnabled()} instead */
104+
@Deprecated
80105
public boolean video_enabled = true;
106+
/** @deprecated Use {@link #getVideoCodec()} instead */
107+
@Deprecated
81108
public String video_codec;
109+
/** @deprecated Use {@link #isVideoCopyinkf()} instead */
110+
@Deprecated
82111
public boolean video_copyinkf;
112+
/** @deprecated Use {@link #getVideoFrameRate()} instead */
113+
@Deprecated
83114
public Fraction video_frame_rate;
115+
/** @deprecated Use {@link #getVideoWidth()} instead */
116+
@Deprecated
84117
public int video_width;
118+
/** @deprecated Use {@link #getVideoHeight()} instead */
119+
@Deprecated
85120
public int video_height;
121+
/** @deprecated Use {@link #getVideoSize()} instead */
122+
@Deprecated
86123
public String video_size;
124+
/** @deprecated Use {@link #getVideoMovflags()} instead */
125+
@Deprecated
87126
public String video_movflags;
127+
/** @deprecated Use {@link #getVideoFrames()} instead */
128+
@Deprecated
88129
public Integer video_frames;
130+
/** @deprecated Use {@link #getVideoPixelFormat()} instead */
131+
@Deprecated
89132
public String video_pixel_format;
90133

134+
/** @deprecated Use {@link #isSubtitleEnabled()} instead */
135+
@Deprecated
91136
public boolean subtitle_enabled = true;
137+
/** @deprecated Use {@link #getSubtitlePreset()} instead */
138+
@Deprecated
92139
public String subtitle_preset;
140+
/** @deprecated Use {@link #getSubtitleCodec()} instead */
141+
@Deprecated
93142
private String subtitle_codec;
94143

144+
/** @deprecated Use {@link #getPreset()} instead */
145+
@Deprecated
95146
public String preset;
147+
/** @deprecated Use {@link #getPresetFilename()} instead */
148+
@Deprecated
96149
public String presetFilename;
150+
/** @deprecated Use {@link #getExtraArgs()} instead */
151+
@Deprecated
97152
public final List<String> extra_args = new ArrayList<>();
98153

154+
/** @deprecated Use {@link #getStrict()} instead */
155+
@Deprecated
99156
public FFmpegBuilder.Strict strict = FFmpegBuilder.Strict.NORMAL;
100157

158+
/** @deprecated Use {@link #getTargetSize()} instead */
159+
@Deprecated
101160
public long targetSize = 0; // in bytes
161+
/** @deprecated Use {@link #getPassPaddingBitrate()} instead */
162+
@Deprecated
102163
public long pass_padding_bitrate = 1024; // in bits per second
103164

165+
/** @deprecated Use {@link #isThrowWarnings()} instead */
166+
@Deprecated
104167
public boolean throwWarnings = true; // TODO Either delete this, or apply it consistently
105168

106169
protected AbstractFFmpegStreamBuilder() {
@@ -686,4 +749,120 @@ protected void addVideoFlags(FFmpegBuilder parent, ImmutableList.Builder<String>
686749
args.add("-r", video_frame_rate.toString());
687750
}
688751
}
752+
753+
public String getFormat() {
754+
return format;
755+
}
756+
757+
public Long getStartOffset() {
758+
return startOffset;
759+
}
760+
761+
public Long getDuration() {
762+
return duration;
763+
}
764+
765+
public List<String> getMetaTags() {
766+
return ImmutableList.copyOf(meta_tags);
767+
}
768+
769+
public boolean isAudioEnabled() {
770+
return audio_enabled;
771+
}
772+
773+
public String getAudioCodec() {
774+
return audio_codec;
775+
}
776+
777+
public int getAudioChannels() {
778+
return audio_channels;
779+
}
780+
781+
public int getAudioSampleRate() {
782+
return audio_sample_rate;
783+
}
784+
785+
public String getAudioPreset() {
786+
return audio_preset;
787+
}
788+
789+
public boolean isVideoEnabled() {
790+
return video_enabled;
791+
}
792+
793+
public String getVideoCodec() {
794+
return video_codec;
795+
}
796+
797+
public boolean isVideoCopyinkf() {
798+
return video_copyinkf;
799+
}
800+
801+
public Fraction getVideoFrameRate() {
802+
return video_frame_rate;
803+
}
804+
805+
public int getVideoWidth() {
806+
return video_width;
807+
}
808+
809+
public int getVideoHeight() {
810+
return video_height;
811+
}
812+
813+
public String getVideoSize() {
814+
return video_size;
815+
}
816+
817+
public String getVideoMovflags() {
818+
return video_movflags;
819+
}
820+
821+
public Integer getVideoFrames() {
822+
return video_frames;
823+
}
824+
825+
public String getVideoPixelFormat() {
826+
return video_pixel_format;
827+
}
828+
829+
public boolean isSubtitleEnabled() {
830+
return subtitle_enabled;
831+
}
832+
833+
public String getSubtitlePreset() {
834+
return subtitle_preset;
835+
}
836+
837+
public String getSubtitleCodec() {
838+
return subtitle_codec;
839+
}
840+
841+
public String getPreset() {
842+
return preset;
843+
}
844+
845+
public String getPresetFilename() {
846+
return presetFilename;
847+
}
848+
849+
public List<String> getExtraArgs() {
850+
return extra_args;
851+
}
852+
853+
public FFmpegBuilder.Strict getStrict() {
854+
return strict;
855+
}
856+
857+
public long getTargetSize() {
858+
return targetSize;
859+
}
860+
861+
public long getPassPaddingBitrate() {
862+
return pass_padding_bitrate;
863+
}
864+
865+
public boolean isThrowWarnings() {
866+
return throwWarnings;
867+
}
689868
}

src/main/java/net/bramp/ffmpeg/builder/FFmpegBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public FFmpegBuilder readAtNativeFrameRate() {
128128

129129
public FFmpegBuilder addInput(FFmpegProbeResult result) {
130130
checkNotNull(result);
131-
String filename = checkNotNull(result.format).filename;
131+
String filename = checkNotNull(result.getFormat()).getFilename();
132132
inputProbes.put(filename, result);
133133
return addInput(filename);
134134
}

src/main/java/net/bramp/ffmpeg/builder/FFmpegOutputBuilder.java

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,45 @@
1919
import net.bramp.ffmpeg.probe.FFmpegProbeResult;
2020

2121
/** Builds a representation of a single output/encoding setting */
22+
@SuppressWarnings({"DeprecatedIsStillUsed", "deprecation"})
2223
public class FFmpegOutputBuilder extends AbstractFFmpegStreamBuilder<FFmpegOutputBuilder> {
2324

2425
static final Pattern trailingZero = Pattern.compile("\\.0*$");
2526

27+
/** @deprecated Use {@link #getConstantRateFactor()} instead*/
28+
@Deprecated
2629
public Double constantRateFactor;
2730

31+
/** @deprecated Use {@link #getAudioSampleFormat()} instead*/
32+
@Deprecated
2833
public String audio_sample_format;
34+
/** @deprecated Use {@link #getAudioBitRate()} instead*/
35+
@Deprecated
2936
public long audio_bit_rate;
37+
/** @deprecated Use {@link #getAudioQuality()} instead*/
38+
@Deprecated
3039
public Double audio_quality;
40+
/** @deprecated Use {@link #getAudioBitStreamFilter()} instead*/
41+
@Deprecated
3142
public String audio_bit_stream_filter;
43+
/** @deprecated Use {@link #getAudioFilter()} instead*/
44+
@Deprecated
3245
public String audio_filter;
3346

47+
/** @deprecated Use {@link #getVideoBitRate()} instead*/
48+
@Deprecated
3449
public long video_bit_rate;
50+
/** @deprecated Use {@link #getVideoQuality()} instead*/
51+
@Deprecated
3552
public Double video_quality;
53+
/** @deprecated Use {@link #getVideoPreset()} instead*/
54+
@Deprecated
3655
public String video_preset;
56+
/** @deprecated Use {@link #getVideoFilter()} instead*/
57+
@Deprecated
3758
public String video_filter;
59+
/** @deprecated Use {@link #getVideoBitStreamFilter()} instead*/
60+
@Deprecated
3861
public String video_bit_stream_filter;
3962

4063
public FFmpegOutputBuilder() {
@@ -356,4 +379,48 @@ protected void addAudioFlags(ImmutableList.Builder<String> args) {
356379
protected FFmpegOutputBuilder getThis() {
357380
return this;
358381
}
382+
383+
public Double getConstantRateFactor() {
384+
return constantRateFactor;
385+
}
386+
387+
public String getAudioSampleFormat() {
388+
return audio_sample_format;
389+
}
390+
391+
public long getAudioBitRate() {
392+
return audio_bit_rate;
393+
}
394+
395+
public Double getAudioQuality() {
396+
return audio_quality;
397+
}
398+
399+
public String getAudioBitStreamFilter() {
400+
return audio_bit_stream_filter;
401+
}
402+
403+
public String getAudioFilter() {
404+
return audio_filter;
405+
}
406+
407+
public long getVideoBitRate() {
408+
return video_bit_rate;
409+
}
410+
411+
public Double getVideoQuality() {
412+
return video_quality;
413+
}
414+
415+
public String getVideoPreset() {
416+
return video_preset;
417+
}
418+
419+
public String getVideoFilter() {
420+
return video_filter;
421+
}
422+
423+
public String getVideoBitStreamFilter() {
424+
return video_bit_stream_filter;
425+
}
359426
}

src/main/java/net/bramp/ffmpeg/builder/MetadataSpecifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@Immutable
2020
public class MetadataSpecifier {
2121

22-
final String spec;
22+
private final String spec;
2323

2424
private MetadataSpecifier(String spec) {
2525
this.spec = checkNotNull(spec);

src/main/java/net/bramp/ffmpeg/builder/StreamSpecifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/** https://ffmpeg.org/ffmpeg.html#Stream-specifiers */
77
public class StreamSpecifier {
88

9-
final String spec;
9+
private final String spec;
1010

1111
private StreamSpecifier(String spec) {
1212
this.spec = spec;

src/main/java/net/bramp/ffmpeg/info/Codec.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
*/
1414
@Immutable
1515
public class Codec {
16-
final String name;
17-
final String longName;
16+
private final String name;
17+
private final String longName;
1818

1919
/** Can I decode with this codec */
20-
final boolean canDecode;
20+
private final boolean canDecode;
2121

2222
/** Can I encode with this codec */
23-
final boolean canEncode;
23+
private final boolean canEncode;
2424

2525
/** What type of codec is this */
26-
final CodecType type;
26+
private final CodecType type;
2727

2828
/**
2929
* @param name short codec name

0 commit comments

Comments
 (0)