[英]Python av play file in infinite loop
Using https://pypi.org/project/av/ trying to open file for infinite playback.使用https://pypi.org/project/av/尝试打开文件以进行无限播放。 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): (注意:这些选项预计会传递给
aiortc.contrib.media.MediaPlayer
并且工作类似):
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?问题:在无限循环中播放文件的
options
(如果可能的话)应该是什么? (NOT just once) (不只是一次)
According to the documentation , you create a MediaPlayer
using the parameter loop=True
根据文档,您使用参数
loop=True
创建一个MediaPlayer
from aiortc.contrib.media import MediaPlayer
player = MediaPlayer(file="file.mp4", options={"fflags": "+genpts"}, loop=True)
You don't need to call PyAV
yourself.你不需要自己调用
PyAV
。 It is done in MediaPlayer
(see source code ).它在
MediaPlayer
中完成(参见源代码)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.