Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exploring FFPMEG + node #5

Merged
merged 7 commits into from
Jun 2, 2020
Merged

Exploring FFPMEG + node #5

merged 7 commits into from
Jun 2, 2020

Conversation

shiffman
Copy link
Owner

@shiffman shiffman commented Jun 2, 2020

See #2

@joeyklee
Copy link
Collaborator

joeyklee commented Jun 2, 2020

Awesome - I'm going to working on some of the UI behaviors in the electron app template and hopefully our efforts can meet in the middle ;)

@shiffman
Copy link
Owner Author

shiffman commented Jun 2, 2020

I now have node hooked up to ffmpeg and am able to execute a script to unpack a video into all of its frames. Next step is to repack frames to video.

Does it make sense for me to create a quick web interface and process the image using tf.js in the browser or should I investigate BodyPix + tfjs-node? @joeyklee let me know if you have an opinion.

@shiffman
Copy link
Owner Author

shiffman commented Jun 2, 2020

Thinking about this a bit more maybe I want to have a browser interface b/c I want to use canvas to draw on the image and that is likely easier without me worrying about a headless browser/canvas instance?

@joeyklee
Copy link
Collaborator

joeyklee commented Jun 2, 2020

@shiffman - yes I was thinking the same thing. Does it make sense to load the video and run bodyPix on the video in the browser and then save each frame to the file system and then pack them up?

@joeyklee
Copy link
Collaborator

joeyklee commented Jun 2, 2020

So far, what I've got ready for an interface looks like below... when you click "start processing" it would trigger the segmentation process.

I've not worked in Electron before, so still figuring out a few things for file uploads, but things are getting closer in #3

Screen Shot 2020-06-02 at 1 53 55 PM

@shiffman
Copy link
Owner Author

shiffman commented Jun 2, 2020

@joeyklee yes! I now have a function that runs two ffmpeg commands, one to unpack all the frames and one to repack it as a video. I also need to run a command to extract the audio and re-add the audio. I also need to investigate retaining video quality / framerate or other important details from the original video.

Let me know when you want to try to integrate these two together?

async function processVideo(file) {
  // Make the directory
  fs.mkdirSync('frames');

  // unpack frames
  const command1 = `ffmpeg -i ${file} -qscale:v 2 frames/out%03d.jpg`;
  const response1 = await exec(command1);
  console.log(response1);

  // Apply obfuscation

  // repack frames
  const command2 = `ffmpeg -start_number 0 -i 'frames/out%3d.jpg' out.mp4`;
  const response2 = await exec(command2);
  console.log(response2);
}

@joeyklee
Copy link
Collaborator

joeyklee commented Jun 2, 2020

@shiffman - oh cool! this makes sense. I will try to integrate those functions!

@shiffman shiffman marked this pull request as ready for review June 2, 2020 18:26
@shiffman
Copy link
Owner Author

shiffman commented Jun 2, 2020

Great! This is probably at its stopping point right now so I could merge it and then we integrate these bits into the electron stuff you are working on?

@joeyklee
Copy link
Collaborator

joeyklee commented Jun 2, 2020

@shiffman - that sounds great! Please go ahead.

@shiffman
Copy link
Owner Author

shiffman commented Jun 2, 2020

Ok, merging this in! I refactored it so that the ffmpeg node script is the root of the repo with the p5.js demo in a public folder. Obviously it's all disconnected and I could redo it to all work together but I will wait until you fold in your stuff!

@shiffman shiffman changed the title [WIP] Exploring FFPMEG + node Exploring FFPMEG + node Jun 2, 2020
@shiffman shiffman merged commit 2d996b4 into master Jun 2, 2020
@joeyklee joeyklee deleted the ffmpeg branch June 2, 2020 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants