0

I am using the ffmpeg library with python to add subtitles and a video as an overlay to a background still image. This code is working fine, but I want to use the afade parameter. The code without the afade parameter works fine. However, when I add the afade code in, I am getting the error.

Error

Unrecognized option 'af fade=t=out:st=10:d=2'.
Error splitting the argument list: Option not found

Code

    try:
        subprocess.check_call([
        'ffmpeg',
        '-i', source_file,
        '-i', padding_image_file,
        '-filter_complex',
            '[0:v]scale=iw/'+ video_scale + ':ih/' + video_scale + ',setsar=1[main];'
            '[1:v]scale=720:1280[pad];'
            '[pad][main]overlay=' + video_overlay_x + ':'+ video_overlay_y + ',subtitles=' + subtitles_file + ':force_style=\'Alignment=6,OutlineColour=&H100000000,BorderStyle=3,Outline=1,Shadow=0,Fontsize=8,MarginL=2,MarginV=20\'',
        '-c:a', 'copy', '-af "afade=t=out:st=14.2:d=0.8"', '-crf', '20', '-preset', 'fast', '-movflags', '+faststart',
        '-y', output_file
    ])

I have tried multiple options and ways to using this -af in different ways but am still getting the "option not found" error.

3
  • 1
    Have you tried '-c:a', 'copy', '-af', 'afade=t=out:st=14.2:d=0.8', '-crf', ? Commented May 18, 2023 at 18:08
  • Right. The parameter name and its values need to be in separate strings, just like you did with the other parameters. And you don't need the double-quotes in that case; you have already done the parsing that the shell would have done. Commented May 18, 2023 at 18:11
  • Thank you both. I am still trying to get my head around the flag combinations. In doing this, I received an error Filtergraph 'afade=t=out:st=14.2:d=0.8' was defined for audio output stream 0:1 but codec copy was selected. Filtering and streamcopy cannot be used together.. I am assuming this means that I am trying to combine the wrong outputs? Commented May 18, 2023 at 18:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.