mp4read

package module
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 8 Imported by: 1

README

mp4read

abema/go-mp4 を使ってるだけ。

mp4ファイル内のh264トラックをデコードするために必要なデータを取り出すだけ。

Documentation

Overview

Package mp4read provides for reading MP4

Index

Constants

This section is empty.

Variables

View Source
var ErrEndOfStream = fmt.Errorf("end of stream")
View Source
var MemoryLimitSampleCapacity int = 4 * 1024 * 1024

mp4 headerの情報をもとにメモリ確保をします。

Functions

This section is empty.

Types

type Mp4read

type Mp4read struct {
	// contains filtered or unexported fields
}

func NewFromFile

func NewFromFile(mp4filename string) (*Mp4read, error)

NewFromFile

mp4ファイルを読み込みます。

func NewFromReadSeeker

func NewFromReadSeeker(r io.ReadSeeker) (*Mp4read, error)

NewFromReadSeeker

mp4を読み込みます。

func (*Mp4read) Close

func (v *Mp4read) Close() error

Close

必要な後処理を行います。

func (*Mp4read) Duration

func (v *Mp4read) Duration() int64

Duration

Videoの長さを返します。1sec==Timescale()

func (*Mp4read) GetSPSPPS

func (v *Mp4read) GetSPSPPS() [][]byte

GetSPSPPS

avcC Box内のSPS/PPSデータ

func (*Mp4read) GetVideoTracks

func (v *Mp4read) GetVideoTracks() (r []int64)

GetVideoTracks

mp4に含まれるビデオトラックのリスト

func (*Mp4read) Initialize

func (v *Mp4read) Initialize() error

Initialize

video trackの詳細を読み込みます。

func (*Mp4read) NextSample

func (v *Mp4read) NextSample(out *VideoSampleInfo) error

NextSample

次のSampleデータを計算してinfoに代入します。終わりに到達するとErrEndOfStreamを返します。

func (*Mp4read) ReadMdatAtSample

func (v *Mp4read) ReadMdatAtSample(info *VideoSampleInfo, buf []byte) (avc []byte, err error)

ReadMdatAtSample

mdatからSampleデータを読み込みます。

func (*Mp4read) Seek

func (v *Mp4read) Seek(timestamp int64, force bool) (bool, error)

Seek

Timescale()単位の指定時刻より前のIDRに移動

force: true 現在より未来のtimestampでも、現在より過去のIDRに移動。
       false 同GOP内で、未来のtimestampなら移動しない。該当したら戻り値はfalse

func (*Mp4read) SetVideoTrack

func (v *Mp4read) SetVideoTrack(id int64) error

SetVideoTrack

Initialize()の前に取り出す対象のビデオトラックを指定。-1なら最初のビデオトラック。

func (*Mp4read) TimeDuration

func (v *Mp4read) TimeDuration() time.Duration

TimeDuration

time.DurationでVideoの長さを返します。

func (*Mp4read) Timescale

func (v *Mp4read) Timescale() uint32

Timescale

Videoの1秒の単位を返します。

func (*Mp4read) VideoInfo

func (v *Mp4read) VideoInfo() (*VideoInfo, error)

VideoInfo

選択されているビデオトラックの情報

type VideoInfo

type VideoInfo struct {
	Width     int
	Height    int
	Duration  int64 // Duration()
	Timescale int64 // Timescale()
	Samples   int   // フレーム数
}

VideoInfo

ビデオトラックの情報。

type VideoSampleInfo

type VideoSampleInfo struct {
	NalLengthSize   int    // サンプルデータ先頭にある長さ情報のサイズ(byte)
	TimeDelta       uint32 // サンプルの再生時間
	Number          int64  // サンプルの番号。フレーム番号ではない。
	CompositionTime int64  // 1サンプル目を0とした時の再生時刻
	// contains filtered or unexported fields
}

VideoSampleInfo

ビデオのサンプル情報。ReadMdatAtSampleに渡すとサンプルデータを取得できる。

Jump to

Keyboard shortcuts

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