Search code examples
djangopython-3.xffmpegsubprocessffmpeg-php

How to execute the ffmpeg thumbnail extraction command using sub-process in django?


The following code we are using to extract the thumbnail images from video

ffmpeg -i low.mkv -vf thumbnail=10,setpts=N/TB -r 1 -vframes 10 inputframes%03d.png

This code is working absolutely fine on terminal, but it is giving an error when we are processing the same with subprocess in django.

Our aim is to generate 10 Thumbnails from any length of the video

Here is the code

vaild_fps = "'thumbnail=10,setpts=N/TB -r 1 -vframes 10'"

subprocess.call([settings.FFMPEG_PATH,
        '-i',
        input_file_path,
        '-vf',
        vaild_fps,
        thumbnail_output_file_path,            
    ]
)

Error No such filter: 'thumbnail=10,setpts=N/TB -r 1 -vframes 10'

Error opening filters!


Solution

  • Unfortunately i'am able to crack-it. Here is the solution

    subprocess.call([settings.FFMPEG_PATH,
            '-i',
            input_file_path,
            '-vf',
            'thumbnail=10,setpts=N/TB',            
            '-r',
            '1',
            '-vframes',
            '10',
            thumbnail_output_file_path,
    
        ]
    )