media

package
v0.0.0-...-6a2a004 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

README

Hybrid Photo/Video File Support

Apple iPhone and iPad

iOS Live Photos consist of a JPEG/HEIC image and a QuickTime AVC/HEVC video, which are both required for viewing.

We recommend using an app like PhotoSync to upload Live Photos to PhotoPrism, since the iOS web upload usually only submits the HEIC image file without the video.

Android Devices

Some Samsung and Google Android devices support taking "Motion Photos" with the included Camera app. Motion Photos are JPEG/HEIC image with a short MP4 video embedded after the image data.

The image part of these files can be opened in any image viewer that supports JPEG/HEIC, but the video part cannot. However, since the MP4 video is simply appended at the end of the image file, it can be easily read by our software and streamed through the API as needed.

Introductory Tutorials

Title Date URL
How to detect Android motion photos in Flutter May 2023 https://ente.io/blog/tech/android-motion-photos-flutter/
Stripping Embedded MP4s out of Android 12 Motion Photos Oct 2021 https://mjanja.ch/2021/10/stripping-embedded-mp4s-out-of-android-12-motion-photos/
Google Pixel "Motion Photo" Howto Mar 2021 https://linuxreviews.org/Google_Pixel_%22Motion_Photo%22
go-mp4: Golang Library and CLI Tool for MP4 Jul 2020 https://dev.to/sunfishshogi/go-mp4-golang-library-and-cli-tool-for-mp4-52o1
Working with Motion Photos Jan 2019 https://medium.com/android-news/working-with-motion-photos-da0aa49b50c
Google: Behind the Motion Photos Technology in Pixel 2 Mar 2018 https://blog.research.google/2018/03/behind-motion-photos-technology-in.html

Software Libraries and References

Title URL
Web Video Codec Guide https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_codecs
Media Container Formats https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers
MP4 Signature Format https://www.file-recovery.com/mp4-signature-format.htm
List of file signatures (Wikipedia) https://en.wikipedia.org/wiki/List_of_file_signatures
Go library for reading and writing MP4 files https://github.com/abema/go-mp4
Go library for buffered I/O with io.Seeker interface https://github.com/sunfish-shogi/bufseekio
How to use the io.Reader interface https://yourbasic.org/golang/io-reader-interface-explained/
AV1 Codec ISO Media File Format https://aomediacodec.github.io/av1-isobmff

PhotoPrism® is a registered trademark. By using the software and services we provide, you agree to our Terms of Service, Privacy Policy, and Code of Conduct. Docs are available under the CC BY-NC-SA 4.0 License; additional terms may apply.

Documentation

Overview

Package media provides general content types and maps them to file formats.

Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under Version 3 of the GNU Affero General Public License (the "AGPL"):
<https://docs.photoprism.app/license/agpl>

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

The AGPL is supplemented by our Trademark and Brand Guidelines,
which describe how our Brand Assets may be used:
<https://www.photoprism.app/trademark>

Feel free to send an email to hello@photoprism.app if you have questions, want to support our work, or just want to say hello.

Additional information can be found in our Developer Guide: <https://docs.photoprism.app/developer-guide/>

Index

Constants

This section is empty.

Variables

View Source
var (
	JpegImageHeader    = []byte{0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46, 0x00, 0x01}
	ISOBaseMediaHeader = []byte{0x66, 0x74, 0x79, 0x70, 0x69, 0x73, 0x6F, 0x6D}
)

Standard media file headers.

Formats maps file formats to general media types.

View Source
var PreviewExpr = gorm.Expr("'" + strings.Join(PreviewFileTypes, "','") + "'")
View Source
var PreviewFileTypes = []string{fs.ImageJPEG.String(), fs.ImagePNG.String()}

Functions

func Base64

func Base64(buf *bytes.Buffer) string

func MainFile

func MainFile(fileName string) bool

MainFile checks if the filename belongs to a main content type.

func Report

func Report(m fs.TypesExt, withDesc, withType, withExt bool) (rows [][]string, cols []string)

Report returns a file format documentation table.

Types

type Type

type Type string

Type represents a general media content type.

const (
	Unknown  Type = ""
	Image    Type = "image"
	Raw      Type = "raw"
	Animated Type = "animated"
	Live     Type = "live"
	Video    Type = "video"
	Vector   Type = "vector"
	Sidecar  Type = "sidecar"
)

func FromName

func FromName(fileName string) Type

FromName returns the content type matching the file extension.

func New

func New(s string) Type

New casts a string to a type.

func (Type) Equal

func (t Type) Equal(s string) bool

Equal checks if the type matches.

func (Type) Main

func (t Type) Main() bool

Main checks if this is a known main media content format.

func (Type) NotEqual

func (t Type) NotEqual(s string) bool

NotEqual checks if the type is different.

func (Type) String

func (t Type) String() string

String returns the type as string.

func (Type) Unknown

func (t Type) Unknown() bool

Unknown checks if the type is unknown.

Jump to

Keyboard shortcuts

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