To process/edit video and audio with Python+FFmpeg. [简单实用] 基于Python+FFmpeg的视频和音频的处理/剪辑。

HeZhang1994 HeZhang1994 Last update: Apr 16, 2024

Video and Audio Processing/Editing

image image image

English Version | 中文版

This is a Python implementation of processing/editing video and audio with FFmpeg libraries.

Many thanks to FFmpeg and its contributors. For more related information, please visit FFmpeg website.

Table of Contents

Functions

  • Extracting the audio from a video.

  • Adding the audio to a video that contains no audio.

  • Removing the audio from a video.

  • Converting the format of audio.

  • Cutting video or audio into clips.

  • Merging video or audio clips.

Dependencies

  • ffmpeg 4.1.1 (for Linux)
  • ffmpeg 4.1.3 (for Mac)

Install FFmpeg for Linux

  • Installation
$ sudo apt-get install ffmpeg
  • Upgrade (if applicable)
# The latest version of FFmpeg is 4.1.x (11th April 2019).
$ sudo add-apt-repository ppa:jonathonf/ffmpeg-4
$ sudo apt update && sudo apt upgrade

Install FFmpeg for Mac

  • Installation
# Install homebrew.
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install FFmpeg via homebrew.
$ brew install ffmpeg
  • Upgrade (if applicable)
# Upgrade FFmpeg via homebrew.
$ brew update && brew upgrade ffmpeg

Usage

Specify the path/name of input and output media in the code (see comments).

Video and Audio Processing

Please use the code provided in VideoAudio_Processing/.

  • To extract the audio from a video, run run_VAP_extract.py.

  • To add the audio to a video, run run_VAP_add.py.

  • To remove the audio from a video, run run_VAP_remove.py.

  • To convert the format of audio, run run_VAP_convert.py.

Video and Audio Editing

Please use the code provided in VideoAudio_Editing/.

  • To cut video or audio into clips, run run_VAE_Video_01Clip.py or run_VAE_Audio_01Clip.py.

  • To merge video or audio clips, run run_VAE_Video_02Merge.py or run_VAE_Audio_02Merge.py.


Please report an issue if you have any question about this repository, I will respond ASAP.

Please star this repository if you found its content useful. Thank you very much. ^_^

Subscribe to our newsletter