Skip to content

Instantly share code, notes, and snippets.

@dodijk
Last active June 25, 2020 06:41
Show Gist options
  • Save dodijk/9961526aeaf04fd81d30e8183f015caa to your computer and use it in GitHub Desktop.
Save dodijk/9961526aeaf04fd81d30e8183f015caa to your computer and use it in GitHub Desktop.
Quick demo of video analysis with Pachyderm.io and ffmpeg

Quick demo of video analysis with Pachyderm.io and ffmpeg

Following up on the Pachyderm beginner tutorial, in this quick demo we will analyse a video using ffmpeg.

Let's first create a repo and put a video file into it.

pachctl create repo videos
pachctl put file videos@master:redfox.webm -f https://upload.wikimedia.org/wikipedia/commons/a/a9/Red_fox_%28Vulpes_vulpes%29_looking_for_a_mouse.webm

Next we'll create a pipeline to extract frames from the video using ffmpeg. We will extract only 5 frames per second to limit computation in later pipelines.

pachctl create pipeline -f images.json

Now inspect if the pipeline has run in Pachyderm and then check out a single frame:

pachctl get file images@master:thumb0001.jpg | open -f -a /Applications/Preview.app

Now let's reuse the edge detection pipeline from the Pachyderm beginner tutorial:

pachctl create pipeline -f https://raw.githubusercontent.com/pachyderm/pachyderm/master/examples/opencv/edges.json

Again, inspect when the pipeline has run and then check out a single frame:

pachctl get file edges@master:thumb0001.png | open -f -a /Applications/Preview.app

As the last pipeline, we will stich the edge-detected frames back together using ffmpeg again:

pachctl create pipeline -f edge_video.json

Now once this one is done we can download the resulting video:

pachctl get file video@master:video.mp4
{
"pipeline": {
"name": "images"
},
"description": "A pipeline that extracts frames from videos using ffmpeg.",
"transform": {
"cmd": ["/bin/bash"],
"stdin": [
"/ffmpegwrapper.sh -i /pfs/videos/* -vf fps=5 /pfs/out/thumb%04d.jpg"
],
"image": "linuxserver/ffmpeg"
},
"input": {
"pfs": {
"repo": "videos",
"glob": "/*"
}
}
}
{
"pipeline": {
"name": "video"
},
"description": "A pipeline that recombines frames into videos using ffmpeg.",
"transform": {
"cmd": ["/bin/bash"],
"stdin": [
"/ffmpegwrapper.sh -r 5 -i /pfs/edges/thumb%04d.png -vf fps=25 /pfs/out/video.mp4"
],
"image": "linuxserver/ffmpeg"
},
"input": {
"pfs": {
"repo": "edges",
"glob": "/"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment