Git Product home page Git Product logo

video2midi's Introduction

video2midi

youtube synthesia video to midi, just for fun )

Воссоздание midi с видео роликов synthesia и ей подобным.. Alt text

Video example on YouTube, creating midi from hybrid synthesia video & real piano video2midi 0.4.5.2

Video example on YouTube, creating 2 channels midi, version video2midi 0.3.9.1

Video example on YouTube, creating 6 channels midi, version video2midi 0.3.9.1

Video example on YouTube, creating 2 channels midi, version video2midi 0.3.0

Manual "How to" Or "How to use video2midi after installing"

GH already added new discuss functionality so we can talk without opening an issue... if you have any questions or comments, you can open discuss or you can write to whatsapp / telegram , i'll try to answer / help ;)

EN:

dependency

  • python-opengl
  • python-opencv
  • python-pygame
  • python-midiutil

install dependency

Debian based Linux:

sudo apt install python-opencv python-pygame python-midiutil python-opengl

Arch Linux:

sudo pacman -S hdf5 python-opencv python-pygame python-opengl
sudo pip install midiutil

Or thanks to C0rn3j you can install video2midi just from AUR now using your favorite AUR helper:

yay -S video2midi-git

Windows + Anaconda2 (python 2.7)/Anaconda3 (python 3.7):

usage

Download the video with your favorite melody (I recommend 720p), launch the program, adjust the keys in it, press Q and after the completion of the work a midi file will be created.

GNU/Linux:
./v2m.py ./synthesia_video.mkv
Windows+Anaconda2 (python 2.7)/Anaconda3 (python 3.7):

in start menu search and open Anaconda command prompt:

cd path to v2m.py
python v2m.py synthesia_video.mkv

Control:

  • h - show/hide this help
  • q - begin to recreate midi
  • s - set start frame, (mods : shift, set processing start frame to the beginning)
  • e - set end frame, (mods : shift, set processing end frame to the ending), on some formats, it does not work correctly, it seems like an OpenCV bug
  • p - if the key is specified, it will forcibly divide the output into 2 channels regardless of the settings. Splitting will be carried out depending on the position of the key relative to the specified key. Used on video with one key color.
  • o - enable or disable the ability to recognize the overlap of keys with each other. In this case, at the moment of overlapping, the end of one note and the beginning of another will be created.
  • i - enable or disable ignore/lengthening of notes with minimal duration ( if enabled the notes whose duration will be less than that specified will be ignored. If disabled the notes whose duration will be less than that specified will be automatically equated to the minimum duration.)
  • r - enable or disable resize function
  • Mouse wheel - keys adjustment
  • Left mouse button - dragging the selected key / select color from the color map
  • CTRL + Left mouse button - update selected color in the color map
  • CTRL + 0 - disable selected color in the color map
  • Right mouse button - dragging all keys, if the key is selected, the transfer is carried out relative to it.
  • Arrows - keys adjustment (mods : shift)
  • PageUp/PageDown - scrolling video (mods : shift)
  • Home/End - go to the beginning or end of the video
  • F2/F3 - save / load settings.
  • [ / ] - change base octave
  • Escape - quit
  • Space - abort re-creation and save midi file to disk

how it works

Frame by frame we scan the virtual keyboard and write the keys to the midi file...

Alt text

Additional features

All settings are moved to an ini file which can be used as common for all directories if it is located in the home directory (~/.v2m.ini) or as a separate for local directory (./v2m.ini).

You can also customize the separation into channels depending on the color of the key. To do this, in the v2m.ini file, you need to modify the color matching to the midi channel of the track. By default, each color key will be recorded in its own channel, so if you want to combine the channels, simply specify the same numbers for different colors.

color_channel_accordance = 0,0, 1,1, 2,2, 3,3, 4,4, 5,5

Alt text

You can customize the channel mapping to a MIDI instrument. To do this, in the v2m.ini file, you need to modify the correspondence of the midi channel to the instrument. The default all channels is 0 midi instrument.

channel_prog_accordance = 0,0, 0,0, 0,0, 0,0, 0,0, 0,0 

RU:

зависимости

  • python-opengl
  • python-opencv
  • python-pygame
  • python-midiutil

установка зависимостей.

Debian based Linux:

sudo apt install python-opencv python-pygame python-midiutil python-opengl

Arch Linux:

sudo pacman -S hdf5 python-opencv python-pygame python-opengl
sudo pip install midiutil

Windows + Anaconda2 (python 2.7)/Anaconda3 (python 3.7):

использование

Скачиваем видео с понравившейся мелодией ( рекомендую 720p ) , запускаем программу, в ней регулируем клавиши жмём Q и после завершения работы будет создан midi файл.

GNU/Linux:
./v2m.py ./synthesia_video.mkv
Windows+Anaconda2 (python 2.7)/Anaconda3 (python 3.7):

in start menu search and open Anaconda command prompt:

cd path to v2m.py
python v2m.py synthesia_video.mkv

Управление:

  • h - показать/спрятать помощь
  • q - приступить к воссозданию midi
  • s - Установить начальный кадр обработки (модификатор: shift, сброс на начальный кадр видео)
  • e - Установить конечный кадр обработки (модификатор: shift, сброс на конечный кадр видео), на некоторых форматах, не работает корректно, похоже на баг OpenCV
  • p - Если клавиша указана, принудительно разделит вывод на 2 канала не зависимо от настроек. Раздиление будет проведено в зависимости от положения клавиши относительно указаной клавиши. Используется на видео с одним цветом клавиш.
  • o - Включить/выключить возможность распознавать перекрытие клавиш друг другом. В данном случае в момент перекрытия будет создано окончание одной ноты и начало другой.
  • i - Включить/выключить игнорирование/удлинение нот меньше минимальной длительности ноты ( Если включено данные ноты не будут записаны в midi. Если выключено ноты длительность которых будет меньше указанной будут автоматически приравнены минимальной длительности. )
  • r - Включить/выключить функцию масштабирования
  • Mouse wheel - подстройка клавиш
  • Левая кнопка мыши - перетаскивание выбранной клавиши / выбор цвета из карты цветов.
  • CTRL + Левая кнопка мыши - обновить выбранный цвет к карте цветов.
  • Правая кнопка мыши - перетаскивание всех клавиш, если клавиша выбрана, перенос осуществляется относительно неё
  • CTRL + 0 - Выключить выбранный цвет.
  • Стрелки - подстройка клавиш (модификатор: shift)
  • PageUp/PageDown - прокрутка видео (модификатор: shift, шаг по кадру)
  • Home/End - переход в начало или конец видео
  • [ / ] - изменить базовую октаву
  • F2/F3 - записать / загрузить настройки.
  • ESCAPE - выход / quit
  • SPACE - прервать воссоздание и записать midi файл на диск / abort re-creation and save midi file to disk

как это работает

Кадр за кадром сканируется видео поток отслеживая изменения виртуальной клавиатуры после всё что зафиксировано дампим на винт.

Alt text

Дополнительные возможности

Все настройки вынесены в файл ini файл который может использоваться как общий для всех каталогов если находится в домашнем каталоге ~/.v2m.ini либо отдельный локальный для каталога ./v2m.ini.

Вы можете настроить разбиение на каналы в зависимости от цвета клавиши. Для этого в файле v2m.ini нужно поправить соответствие цвета каналу midi трека. По умолчанию каждый цвет активирующий клавишу будет записан в собственный канал, таким образом если хотите объединить каналы просто укажите для разных цветов одинаковые номера.

color_channel_accordance = 0,0, 1,1, 2,2, 3,3, 4,4, 5,5

Alt text

Вы можете настроить соотнесение канала к MIDI инструменту. Для этого в файле v2m.ini нужно поправить соответствие канала midi инструменту. По умолчанию канал равен 0 midi инструменту

channel_prog_accordance = 0,0, 0,0, 0,0, 0,0, 0,0, 0,0 

video2midi's People

Contributors

c0rn3j avatar exstrim401 avatar ivy-rew avatar lordeagle84 avatar svsdval avatar wuzhuoqing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

video2midi's Issues

Distorted sound, wrong notes, spamming

Idk why it does this but after I create the midi, the sound of the midi is very distorted and very wrong, Idk if its the amount of keys, the hands or any detail in the video, but I hope anyone can help, here's the link for the video I'm trying to make a midi https://www.youtube.com/watch?v=e0r2vRkKqd4

heres what the midi sounds like after

Le.Festin.d.Esope.Etude.Op.39.No.12.Alkan.mp4_output.mp4

resize app window

When trying to process a small resolution, the GUI is unusable. Is there a way to run the app in full screen?

Исходник видео в маленьком разрешении. Можно как-то извратиться, скрыть менюшки и перетащить ноты в нужное место, но, точно попасть практически нереально.
Минут пять прицеливался, чтобы наложить ровно всю раскладку. Если бы пришлось индивидумально ноты таскать - вряд ли бы справился. https://i.imgur.com/mYNbQa1.png

Black key position can be tuned a little bit

Thanks for the great tool. The default location for each black key can be tuned a little bit, like

    if (j == 1) or ( j == 6 ):
      keys_pos[i*12+j][0] = int(round( xx  + whitekey_width *0.4 ));
    if (j == 8 ):
      keys_pos[i*12+j][0] = int(round( xx  + whitekey_width *0.5 ));
    if ( j ==3 ) or ( j == 10 ):
      keys_pos[i*12+j][0] = int(round( xx  + whitekey_width *0.6 ));

Проблема с отслеживанием временных промежутков между нажатиями

Привет. Первый раз использую, и результат не очень вышел.

Вот фрагмент оригинального видео
https://disk.yandex.ru/i/W6HIfQbZzvC6-w

А вот этот же момент из получившегося миди
https://disk.yandex.ru/i/kdZAqZ6o8wTr8w

На слух слышно, что там постоянно сбивы какие-то между переходами BC и AG. Глянул в midi редакторе, а там одно нажатие на другое почти наслаиваются, то есть по таймингам не очень точно отслеживается, когда одну клавишу отпустили, и нажимают уже другую.

image

Это я что-то неправильно настроил, или просто Synthesia так отображает нажатия с задержкой, и соответственно твой софт так считывает? В общем, можно ли с этим что-нибудь сделать?

Оригинальный ролик:
https://youtu.be/lvppVNysQeY

can't find v2m.py

I'm on linux and after installing it with the command it can't be launched and i can't even find it on my computer

Very glitchy midi

Hello whenever i recreate the midi the video playback glitches and when it finishes, the midi is very glitchy for some reason.

Here is the video showcasing it: https://www.youtube.com/watch?v=Vm1x1yw19uc
This is the video i am trying to get a midi of: https://www.youtube.com/watch?v=5HgExMvlERg

What the midi sounds like:

Glimpse.mp4_1_output.mp4

This is the start and end of the log if that helps idk

Screenshot 2023-12-23 135309
Screenshot 2023-12-23 135341

Everything was installed properly and it does this with every song i try to do.

Oversized window

Facing issues with oversized window. The resize window button does not help.
For instance, color map is always cropped.
System Windows 10, screen display resolution 1920x1080. I use fullhd screen notebook and a external display also fullhd. Even if I use only the notebook screen, the issue persists. Any ideas?

oversized window

Crashing or doesnt work

Hello, someone suggested your video to me because I love Virtual Piano more than anything and I need Sheets. These videos they showed me shows me that I need to download Video2midi in Github. I have now done this and went to the ornder Docs. Since I have Windows 10, I selected the folder Win_Install and did all the steps except the last, because there is an error. I tried it anyway then. I downloaded the Youtube video on MP4 then pressed V2m and then selected the video it was selected and neither the video nor the function opens. heres the Video what Ima sent you what is happening: https://youtu.be/a6tJ0NKQJ2k

Lack of quantization option leads to weird rhythms

