ffprobe.ProbeReader() can't get video bit_rate, but ffprobe.ProbeURL() can
outer199 opened this issue · comments
Desc
ffprobe.ProbeReader can't get video bit_rate, but ffprobe.ProbeURL
go-ffprobe version
v2.0.3
Video url
Download Video locally
Code
package main
import (
"context"
"fmt"
"log"
"os"
"time"
"gopkg.in/vansante/go-ffprobe.v2"
)
func main() {
ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
defer cancelFn()
data, err := ffprobe.ProbeURL(ctx, "/home/aa/aa.mp4")
if err != nil {
log.Panicf("Error getting data: %v", err)
}
fmt.Println("Filename", data.Format.Filename)
fmt.Println("BitRate", data.Format.BitRate)
fmt.Println("FormatName", data.Format.FormatName)
fmt.Println("DurationSeconds", data.Format.Duration().Seconds())
fmt.Println("Size", data.Format.Size)
fmt.Println("ProbeScore", data.Format.ProbeScore)
fmt.Println("Tags", data.Format.Tags)
fmt.Println("Width", data.FirstVideoStream().Width)
fmt.Println("Height", data.FirstVideoStream().Height)
fmt.Println("--------------------------")
ctx1, cancelFn1 := context.WithTimeout(context.Background(), 15*time.Second)
defer cancelFn1()
fileReader, err := os.Open("/home/aa/aa.mp4")
if err != nil {
log.Panicf("Error opening test file: %v", err)
}
defer fileReader.Close()
data1, err := ffprobe.ProbeReader(ctx1, fileReader)
if err != nil {
log.Panicf("Error getting data: %v", err)
}
fmt.Println("Filename", data1.Format.Filename)
fmt.Println("BitRate", data1.Format.BitRate)
fmt.Println("FormatName", data1.Format.FormatName)
fmt.Println("DurationSeconds", data1.Format.Duration().Seconds())
fmt.Println("Size", data1.Format.Size)
fmt.Println("ProbeScore", data1.Format.ProbeScore)
fmt.Println("Tags", data1.Format.Tags)
fmt.Println("Width", data1.FirstVideoStream().Width)
fmt.Println("Height", data1.FirstVideoStream().Height)
}
Prints
Filename /home/aa/aa.mp4
BitRate 195875
FormatName mov,mp4,m4a,3gp,3g2,mj2
DurationSeconds 55.832
Size 1367012
ProbeScore 100
Tags &{isom 512 isomiso2avc1mp41 }
Width 1280
Height 720
--------------------------
Filename pipe:
BitRate
FormatName mov,mp4,m4a,3gp,3g2,mj2
DurationSeconds 55.832
Size
ProbeScore 100
Tags &{isom 512 isomiso2avc1mp41 }
Width 1280
Height 720
I got same issue. ProbeReader can't get duration, but ProbeURL does.