Montspy / LooPyGen

Loopring Python Minter on Layer 2
17 stars 6 forks source link

[python] Properly merge audio when compositing animated images #33

Closed Montspy closed 2 years ago

Montspy commented 2 years ago

Users should be able to generate NFTs with an audio track if they provide webm or mp4 files that contain a stereo audio track.

ffmpeg can do the mixing using this filter complex:

[0:a][1:a]amerge=inputs=2,pan=stereo|c0<c0+c2|c1<c1+c3[a] [0:a][1:a]amerge=inputs=2 merge the two stereo audio sources 0:a and 1:a (from video source 0 and 1) into a 4 channel audio source pan=stereo|c0<c0+c2|c1<c1+c3 combine the 4 channels c0, c1, c2, c3 into 2 channels (stereo)

Related to MP4 support in #30

Montspy commented 2 years ago

I had to rewrite more than I thought to support files with audio and files without audio. We now support files with no audio and files with stereo audio (no mono) Implemented in #30