001package net.bramp.ffmpeg.probe;
002
003import com.google.common.collect.ImmutableList;
004import com.google.common.collect.ImmutableMap;
005import java.util.Collections;
006import java.util.List;
007import java.util.Map;
008import net.bramp.ffmpeg.shared.CodecType;
009import org.apache.commons.lang3.math.Fraction;
010
011/** Represents a media stream from an FFprobe result. */
012public class FFmpegStream {
013  public int index;
014  public String codec_name;
015  public String codec_long_name;
016  public String profile;
017  public CodecType codec_type;
018  public Fraction codec_time_base;
019
020  public String codec_tag_string;
021  public String codec_tag;
022
023  public int width;
024  public int height;
025
026  public int has_b_frames;
027
028  public String sample_aspect_ratio; // TODO Change to a Ratio/Fraction object
029  public String display_aspect_ratio;
030
031  public String pix_fmt;
032  public int level;
033  public String chroma_location;
034  public int refs;
035  public String is_avc;
036  public String nal_length_size;
037  public String id;
038  public Fraction r_frame_rate;
039  public Fraction avg_frame_rate;
040  public Fraction time_base;
041
042  public long start_pts;
043  public double start_time;
044
045  public long duration_ts;
046  public double duration;
047
048  public long bit_rate;
049  public long max_bit_rate;
050  public int bits_per_raw_sample;
051  public int bits_per_sample;
052
053  public long nb_frames;
054
055  public String sample_fmt;
056  public int sample_rate;
057  public int channels;
058  public String channel_layout;
059
060  public String color_range;
061  public String color_space;
062  public String color_transfer;
063  public String color_primaries;
064
065  public FFmpegDisposition disposition;
066
067  // TODO: Make Map immutable
068  public Map<String, String> tags;
069
070  // TODO: Convert array to immutable List
071  public SideData[] side_data_list;
072
073  public int getIndex() {
074    return index;
075  }
076
077  public String getCodecName() {
078    return codec_name;
079  }
080
081  public String getCodecLongName() {
082    return codec_long_name;
083  }
084
085  public String getProfile() {
086    return profile;
087  }
088
089  public CodecType getCodecType() {
090    return codec_type;
091  }
092
093  public Fraction getCodecTimeBase() {
094    return codec_time_base;
095  }
096
097  public String getCodecTagString() {
098    return codec_tag_string;
099  }
100
101  public String getCodecTag() {
102    return codec_tag;
103  }
104
105  public int getWidth() {
106    return width;
107  }
108
109  public int getHeight() {
110    return height;
111  }
112
113  public int getHasBFrames() {
114    return has_b_frames;
115  }
116
117  public String getSampleAspectRatio() {
118    return sample_aspect_ratio;
119  }
120
121  public String getDisplayAspectRatio() {
122    return display_aspect_ratio;
123  }
124
125  public String getPixFmt() {
126    return pix_fmt;
127  }
128
129  public int getLevel() {
130    return level;
131  }
132
133  public String getChromaLocation() {
134    return chroma_location;
135  }
136
137  public int getRefs() {
138    return refs;
139  }
140
141  public String getIsAvc() {
142    return is_avc;
143  }
144
145  public String getNalLengthSize() {
146    return nal_length_size;
147  }
148
149  public String getId() {
150    return id;
151  }
152
153  public Fraction getRFrameRate() {
154    return r_frame_rate;
155  }
156
157  public Fraction getAvgFrameRate() {
158    return avg_frame_rate;
159  }
160
161  public Fraction getTimeBase() {
162    return time_base;
163  }
164
165  public long getStartPts() {
166    return start_pts;
167  }
168
169  public double getStartTime() {
170    return start_time;
171  }
172
173  public long getDurationTs() {
174    return duration_ts;
175  }
176
177  public double getDuration() {
178    return duration;
179  }
180
181  public long getBitRate() {
182    return bit_rate;
183  }
184
185  public long getMaxBitRate() {
186    return max_bit_rate;
187  }
188
189  public int getBitsPerRawSample() {
190    return bits_per_raw_sample;
191  }
192
193  public int getBitsPerSample() {
194    return bits_per_sample;
195  }
196
197  public long getNbFrames() {
198    return nb_frames;
199  }
200
201  public String getSampleFmt() {
202    return sample_fmt;
203  }
204
205  public int getSampleRate() {
206    return sample_rate;
207  }
208
209  public int getChannels() {
210    return channels;
211  }
212
213  public String getChannelLayout() {
214    return channel_layout;
215  }
216
217  public String getColorRange() {
218    return color_range;
219  }
220
221  public String getColorSpace() {
222    return color_space;
223  }
224
225  public String getColorTransfer() {
226    return color_transfer;
227  }
228
229  public String getColorPrimaries() {
230    return color_primaries;
231  }
232
233  public FFmpegDisposition getDisposition() {
234    return disposition;
235  }
236
237  public Map<String, String> getTags() {
238    return ImmutableMap.copyOf(tags);
239  }
240
241  /** Returns the list of side data associated with this stream. */
242  public List<SideData> getSideDataList() {
243    if (side_data_list == null) {
244      return Collections.emptyList();
245    }
246
247    return ImmutableList.copyOf(side_data_list);
248  }
249
250  /** Represents side data associated with an FFprobe stream. */
251  public static class SideData {
252    public String side_data_type;
253    public String displaymatrix;
254    public int rotation;
255
256    public String getSideDataType() {
257      return side_data_type;
258    }
259
260    public String getDisplaymatrix() {
261      return displaymatrix;
262    }
263
264    public int getRotation() {
265      return rotation;
266    }
267  }
268}