mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-14 17:58:27 +00:00
ATS-812: PoC FFmpeg (experimental) - add frame width & height
- eg. to demo transcoding of video resolution (or even resize of frame if output to an image)
This commit is contained in:
@@ -7,12 +7,16 @@
|
||||
<table>
|
||||
<tr><td><div style="text-align:right">file *</div></td><td><input type="file" name="file" /></td></tr>
|
||||
<tr><td><div style="text-align:right">targetExtension *</div></td><td><input type="text" name="targetExtension" value="" /></td></tr>
|
||||
|
||||
<tr><td><div style="text-align:right">timeOffset</div></td><td><input type="text" name="timeOffset" value="" /> (eg. S or HH:MM:SS)</td></tr>
|
||||
<tr><td><div style="text-align:right">duration</div></td><td><input type="text" name="duration" value="" /> (eg. S or HH:MM:SS)</td></tr>
|
||||
|
||||
<tr><td><div style="text-align:right">frameWidth</div></td><td><input type="text" name="frameWidth" value="" /></td></tr>
|
||||
<tr><td><div style="text-align:right">frameHeight</div></td><td><input type="text" name="frameHeight" value="" /></td></tr>
|
||||
|
||||
<tr><td><div style="text-align:right">timeout</div></td><td><input type="text" name="timeout" value="" /></td></tr>
|
||||
<tr><td><div style="text-align:right">testDelay</div></td><td><input type="text" name="testDelay" value="" /></td></tr>
|
||||
|
||||
<tr><td><div style="text-align:right">timeOffset</div></td><td><input type="text" name="timeOffset" value="" /></td></tr>
|
||||
<tr><td><div style="text-align:right">duration</div></td><td><input type="text" name="duration" value="" /></td></tr>
|
||||
|
||||
<tr><td></td><td><input type="submit" value="Transform" /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
|
@@ -29,26 +29,29 @@ package org.alfresco.transformer;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/**
|
||||
* FFmpeg options builder.
|
||||
* FFmpeg options builder
|
||||
*
|
||||
* https://ffmpeg.org/ffmpeg.html#Options including:
|
||||
* - https://ffmpeg.org/ffmpeg.html#Main-options
|
||||
* - https://ffmpeg.org/ffmpeg.html#Video-Options
|
||||
* - https://ffmpeg.org/ffmpeg-utils.html#time-duration-syntax
|
||||
*
|
||||
* @author janv
|
||||
*/
|
||||
// TODO PoC for FFmpeg
|
||||
// TODO PoC for FFmpeg - add other FFmpeg transform options (as needed) ...
|
||||
public final class FFmpegOptionsBuilder
|
||||
{
|
||||
private String timeOffset;
|
||||
private String duration;
|
||||
|
||||
private Integer framesNum;
|
||||
|
||||
// TODO PoC - add other FFmpeg transform options ...
|
||||
private FFmpegOptionsBuilder() {}
|
||||
// temporal
|
||||
private String timeOffset;
|
||||
private String duration;
|
||||
|
||||
public FFmpegOptionsBuilder withTimeOffset(final String timeOffset)
|
||||
{
|
||||
this.timeOffset = timeOffset;
|
||||
return this;
|
||||
}
|
||||
// frame resolution
|
||||
private Integer frameWidth;
|
||||
private Integer frameHeight;
|
||||
|
||||
private FFmpegOptionsBuilder() {}
|
||||
|
||||
public FFmpegOptionsBuilder withFramesNum(final Integer framesNum)
|
||||
{
|
||||
@@ -56,31 +59,54 @@ public final class FFmpegOptionsBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
public FFmpegOptionsBuilder withTimeOffset(final String timeOffset)
|
||||
{
|
||||
this.timeOffset = timeOffset;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FFmpegOptionsBuilder withDuration(final String duration)
|
||||
{
|
||||
this.duration = duration;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FFmpegOptionsBuilder withFrameWidth(final Integer frameWidth)
|
||||
{
|
||||
this.frameWidth = frameWidth;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FFmpegOptionsBuilder withFrameHeight(final Integer frameHeight)
|
||||
{
|
||||
this.frameHeight = frameHeight;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String build()
|
||||
{
|
||||
StringJoiner args = new StringJoiner(" ");
|
||||
|
||||
if (timeOffset != null)
|
||||
{
|
||||
args.add("-ss "+timeOffset);
|
||||
}
|
||||
|
||||
if (framesNum != null)
|
||||
{
|
||||
args.add("-frames:v "+framesNum);
|
||||
}
|
||||
|
||||
if (timeOffset != null)
|
||||
{
|
||||
args.add("-ss "+timeOffset);
|
||||
}
|
||||
|
||||
if (duration != null)
|
||||
{
|
||||
args.add("-t "+duration);
|
||||
}
|
||||
|
||||
if ((frameWidth != null) && (frameHeight != null))
|
||||
{
|
||||
args.add("-s "+frameWidth+"x"+frameHeight);
|
||||
}
|
||||
|
||||
return args.toString();
|
||||
}
|
||||
|
||||
|
@@ -124,6 +124,9 @@ public class FFmpegCommandExecutor extends AbstractCommandExecutor
|
||||
optionsBuilder.withDuration(transformOptions.get(DURATION));
|
||||
}
|
||||
|
||||
optionsBuilder.withFrameWidth(stringToInteger(transformOptions.get(FRAME_WIDTH)));
|
||||
optionsBuilder.withFrameHeight(stringToInteger(transformOptions.get(FRAME_HEIGHT)));
|
||||
|
||||
optionsBuilder.withFramesNum(stringToInteger(transformOptions.get(FRAMES_NUM)));
|
||||
|
||||
final String options = optionsBuilder.build();
|
||||
|
@@ -73,8 +73,10 @@ public interface RequestParamMap
|
||||
String NOT_EXTRACT_BOOKMARKS_TEXT = "notExtractBookmarksText";
|
||||
String PAGE_LIMIT = "pageLimit";
|
||||
|
||||
// TODO PoC for FFmpeg
|
||||
// TODO PoC for FFmpeg - effectively target options (note: if we need specific source options, may need extra set)
|
||||
String TIME_OFFSET = "timeOffset";
|
||||
String DURATION = "duration";
|
||||
String FRAMES_NUM = "framesNum";
|
||||
String FRAME_WIDTH = "frameWidth";
|
||||
String FRAME_HEIGHT = "frameHeight";
|
||||
}
|
||||
|
Reference in New Issue
Block a user