ffpyplayer icon indicating copy to clipboard operation
ffpyplayer copied to clipboard

Help setting video/audio filters for `MediaPlayer` using `lib_opts`

Open blsqr opened this issue 2 years ago • 2 comments

Hi there,

I'm looking for some help regarding the syntax to set video and/or audio filters in MediaPlayer (where I'm trying to speed up a video). The following ffplay command with video/audio filters works as expected:

ffplay -i video.mp4 -vf "[in]setpts=0.5*PTS[out]" -af "[in]atempo=2.0[out]"

I translated this into lib_opts as follows:

lib_opts = {
    "-vf": "[in]setpts=0.5*PTS[out]",
    "-af": "[in]atempo=2.0[out]",
}
ff_opts = {
    "sync": "audio",
    "paused": False,
    "ss": 0,  # seek to start
    "infbuf": False,
}

player = MediaPlayer(
    video_url, lib_opts=lib_opts, ff_opts=ff_opts
)

… but get the error: library option -vf: b'[in]setpts=0.5*PTS[out]' not found. The same happens with vf/af.

Are audio/video filters supported by MediaPlayer? If so, how can I pass these options correctly?

blsqr avatar Aug 16 '23 10:08 blsqr

Very late response, I know, but I found out that you have to set video filters in ff_opts.

ff_opts = {
    "fps": 8
}

MediaPlayer(video_url, ff_opts=ff_opts)

Just posting this in case someone has the same headache I was going through.

truubo avatar Jan 12 '25 04:01 truubo

Thank you, I wasn't aware that fps is a valid option in ff_opts! However, this fps setting seems to be ignored, both with sync: audio and without. I will test again in a more isolated setting, though.

Which version of ffpyplayer and ffmpeg are you using?

blsqr avatar Jan 13 '25 09:01 blsqr