3

Using https://pypi.org/project/av/ trying to open file for infinite playback. But the cycle ends with the last frame.

After searching and reading manuals, test code looks as follows:

(Note: these options are expected to be passed down to aiortc.contrib.media.MediaPlayer and work similarly):

import av
av.open(file="file.mp4", options={"fflags": "+genpts", "loop": "-1"})
for frame in media.decode():
    print(frame)

Question: What should be the options (and if it is possible) to play file in infinite loop? (NOT just once)

yan
  • 196
  • 1
  • 9

1 Answers1

0

According to the documentation, you create a MediaPlayer using the parameter loop=True

from aiortc.contrib.media import MediaPlayer

player = MediaPlayer(file="file.mp4", options={"fflags": "+genpts"}, loop=True)

You don't need to call PyAV yourself. It is done in MediaPlayer (see source code).

maiermic
  • 4,764
  • 6
  • 38
  • 77