ffmpeg-python icon indicating copy to clipboard operation
ffmpeg-python copied to clipboard

How to get pts associated with frame.

Open edvardHua opened this issue 6 years ago • 4 comments

When i streaming the video through rtmp protocol, i want to get frame data and pts at the same time. It's there have method to do it ?

edvardHua avatar Sep 04 '19 08:09 edvardHua

Were you able to resolve this? I am looking for a similar solution.

tcdalton avatar Nov 25 '19 16:11 tcdalton

Maybe you can try something like this:

_, message = ffmpeg.input(...).filter('showinfo').output(...).run(quiet=True)

and then get pts from the string in

message.decode()

using a regexp.

This is working for me when dissecting a video file into frames.

CaveSven avatar Jul 24 '20 07:07 CaveSven

Any pointers on how to get a pts timestamp and frame without loading the entire video file into memory? I'm able to iteratively get the frames from the Process video frame-by-frame using numpy section of the documentation, but I'm not able to capture the output of the showinfo filter.

process = (
    ffmpeg
    .input(video_path)
    .filter("fps", 2)
    .filter("showinfo")
    .output('pipe:', format='rawvideo', pix_fmt='rgb24', vframes=8)
    .run_async(pipe_stdout=True)
)

while True:
    in_bytes = process.stdout.read(width * height * 3)
    if not in_bytes:
        break
    
    in_frame = np.frombuffer(in_bytes, np.uint8).reshape([height, width, 3])

aneeshvartakavi avatar Mar 21 '21 22:03 aneeshvartakavi

Hi, I've the same problem to solve. Do you have found the solution? If yes, can you share it please? Thanks

aimaicai avatar Feb 22 '24 11:02 aimaicai