Skip to content

Commit

Permalink
stream: Add functions to get/set fields of Stream (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
xaionaro authored Jan 14, 2025
1 parent ac7a8c3 commit a908f28
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
20 changes: 20 additions & 0 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ func (s *Stream) EventFlags() StreamEventFlags {
return StreamEventFlags(s.c.event_flags)
}

// https://ffmpeg.org/doxygen/7.0/structAVStream.html#ab76e176c2a1d1ff09ec9c0bb88dc25e9
func (s *Stream) SetEventFlags(eventFlags StreamEventFlags) {
s.c.event_flags = C.int(eventFlags)
}

// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a6873ed62f196c24e8bf282609231786f
func (s *Stream) ID() int {
return int(s.c.id)
Expand Down Expand Up @@ -86,6 +91,16 @@ func (s *Stream) NbFrames() int64 {
return int64(s.c.nb_frames)
}

// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a6cdb0c90a69899f4e1e54704bb654936
func (s *Stream) PTSWrapBits() int {
return int(s.c.pts_wrap_bits)
}

// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a6cdb0c90a69899f4e1e54704bb654936
func (s *Stream) SetPTSWrapBits(bits int) {
s.c.pts_wrap_bits = C.int(bits)
}

// https://ffmpeg.org/doxygen/7.0/structAVStream.html#ad63fb11cc1415e278e09ddc676e8a1ad
func (s *Stream) RFrameRate() Rational {
return newRationalFromC(s.c.r_frame_rate)
Expand All @@ -111,6 +126,11 @@ func (s *Stream) StartTime() int64 {
return int64(s.c.start_time)
}

// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a7c67ae70632c91df8b0f721658ec5377
func (s *Stream) SetStartTime(startTime int64) {
s.c.start_time = C.int64_t(startTime)
}

// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6
func (s *Stream) TimeBase() Rational {
return newRationalFromC(s.c.time_base)
Expand Down
6 changes: 6 additions & 0 deletions stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,20 @@ func TestStream(t *testing.T) {
require.Equal(t, NewRational(2, 1), s1.AvgFrameRate())
s1.SetDiscard(DiscardAll)
require.Equal(t, DiscardAll, s1.Discard())
s1.SetEventFlags(1)
require.Equal(t, StreamEventFlags(1), s1.EventFlags())
s1.SetID(2)
require.Equal(t, 2, s1.ID())
s1.SetIndex(1)
require.Equal(t, 1, s1.Index())
s1.SetPTSWrapBits(2)
require.Equal(t, 2, s1.PTSWrapBits())
s1.SetRFrameRate(NewRational(2, 1))
require.Equal(t, NewRational(2, 1), s1.RFrameRate())
s1.SetSampleAspectRatio(NewRational(2, 1))
require.Equal(t, NewRational(2, 1), s1.SampleAspectRatio())
s1.SetStartTime(1)
require.Equal(t, int64(1), s1.StartTime())
s1.SetTimeBase(NewRational(1, 1))
require.Equal(t, NewRational(1, 1), s1.TimeBase())
}

0 comments on commit a908f28

Please sign in to comment.