Deduce the duration if it isn't already present.
This commit is contained in:
parent
d56b35dff3
commit
27037a9a6a
2 changed files with 12 additions and 1 deletions
|
|
@ -188,6 +188,7 @@ public class FlvFilter extends OutputStream {
|
||||||
if (currentBox != null) {
|
if (currentBox != null) {
|
||||||
throw new IOException("Premature end of file");
|
throw new IOException("Premature end of file");
|
||||||
}
|
}
|
||||||
|
metadata.setDurationFromLastTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -438,9 +438,19 @@ public class FlvMetadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDuration(String durationStr) {
|
public void setDuration(String durationStr) {
|
||||||
this.duration.set(Double.parseDouble(durationStr));
|
setDuration(Double.parseDouble(durationStr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDuration(double seconds) {
|
||||||
|
this.duration.set(Double.valueOf(seconds));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDurationFromLastTimestamp() {
|
||||||
|
if (duration.value == null || duration.value.doubleValue() <= 0) {
|
||||||
|
setDuration(lasttimestamp.value / 1000d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setDimension(Dimension d) {
|
public void setDimension(Dimension d) {
|
||||||
this.width.set(Double.valueOf(d.getWidth()));
|
this.width.set(Double.valueOf(d.getWidth()));
|
||||||
this.height.set(Double.valueOf(d.getHeight()));
|
this.height.set(Double.valueOf(d.getHeight()));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue