httphandler

package
v1.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

README

Tasks

Metadata

POST /probe/media

Returns the container format, streams, and metadata for a media file.

The request body can be either:

  • multipart/form-data with a single file field named file; or
  • any other content type, in which case the request body is read directly as the media stream.

format and opts query parameters can be used to force a specific input format (e.g. mpegts) and pass format-specific options, for input that FFmpeg can't detect automatically.

POST /probe/source

Returns the container format, streams, and metadata for a URL, rather than an uploaded file - a network source FFmpeg can read directly (http, https, rtmp, ...), or a local capture device addressed as device://<format>/<address> (e.g. device://avfoundation/0:0, device://v4l2//dev/video0).

The url query parameter is required. format and opts query parameters can be used to force a specific input format and pass format-specific options, the same as /probe/media.

POST /metadata

Returns the detected content type and container-level metadata (e.g. title, artist) for a media file - excludes artwork and chapters, and doesn't probe streams, unlike /probe/media.

The request body can be either:

  • multipart/form-data with a single file field named file; or
  • any other content type, in which case the request body is read directly as the media stream.

filter narrows the result to a single metadata namespace or key - "namespace:" (all keys in that namespace), "name" (this name in any namespace), or "namespace:name" (one specific key); omitted means include all keys. Unlike /probe/media, there's no format/opts override - metadata extraction detects content type from the bytes themselves rather than using FFmpeg's demuxer.

Encoder

POST /encode

Starts an asynchronous encode of an uploaded media file and returns immediately - encoding is a long-running task, so this doesn't wait for it to finish. The task stays tracked by the task manager afterwards, so it can also be polled, cancelled, or watched via GET /task/{uuid}, DELETE /task/{uuid}, and GET /task/event.

The request body is always multipart/form-data, with two fields:

  • file - the media file to encode; and
  • request - a JSON-encoded object with output (required) and optional audio, video, and subtitle encoding profiles - at least one of which must be set. Each profile targets the first stream of its type found in the input.

The response depends on the request's Accept header:

  • Accept: text/event-stream streams the task's own events - the same shape as GET /task/event filtered to this task's uuid - until it finishes or the client disconnects.
  • Anything else returns the task's current status as application/json (the same shape as GET /task/{uuid}), reflecting whatever state the task is in at the moment it was started - typically not_started or running, not yet the final result.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterEncoderHandlers added in v1.9.3

func RegisterEncoderHandlers(manager *manager.Media, tasks *taskmanager.Manager, router *httprouter.Router) error

RegisterEncoderHandlers registers the encoder HTTP handlers. It takes both the media manager (to start an encode) and the task manager (to stream that task's own events for the text/event-stream response) as separate arguments, mirroring how they're wired independently in cmd/gomedia/server.go.

func RegisterMetadataHandlers

func RegisterMetadataHandlers(manager *manager.Media, router *httprouter.Router) error

Types

type EncodeFormData added in v1.9.3

type EncodeFormData struct {
	File    types.File `json:"file" form:"file" validate:"required"`
	Request string     `json:"request" form:"request" validate:"required"`
}

EncodeFormData is the multipart/form-data shape POST /encode expects - the media to encode as a file part, and the rest of the request (output format, audio/video/subtitle profiles) as a JSON-encoded string part, since taskencoder.EncodeRequest's profile fields are too complex for the generic query/form decoder to fill directly.

type FormData

type FormData struct {
	File types.File `json:"file" form:"file" validate:"required"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL