Comments (8)
Had a play around today, you can also use good ol' ffmpeg
to map the audio from the source video over the generated output:
imageio.mimsave('generated.mp4', [img_as_ubyte(frame) for frame in predictions], fps=30)
!ffmpeg -y -i source_video.mp4 -q:a 0 -map a sample.mp3
!ffmpeg -y -i generated.mp4 -i sample.mp3 -map 0 -map 1 -codec copy final.mp4
from first-order-model.
Alternatively, you can use moviepy library with just 4 lines of code:
https://colab.research.google.com/drive/1T2BEp281ogKwrH5MbRWH1IbU74XehNL_#scrollTo=gk_uBmzWRKvl&line=4&uniqifier=1
from first-order-model.
The audio is lost during opening using imageio.mimread. I guess imageio not support audio. So the only way is to copy audio stream to the output using some external program such as ffmpeg.
from first-order-model.
WARNING: running this will update some dependencies and break demo functionality so only do this on a different environment than first-order-model
I've used mhmovie
. To install it run:
pip3 install mhmovie
Then merge audio from your source video with demo output video into a new file called final.mp4
:
from mhmovie.code import *
sourceAudio = movie("source.mp4").extract_music()
targetVideo = movie("generated.mp4")
final = targetVideo + sourceAudio
final.save("final.mp4")
from first-order-model.
Hi,
I made a version of @AliaksandrSiarohin original demo notebook with audio. Check it out at https://colab.research.google.com/github/weltonrodrigo/first-order-model/blob/master/deepfake_babysteps.ipynb
from first-order-model.
I managed to get a good result with the following:
ffmpeg -i video.mp4 -i audio.mp3 -shortest -c:v copy -c:a aac -b:a 256k output.mp4
The above suggested ffpmeg commands resulted in no audio in the output for me, but mine worked.
from first-order-model.
As simple as it is using ffmpeg
if you have not turned off the warnings
import warnings
warnings.filterwarnings("ignore")
You will notice there are a few frames that are dropped during the preprocessing (resizing to 256x256) of the video. And just merging the audio layer back with the video doesn't produce quite a good result, but I think it is just a matter of level of details. The video produced is shorted in comparison to the source-audio.
from first-order-model.
@AliaksandrSiarohin This had been fixed by #415 (and #484 for CLI) and should be closed.
from first-order-model.
Related Issues (20)
- Can't use an own video for colab demo HOT 6
- 把first order motion整合到现有框架里 HOT 1
- issue on requirement.txt HOT 1
- out = torch.cat([out, skip], dim=1)
- RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 28 but got size 29 for tensor number 1 in the list. HOT 4
- architecture
- Training doesn't work on custom datasets HOT 12
- model_state_dict and other details
- onxx
- About evaluation
- The model of fashion.pth.tar can not down,because it is error. HOT 1
- real time use
- Software developer
- Retraining 512x512 with 68 keypoints,then retraining 512x512 with dlib 68 keypoints detector HOT 2
- Datasets and contact details
- Cannot install correctly, What do i have to do?
- where is the checkpoint downloaded?
- Cita dgt
- Display of key points HOT 1
- Hi
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from first-order-model.