0

I want to get duration of hls. But when I run it gives me error: exit status 1

Here's my Go code

func (i *ImageGenerationService) GenerateImages(movieID int) (models.FileResponse, error) {
 if _, err := exec.LookPath("ffprobe"); err != nil {
 return models.FileResponse{}, errors.New("video.Init: ffprobe was not found in your PATH ")
 }
 files, err := i.GetVideoFiles(movieID)
 if err != nil {
 i.logger.Warn("failed to get files", zap.Error(err))
 return models.FileResponse{}, err
 }
 var ii int
 var file *models.ProcessedFiles
 for ii, file = range files {
 if file.Quality == "1080p" {
 break
 }
 }
 _, err = os.Getwd()
 if err != nil {
 i.logger.Warn("failed to get current directory", zap.Error(err))
 return models.FileResponse{}, err
 }
 args := utils.GetDurationScript(files[ii].Filename)
 cmd := exec.Command("ffprobe", args...)
 cmd.Stderr, cmd.Stdout = os.Stderr, os.Stdout
 err = cmd.Run()
 if err != nil {
 return models.FileResponse{}, err
 }
 return models.FileResponse{}, nil
}
func GetDurationScript(hls string) []string {
 return []string{
 "-v",
 "quiet",
 "-show_entries",
 "format=duration",
 "-print_format",
 "json",
 "-headers",
 `"Authorization: YOUR_TOKEN"`,
 hls,
 }
}

I'm using OS X, go1.22.

My HLS file looks like this: https://example.com/999/1080/41509578-e299-4594-a506-cf1ff9864a1b.m3u8

Correct my code if I'm wrong or give me some suggestions of how to fix this!!!

1 Answer 1

1

I found my error it was while I'm writing header:

func GetDurationScript(hls string) []string {
 return []string{
 "-v",
 "quiet",
 "-show_entries",
 "format=duration",
 "-print_format",
 "json",
 "-headers",
 `Authorization: YOUR_TOKEN`,
 "-i",
 hls,
 }
}

headers must be without quotes(', '')

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.