Home > OS >  Resize multiple videos in one folder using opencv
Resize multiple videos in one folder using opencv

Time:06-09

I'm trying to resize 57 files/.mp4 videos in one folder, in other words, to change the dimension of all the videos using OpenCV.

Please I need any direction or script of code

Many thanks

CodePudding user response:

I'm working in the Jupyter notebook



!for f in ./SSL-V02/*MP4; do ffmpeg -i "$f" -vf scale=512:512 "small$f" ;  done

and it gives me an error

ffmpeg version 4.3 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 7.3.0 (crosstool-NG 1.23.0.449-a04d0) configuration: --prefix=/home/user01/miniconda3/envs/pt --cc=/opt/conda/conda-bld/ffmpeg_1597178665428/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-pic --enable-pthreads --enable-shared --disable-static --enable-version3 --enable-zlib --enable-libmp3lame libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat 58. 45.100 / 58. 45.100 libavdevice 58. 10.100 / 58. 10.100 libavfilter 7. 85.100 / 7. 85.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x5588be912c00] moov atom not found ./SSL-V02/C0205.MP4: Invalid data found when processing input

and this error repeated many times

CodePudding user response:

@user14809144

   
    import os
    import ffmpeg
    
    path = './SSL-V02/' # the directory that contains video fiels 
    
    folder = os.fsencode(path)
    filenames = []
    
    for file in os.listdir(folder):
        filename = os.fsdecode(file)
        if filename.endswith( ('.MP4') ): # all the fiels ends with .mp4 
            filenames.append(filename)
    
    filenames.sort() # now you have the filenames and can do something with them

  • Related