Skip to content

+genpts passed as option to ffmpeg doesn't work #1521

Description

@aseemk98

Overview

I am receiving an mpeg2ts on localhost:7000. The issue is that the stream doesn't contain any pts/dts information at all. Hence, I used the genpts flag in in fflags to generate these on the go. Here is my test code:

import av
import os

                                         
options = {"fflags": "+genpts"}

                                        
container = av.open(                         
    file="udp://localhost:7000",                          
    format="mpegts",            
    mode="r",                   
    options=options,
    timeout=5                                        
)
container.gen_pts = True     
print("Default value of gen_pts:", container.gen_pts)                                            

for packet in container.demux():
    print(f"Packet PTS: {packet.pts}, DTS: {packet.dts}") 
    for frame in packet.decode():
        print(f"Frame PTS: {frame.pts}, DTS: {frame.dts}, Time: {frame.time}")

Expected behavior

To verify whether its an issue with my ffmpeg installation, I used ffmpeg with the genpts option to generate a .ts file and then used ffprobe to check for pts/dts values.
ffmpeg -fflags +genpts -i udp://localhost:7000 -c copy output.ts followed by
ffprobe -select_streams v -show_frames output.ts | less

This does embed pts and dts for every frame:

[FRAME]
media_type=video
stream_index=0
key_frame=1
pts=126000
pts_time=1.400000
pkt_dts=126000
pkt_dts_time=1.400000
best_effort_timestamp=126000
best_effort_timestamp_time=1.400000
duration=3000
duration_time=0.033333
pkt_pos=564
pkt_size=48211
width=1920
height=1080
crop_top=0
crop_bottom=0
crop_left=0
crop_right=0
pix_fmt=yuv420p
sample_aspect_ratio=1:1
pict_type=I
interlaced_frame=0
top_field_first=0
repeat_pict=0
color_range=tv
color_space=unknown
color_primaries=bt709
color_transfer=unknown
chroma_location=left
[/FRAME]

Actual behavior

But when I set the same option through the PyAV code above, all the pts/dts values are printed as None.

Versions

  • OS: macOS 13.4
  • PyAV runtime:
PyAV v10.0.0
library configuration: --disable-static --enable-shared --libdir=/tmp/vendor/lib --prefix=/tmp/vendor --arch=arm64 --enable-cross-compile --disable-alsa --disable-doc --disable-mediafoundation --enable-fontconfig --enable-gmp --disable-gnutls --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --disable-libxcb --enable-libxml2 --enable-libxvid --enable-lzma --enable-version3 --enable-zlib
library license: GPL version 3 or later
libavcodec     59. 37.100
libavdevice    59.  7.100
libavfilter     8. 44.100
libavformat    59. 27.100
libavutil      57. 28.100
libswresample   4.  7.100
libswscale      6.  7.100

Research

I have done the following:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions