Skip to content

hongcyu/char_painting

Folders and files

Name Name
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

Char Painting


 Python  Platform

Can access my https://hongcyu.cn/posts/opencv-pictovideo.html See details

Overall thinking

  1. Separate the pictures that make up the video
  2. Convert the picture to ASCII code
  3. Compose the converted pictures into videos
  4. Add the original video music to the output video through FFmpeg and suppress it to mp4.

Precautions and usage

  1. You may need to install opencv and Pillow. If these two libraries are not available, this script will automatically install them for you. If the automatic installation fails, please run it separately in cmd pip3 install opencv-python-headless pip3 install Pillow

  2. Support common mp4, flv and other formats.

  3. You need to modify your video file path in the main function. The default video file name is input.mp4, and it is placed in the same directory as this py file. If input.mp4 is not found, you will be automatically asked for the video name.

    The simplest method: place the video in the folder of the py file, and change the video_path parameter to your video name to run.

  4. In addition, you can set up multi process processing pictures, and you can modify the number of processes yourself.

     if __name__ == '__main__': Video_path=sys. path [0]+'/input. mp4' # Change input.mp4 to your video name. Note that the preceding slash should be reserved Save_pic_path=sys. path [0]+'/cache_pic' # Don't move Save_charpic_path=sys. path [0]+'/cache_char' # Don't move Processes_number=8 # How many processes are used to process pictures at the same time, usually not more than the number of CPU threads, which can be set by yourself
  5. To add the original video audio track to the generated video and suppress it to mp4, ffmpeg needs to be installed in advance. If ffmpeg is not installed, please comment out or delete the last line

     write_audio(video_path)

About

Convert video to character drawing video with python video_to_paint

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages