Video Tools

Complete documentation with code snippets for py_extract's video tools module.

Importing

Import Video Tools module to your python file by,

from py_extract import Video_tools

Features of this module,

Get Video Info

This function will Extract Video info and return them in json format.

Argumenats,

  • input_file - Input File Path

Example Code Snippet,

from py_extract import Video_tools

file = "/home/itzfork/Videos/Test/test_py_extract_dual_aud.mkv"
# Output Path (Optional)
your_output_path = "/home/itzfork/My_All_Audio"

x = Video_tools.video_info(input_file=file)
print(x)

Output: Click here

Extract audios from a video

There are 2 options to select,

  1. Extract first audio
  2. Extract all audios

Extract first audio

This will extract first audio of a video and return it’s path.

Argumenats,

  • input_file - Input File Path
  • output_path [Optional] - Path to folder that extracted files go. Default path is py_extracted/one_audio

Example Code Snippet,

from py_extract import Video_tools

file = "/home/itzfork/Videos/Test/test_py_extract_dual_aud.mkv"
# Output Path (Optional)
your_output_path = "/home/itzfork/My_Folder"

x = Video_tools.extract_first_audio(input_file=file, output_path=your_output_path)
print(x)

Output: Click here

Extract all audios

This will extract all audio(s) of a video and return extracted audios path as a list.

Argumenats,

  • input_file - Input File Path
  • output_path [Optional] - Path to folder that extracted files go. Default path is py_extracted/all_audios

Example Code Snippet,

from py_extract import Video_tools

file = "/home/itzfork/Videos/Test/test_py_extract_dual_aud.mkv"
# Output Path (Optional)
your_output_path = "/home/itzfork/My_All_Audio"

x = Video_tools.extract_all_audio(input_file=file, output_path=your_output_path)
print(x)

Output: Click here

Extract Subtitles,

This is pretty same as extract_all_audio function. Using this you can extract Subtitle(s) from a video.

Argumenats,

  • input_file - Input File Path
  • output_path [Optional] - Path to folder that extracted files go. Default path is py_extracted/all_subs

Example Code Snippet,

from py_extract import Video_tools

file = "/home/itzfork/Videos/Test/test_py_extract_dual_aud.mkv"
# Output Path (Optional)
your_output_path = "/home/itzfork/My_Subs"

x = Video_tools.extract_subtitles(input_file=file, output_path=your_output_path)
print(x)

Output: Click here