PeerTube icon indicating copy to clipboard operation
PeerTube copied to clipboard

Enhance Video Studio API to Allow Custom Watermark Positioning, Size, and Transparency

Open raazkarkee405 opened this issue 11 months ago • 1 comments

Describe the problem to be solved

Image

The current PeerTube API endpoint /api/v1/videos/{id}/studio/edit allows users to add a watermark to a video, but it does not provide options to customize the watermark's position, size, or transparency. The watermark is applied with default settings as defined in the PeerTube codebase:

export const VIDEO_FILTERS = { WATERMARK: { SIZE_RATIO: 1 / 10, HORIZONTAL_MARGIN_RATIO: 1 / 20, VERTICAL_MARGIN_RATIO: 1 / 20 } } This means the watermark is always placed in a fixed position (top-left corner, based on the margin ratios) and at a fixed size (1/10th of the video dimensions), with no option to adjust its transparency. This lack of flexibility limits the usability for users who need more control over how the watermark appears on their videos.

Additionally, there is no way to specify watermark and its properties (position, size, transparency) during the video upload process, which would be a more seamless experience for users who want to apply a watermark at the time of upload.

Describe the solution you would like

I propose the following enhancements to the PeerTube API and functionality:

  1. Extend the /api/v1/videos/{id}/studio/edit Endpoint:
  • Add new optional parameters to the API to allow users to customize the watermark:
  • watermark_position: An object specifying the position of the watermark (e.g., { x: number, y: number } in pixels or percentages, or predefined positions like "top-left", "bottom-right", etc.).
  • watermark_size: A parameter to adjust the size of the watermark (e.g., a ratio like the current SIZE_RATIO or a specific width/height in pixels).
  • watermark_transparency: A parameter to set the opacity of the watermark (e.g., a value between 0 and 1, where 0 is fully transparent and 1 is fully opaque).
  1. Add Watermark Customization During Video Upload:
  • Extend the video upload API to include optional watermark parameters in the request body, similar to the ones proposed above. This would allow users to apply a watermark with custom properties at the time of upload.
  1. Add a Hook for Watermark Customization (if feasible):
  • Introduce a server-side hook that developers can use to programmatically modify watermark properties using plugin before the video is processed. This would allow advanced users to integrate custom logic for watermark application.

These changes would provide greater flexibility for users to customize watermarks in PeerTube, both during video editing and at upload time, while also enabling plugins to extend functionality via hooks.

raazkarkee405 avatar Mar 27 '25 05:03 raazkarkee405

I would love the studio API to have a "save to new" function. for creating sub-clips. This should be on a separate issue probably, but I thought I would just pile on here ... 😉

stevespaw avatar Apr 18 '25 16:04 stevespaw