|
@@ -38,13 +38,34 @@ public class FFmpegWrapper {
|
|
|
String codecName = jsonObject1.get("codec_name").getAsString();
|
|
String codecName = jsonObject1.get("codec_name").getAsString();
|
|
|
String codecTagString = jsonObject1.get("codec_tag_string").getAsString();
|
|
String codecTagString = jsonObject1.get("codec_tag_string").getAsString();
|
|
|
double bitRate = jsonObject1.get("bit_rate").getAsDouble();
|
|
double bitRate = jsonObject1.get("bit_rate").getAsDouble();
|
|
|
- double duration = jsonObject1.get("duration").getAsDouble();
|
|
|
|
|
|
|
+ JsonElement durationElement = jsonObject1.get("duration");
|
|
|
|
|
+ double duration;
|
|
|
|
|
+ if (durationElement == null) {
|
|
|
|
|
+ duration = 0;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ duration = durationElement.getAsDouble();
|
|
|
|
|
+ }
|
|
|
audioProps = new AudioProps(codecName, codecTagString, bitRate, duration);
|
|
audioProps = new AudioProps(codecName, codecTagString, bitRate, duration);
|
|
|
} else if (codecType.equals("video")) {
|
|
} else if (codecType.equals("video")) {
|
|
|
String codecName = jsonObject1.get("codec_name").getAsString();
|
|
String codecName = jsonObject1.get("codec_name").getAsString();
|
|
|
String codecTagString = jsonObject1.get("codec_tag_string").getAsString();
|
|
String codecTagString = jsonObject1.get("codec_tag_string").getAsString();
|
|
|
- double bitRate = jsonObject1.get("bit_rate").getAsDouble();
|
|
|
|
|
- double duration = jsonObject1.get("duration").getAsDouble();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ double bitRate;
|
|
|
|
|
+ JsonElement biteRateElement = jsonObject1.get("bit_rate");
|
|
|
|
|
+ if (biteRateElement == null) {
|
|
|
|
|
+ bitRate = 0;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ bitRate = biteRateElement.getAsDouble();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ double duration;
|
|
|
|
|
+ JsonElement durationElement = jsonObject1.get("duration");
|
|
|
|
|
+ if (durationElement == null) {
|
|
|
|
|
+ duration = 0;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ duration = durationElement.getAsDouble();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
double codedWidth = jsonObject1.get("coded_width").getAsDouble();
|
|
double codedWidth = jsonObject1.get("coded_width").getAsDouble();
|
|
|
double codedHeight = jsonObject1.get("coded_height").getAsDouble();
|
|
double codedHeight = jsonObject1.get("coded_height").getAsDouble();
|
|
|
videoProps = new VideoProps(codecName, codecTagString, bitRate, duration, codedWidth, codedHeight);
|
|
videoProps = new VideoProps(codecName, codecTagString, bitRate, duration, codedWidth, codedHeight);
|
|
@@ -57,14 +78,16 @@ public class FFmpegWrapper {
|
|
|
double bitRate = format.get("bit_rate").getAsDouble();
|
|
double bitRate = format.get("bit_rate").getAsDouble();
|
|
|
|
|
|
|
|
MediaProps mediaProps = new MediaProps(audioProps, videoProps);
|
|
MediaProps mediaProps = new MediaProps(audioProps, videoProps);
|
|
|
- JsonObject tags = format.get("tags").getAsJsonObject();
|
|
|
|
|
- JsonElement jsonElement = tags.get("creation_time");
|
|
|
|
|
- if (jsonElement != null) {
|
|
|
|
|
- String creationTime = jsonElement.getAsString();
|
|
|
|
|
- LocalDateTime localDateTime = DateTimeConverter.localDateTime(creationTime);
|
|
|
|
|
- mediaProps.setCreateTime(localDateTime);
|
|
|
|
|
|
|
+ JsonElement tagsElement = format.get("tags");
|
|
|
|
|
+ if (tagsElement != null) {
|
|
|
|
|
+ JsonObject tags = tagsElement.getAsJsonObject();
|
|
|
|
|
+ JsonElement jsonElement = tags.get("creation_time");
|
|
|
|
|
+ if (jsonElement != null) {
|
|
|
|
|
+ String creationTime = jsonElement.getAsString();
|
|
|
|
|
+ LocalDateTime localDateTime = DateTimeConverter.localDateTime(creationTime);
|
|
|
|
|
+ mediaProps.setCreateTime(localDateTime);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
return mediaProps;
|
|
return mediaProps;
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|