mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 23:39:30 +00:00
[mob][photos] Consider the 'width' and 'height' key also when parsing dimensions of video
This commit is contained in:
parent
af5e9b51e1
commit
7c202a4edb
@ -18,8 +18,8 @@ class FFProbeProps {
|
|||||||
String? bitrate;
|
String? bitrate;
|
||||||
String? majorBrand;
|
String? majorBrand;
|
||||||
String? fps;
|
String? fps;
|
||||||
String? _codecWidth;
|
String? _width;
|
||||||
String? _codecHeight;
|
String? _height;
|
||||||
int? _rotation;
|
int? _rotation;
|
||||||
|
|
||||||
// dot separated bitrate, fps, codecWidth, codecHeight. Ignore null value
|
// dot separated bitrate, fps, codecWidth, codecHeight. Ignore null value
|
||||||
@ -27,36 +27,36 @@ class FFProbeProps {
|
|||||||
final List<String> info = [];
|
final List<String> info = [];
|
||||||
if (bitrate != null) info.add('$bitrate');
|
if (bitrate != null) info.add('$bitrate');
|
||||||
if (fps != null) info.add('ƒ/$fps');
|
if (fps != null) info.add('ƒ/$fps');
|
||||||
if (_codecWidth != null && _codecHeight != null) {
|
if (_width != null && _height != null) {
|
||||||
info.add('$_codecWidth x $_codecHeight');
|
info.add('$_width x $_height');
|
||||||
}
|
}
|
||||||
return info.join(' * ');
|
return info.join(' * ');
|
||||||
}
|
}
|
||||||
|
|
||||||
int? get width {
|
int? get width {
|
||||||
if (_codecWidth == null || _codecHeight == null) return null;
|
if (_width == null || _height == null) return null;
|
||||||
final intCodecWidth = int.tryParse(_codecWidth!);
|
final intWidth = int.tryParse(_width!);
|
||||||
if (_rotation == null) {
|
if (_rotation == null) {
|
||||||
return intCodecWidth;
|
return intWidth;
|
||||||
} else {
|
} else {
|
||||||
if ((_rotation! ~/ 90).isEven) {
|
if ((_rotation! ~/ 90).isEven) {
|
||||||
return intCodecWidth;
|
return intWidth;
|
||||||
} else {
|
} else {
|
||||||
return int.tryParse(_codecHeight!);
|
return int.tryParse(_height!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int? get height {
|
int? get height {
|
||||||
if (_codecWidth == null || _codecHeight == null) return null;
|
if (_width == null || _height == null) return null;
|
||||||
final intCodecHeight = int.tryParse(_codecHeight!);
|
final intHeight = int.tryParse(_height!);
|
||||||
if (_rotation == null) {
|
if (_rotation == null) {
|
||||||
return intCodecHeight;
|
return intHeight;
|
||||||
} else {
|
} else {
|
||||||
if ((_rotation! ~/ 90).isEven) {
|
if ((_rotation! ~/ 90).isEven) {
|
||||||
return intCodecHeight;
|
return intHeight;
|
||||||
} else {
|
} else {
|
||||||
return int.tryParse(_codecWidth!);
|
return int.tryParse(_width!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,15 +168,33 @@ class FFProbeProps {
|
|||||||
result.fps = _formatFPS(stream[key]);
|
result.fps = _formatFPS(stream[key]);
|
||||||
parsedData[key] = result.fps;
|
parsedData[key] = result.fps;
|
||||||
} else if (key == FFProbeKeys.codedWidth) {
|
} else if (key == FFProbeKeys.codedWidth) {
|
||||||
result._codecWidth = stream[key].toString();
|
final width = stream[key];
|
||||||
parsedData[key] = result._codecWidth;
|
if (width != null || width != "0") {
|
||||||
|
result._width = width.toString();
|
||||||
|
parsedData[key] = result._width;
|
||||||
|
}
|
||||||
} else if (key == FFProbeKeys.codedHeight) {
|
} else if (key == FFProbeKeys.codedHeight) {
|
||||||
result._codecHeight = stream[key].toString();
|
final height = stream[key];
|
||||||
parsedData[key] = result._codecHeight;
|
if (height != null && height != "0") {
|
||||||
|
result._height = height.toString();
|
||||||
|
parsedData[key] = result._height;
|
||||||
|
}
|
||||||
|
} else if (key == FFProbeKeys.width) {
|
||||||
|
final width = stream[key];
|
||||||
|
if (width != null || width != "0") {
|
||||||
|
result._width = width.toString();
|
||||||
|
parsedData[FFProbeKeys.width] = result._width;
|
||||||
|
}
|
||||||
|
} else if (key == FFProbeKeys.height) {
|
||||||
|
final height = stream[key];
|
||||||
|
if (height != null && height != "0") {
|
||||||
|
result._height = height.toString();
|
||||||
|
parsedData[FFProbeKeys.width] = result._height;
|
||||||
|
}
|
||||||
} else if (key == FFProbeKeys.sideDataList) {
|
} else if (key == FFProbeKeys.sideDataList) {
|
||||||
|
// result._rotation = stream[key][0][FFProbeKeys.rotation];
|
||||||
for (Map sideData in stream[key]) {
|
for (Map sideData in stream[key]) {
|
||||||
if (sideData[FFProbeKeys.sideDataType] ==
|
if (sideData["side_data_type"] == "Display Matrix") {
|
||||||
SideDataType.displayMatrix.getString()) {
|
|
||||||
result._rotation = sideData[FFProbeKeys.rotation];
|
result._rotation = sideData[FFProbeKeys.rotation];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user