First off, I think this is a good tool, and is the only thing I could find to do the job I wanted, and for being a one-man project, it is near perfect. My main complaint is that the rhythm always turns out a little weird. This could be fixed by having the program count notes at proper intervals. For instance, I would set time to frame 1, note the bpm of the song, and then tell it the smallest interval in the song. This would likely be a quick edit that could be made to the song after the midi is generated. Although I'm not a midi expert, I feel this could fix some rhythm problems.

Too many notes?

I don't know if the creator is still active, but I wanted to know... There are WAY more than 88 keys here, is there any adjustment to how many notes are present? I saw in your My Little Pony demo screenshot that you had way fewer notes. Also, it's perfectly aligned. Is there a way to change the spacing between notes in mass (a lot at a time)?

"v2m or v2m.py [Errno 2] no such file or directory"

Can anyone help? After I type "cd C:/video2midi-masters" then type "python ./v2m.py or ./v2m on Anaconda Prompt it just says no file or directory, I'm confused cause I don't know much about coding, I watched a video on what to do after installing in rutube, but the error in the title just occurs, I'm sure I did something wrong so can anyone pls tell me how to fix this error?? Thank you

Installation in MacOS

Just here to confirm that the program works in MacOS as well. To install the dependencies, one can just use pip (as already documented for Linux in the Wiki):

pip install opencv-python pygame midiutil pyopengl

Tested on MacOS 10.14.6, Python 3.7.7 (installed via Homebrew), pip 20.0.2.

Maybe could there be a suggestion in the README to install the dependencies via pip for MacOS installations.

Note might be missing in midi file when using rollcheck

Hi,
Great code, it's really useful for me. I just found a small bug in the code:
If the prefs.rollcheck is set, it seemingly might happen that the end of a key-press is not registered and accordingly the note doesn't show in the resulting MIDI file.

To get the missing note I had to change the lines 1179-1188:

        if prefs.rollcheck_priority == 0:
          if not iswhitekey(i):
          # Priority on Black keys;
            if notes[i+1] >0: notes[i] = 0; 
            if notes[i-1] >0: notes[i] = 0; 
        else:
          if iswhitekey(i):
          # Priority on White keys;
            if notes[i+1] >0: notes[i] = 0; 
            if notes[i-1] >0: notes[i] = 0; 

to:

        if prefs.rollcheck_priority == 0:
          if not iswhitekey(i):
          # Priority on Black keys;
            if notes[i+1] >0 and notes_tmp[i] >0: notes[i] = 0; 
            if notes[i-1] >0 and notes_tmp[i] >0: notes[i] = 0; 
        else:
          if iswhitekey(i):
          # Priority on White keys;
            if notes[i+1] >0 and notes_tmp[i] >0: notes[i] = 0; 
            if notes[i-1] >0 and notes_tmp[i] >0: notes[i] = 0; 

version 0.3.6 hangs

Hi! video2midi hangs after line
cannot find setings file: /home/gnidorah/.v2m.ini
0.3.5 works fine

Small videos issues due to window size

The size of app window is the same as the opened video size, the window is not resizable. When opening small videos, like 360p, that makes the app overlay controls very cluttered. Also it's almost impossible to precisely adjust keyboard postilion due to the resolution of adjustment. I had to manually adjust keys.

Manually overriding the window size by windows manager doesn't resolve the issue.

How to add colors - Как добавить цвета

Hey, I have a few videos that don't have the preset colors, how do I add colors?

TRANSLATION/ПЕРЕВОД:

Привет, у меня есть несколько видео, в которых нет предустановленных цветов. Как мне добавить цвета?

merging two notes into one

Hello. Thank you for such a wonderful toolbox!
In general, it works great!

I tried to convert this video https://www.youtube.com/watch?v=HWu-a4zcXbw into midi.
At some moments, two notes are incorrectly recognized as one - I am attaching a picture wherein you can see your GUI interface and part of Synthesia window (please compare the green notes).
Any suggestions with settings?

Also, in the GUI interface, I have "note duration (sec): 10", although the ini file has "minimal_note_duration = 0.1".
I can change it in GUI, but in seconds resolution: 0,1,2,3 seconds etc
Thank you again.
cannot recognize two notes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.