Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to play next video from disk? For play-from-disk. #129

Open
Charlotte3240 opened this issue Sep 29, 2022 · 0 comments
Open

How to play next video from disk? For play-from-disk. #129

Charlotte3240 opened this issue Sep 29, 2022 · 0 comments

Comments

@Charlotte3240
Copy link

Example : play-from-disk

I try play next audio success. but, the same code for video not work.

I try it ResetReader for ivfReader. but, the frame length always is 0. then panic ivfErr.

I can't understand this.

	// * works around latency issues with Sleep (see https://github.com/golang/go/issues/44343)
			ticker := time.NewTicker(time.Millisecond * time.Duration((float32(header.TimebaseNumerator)/float32(header.TimebaseDenominator))*1000))
			for ; true; <-ticker.C {
				frame, _, ivfErr := ivf.ParseNextFrame()
				if errors.Is(ivfErr, io.EOF) {
					fmt.Printf("All video frames parsed and sent")
					//os.Exit(0)

					//MARK: - play other video
					file.Close()
					fi, err := os.Open("output1.ivf")
					if err != nil {
						panic(err)
					}
					ivf.ResetReader(func(bytesRead int64) io.Reader {
						return fi
					})
					continue
				}

				if ivfErr != nil {
					panic(ivfErr)
				}

				if ivfErr = videoTrack.WriteSample(media.Sample{Data: frame, Duration: time.Second}); ivfErr != nil {
					panic(ivfErr)
				}
			}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant