livepeer / lpms

Livepeer media server
MIT License
282 stars 71 forks source link

Add fps and duration to GetCodecInfo #376

Closed ad-astra-video closed 1 month ago

ad-astra-video commented 10 months ago

Add FPS and Duration data to GetCodecInfo.

ad-astra-video commented 10 months ago

Performance stats indicate it performs more or less the same as not getting the FPS and Duration data. Was tested on my O node so not entirely unused test environment.

Most test files from https://test-videos.co.uk

perf_test.txt

test function was:

func main() {
    p := "/home/brad/test-videos"
    items, _ := os.ReadDir(p)
    w := tabwriter.NewWriter(os.Stdout, 1, 1, 1, ' ', tabwriter.Debug)

    fmt.Fprintln(w, "File\tTook (ms)\tFPS\tDur")
    for _, item := range items {
        vid_path := p + "/" + item.Name()
        //fmt.Println(item.Name())
        start := time.Now()
        _, mfi, err := ffmpeg.GetCodecInfo(vid_path)
        if err == nil {
            took := time.Since(start).Milliseconds()
            line := fmt.Sprintf("%v\t%v\t%v\t%v", item.Name(), took, mfi.FPS, mfi.Dur)
            fmt.Fprintln(w, line)
        } else {
            fmt.Printf("error getting codec info: %w\n", err)
        }
    }

    w.Flush()
}
leszko commented 8 months ago

@ad-astra-video Is this PR ready to merge?

ad-astra-video commented 8 months ago

I think the lpms part has no changes needed. go-livepeer does not consider getting the fps from the new fields yet though. Do you want to wait to merge until that gets added to go-livepeer?

leszko commented 8 months ago

I think the lpms part has no changes needed. go-livepeer does not consider getting the fps from the new fields yet though. Do you want to wait to merge until that gets added to go-livepeer?

Yeah, maybe let's wait and merge it all together

ad-astra-video commented 2 months ago

Rebased this to current master. Testing this with AI workflows.

j0sh commented 1 month ago

Is this PR still needed now that https://github.com/livepeer/lpms/pull/407 is merged?