Skip to content

Commit

Permalink
Fix: MonteMediaView has zero size with quicktime videos.
Browse files Browse the repository at this point in the history
  • Loading branch information
wrandelshofer committed Aug 17, 2024
1 parent 1d3ee3e commit e878e0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ protected void doRealizing() throws Exception {
reader = Registry.getInstance().getReader(new File(new URI(media.getSource())));
List<TrackInterface> tracks = new ArrayList<>();
int mediaWidth = 0, mediaHeight = 0;
int trackWidth = 0, trackHeight = 0;
Format fileFormat = reader.getFileFormat();
for (int i = 0, n = reader.getTrackCount(); i < n; i++) {
mediaWidth = (fileFormat.get(VideoFormatKeys.WidthKey, 0));
Expand All @@ -125,6 +126,8 @@ protected void doRealizing() throws Exception {
tracks.add(switch (format.get(MediaTypeKey)) {
case FormatKeys.MediaType.VIDEO -> {
realizeVideoTrack(i, metadata, format, trackFormat);
trackWidth = Math.max(trackWidth, trackFormat.get(VideoFormatKeys.WidthKey));
trackHeight = Math.max(trackHeight, trackFormat.get(VideoFormatKeys.HeightKey));
yield vTrack;
}
case FormatKeys.MediaType.AUDIO -> {
Expand All @@ -135,8 +138,8 @@ protected void doRealizing() throws Exception {
default -> new MonteUnsupportedTrack(Locale.ENGLISH, i, i + "", metadata);
});
}
int finalWidth = mediaWidth;
int finalHeight = mediaHeight;
int finalWidth = mediaWidth == 0 ? trackWidth : mediaWidth;
int finalHeight = mediaHeight == 0 ? trackHeight : mediaHeight;
runAndWait(() -> {
media.setFormat(fileFormat);
media.getTracks().addAll(tracks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public Rational getDuration(int track, long sample) throws IOException {

@Override
public Format getFileFormat() throws IOException {
return QUICKTIME;
ensureRealized();
return meta.getFileFormat();
}

@Override
Expand Down

0 comments on commit e878e0f

Please sign in to comment.