Converting MPEG Videos into Images - wtepfenhart/BioSimVis GitHub Wiki

Conveting MPEG Videos into Images

This procedure explains the steps to covert a MPEG file into multiple images using Python utilities ffmpeg.

What is FFMPEG?

ffmpy3 is a Python wrapper for FFmpeg, originally forked from the ffmpy project. It compiles FFmpeg command line from provided arguments and their respective options and executes it using Python’s sub-process.

ffmpy3 resembles the command line approach FFmpeg uses. It can read from an arbitrary number of input “files” (regular files, pipes, network streams, grabbing devices, etc.) and write into arbitrary number of output “files”. See FFmpeg documentation for further details about how FFmpeg command line options and arguments work.

FFMPEG installation

First set up a new virtual environment in Anaconda. The Anaconda environment is set up in Python 3.6.6 version. Enter te Python virtual environment use command:

activate environment_name

To install ffmpy3 inside the environment. Use the command:

pip install ffmpy3

See confirmation for successful installation:

(mnist) C:\Users\Admin\PycharmProjects\mnist>pip install ffmpy3 Collecting ffmpy3 Downloading https://files.pythonhosted.org/packages/96/7a/4bcefef1b5d7143fc916762563d3d25afc6386a62d71c6b5970fec3a3123/ffmpy3-0.2.3-py3-none-any.whl mkl-random 1.0.1 requires cython, which is not installed. mkl-fft 1.0.4 requires cython, which is not installed. tensorflow 1.10.0 has requirement numpy<=1.14.5,>=1.13.3, but you'll have numpy 1.15.1 which is incompatible. tensorflow 1.10.0 has requirement setuptools<=39.1.0, but you'll have setuptools 40.2.0 which is incompatible. Installing collected packages: ffmpy3 Successfully installed ffmpy3-0.2.3 You are using pip version 10.0.1, however version 18.0 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Breaking mpeg video into jpg files. Please log into user account with administrator rights.

ffmpeg -i <source_mpeg_file> /%d.jpg -vcodec mjpeg -ss 0:0:0 -t 0:2:0

e.g.

  <directory> - ffmpeg -i test.mp4  C:/Users/Administrator/Documents/test/images/
  <source_mpeg_file> - test.mp4

-HH

⚠️ **GitHub.com Fallback** ⚠️