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

Not exporting MP4 (on Ubuntu 18.04) #85

Closed
djboni opened this issue Dec 11, 2020 · 12 comments
Closed

Not exporting MP4 (on Ubuntu 18.04) #85

djboni opened this issue Dec 11, 2020 · 12 comments
Labels

Comments

@djboni
Copy link

djboni commented Dec 11, 2020

Hi,

I have some problems with MP4 exporting.

I tried the example below. The program runs, I can see the animation on the screen.

./MIDIVisualizer --midi file.mid --size 1920 1080 --config config.ini --export video.mp4 --format MPEG4

However there is no video.mp4 file created. I tried export to current directory "--export ." but did not work.

I am running on:
Ubuntu 18.04
8 GB RAM
GPU AMD Radeon
MIDIVisualizer v6.1

Thanks and best regards.

Djones

@djboni djboni added the bug label Dec 11, 2020
@MysticPiano
Copy link

MysticPiano commented Dec 11, 2020

Hello @djboni

Welcome to MIDI Visualizer Issues.

I see you have problems exporting .mp4 files right?

Seeing your Command line command, I might have found out a bug
./MIDIVisualizer --midi (specify path)file.mid(.mp4) --size 1920 1080 --config config.ini --export video.mp4 --format MPEG4

As you can see you have not specified the path to the folder. That might be the problem. Please try specifying the path and you might get it. Also the extension is .mid and not .mp4

Right Command

./MIDIVisualizer --midi C/Users/Mystic/Documents/MidiFiles/file.mp4 --size 1920 1080 --config config.ini --export video.mp4 --format MPEG4

Note that I am A COMMUNITY MEMBER and am helping you since I like this program. I am Not the developer of this program nor do I take any credit for fixing these issues. I try to help everyone, but if there is something wrong with the program itself and I don't know how to fix it, I may not be able to help you. If you need any more help, with anything reply and I will respond within 48 hours.

@djboni
Copy link
Author

djboni commented Dec 11, 2020

Hello @MysticPiano

I see you have problems exporting .mp4 files right?

Yes, I have problems exporting MP4 files.

As you can see you have not specified the path to the folder. That might be the problem.

I guess that is not a problem, since the file was in my CWD (current working directory) and it was being read by the visualizer, since it showed a nice visualization on screen.

However it did not output the MP4 file.

Pleas take a look at this script:

$ cat command.sh
#!/bin/sh
set -x

# Show working directory
ls -l

# Export to this directory with name video.mp4
./MIDIVisualizer/MIDIVisualizer --midi ./file.mid --size 440 240 --config ./config.ini --export ./video.mp4 --format MPEG4

# Export to this directory
./MIDIVisualizer/MIDIVisualizer --midi ./file.mid --size 440 240 --config ./config.ini --export ./ --format MPEG4

# Show working directory (no MP4 file)
ls -l

And its output:

$ ./command.sh

# Show working directory
+ ls -l
total 20
-rwxr-xr-x 1 djones djones  439 dez 11 13:39 command.sh
-rw-r--r-- 1 djones djones 7416 dez 11 11:02 config.ini
-rw-r--r-- 1 djones djones 2735 dez 11 13:21 file.mid
drwxr-xr-x 8 djones djones 4096 dez 11 10:39 MIDIVisualizer

# Export to this directory with name video.mp4
+ ./MIDIVisualizer/MIDIVisualizer --midi ./file.mid --size 440 240 --config ./config.ini --export ./video.mp4 --format MPEG4
[INFO]: 3 tracks (Tempo track (1)).
[INFO]: 480 units per quarter note .
[INFO]: Reading track 0.
[INFO]: Track $1K.516f::96:22:141:41:105:122:11:30:70:121:26:9:112:49:109:78::$0 (length: 147, instrument: , major).
[INFO]: Reading track 1.
[INFO]: Track $1K.516f::96:22:141:41:105:122:11:30:70:121:26:9:112:49:109:78::$0 (length: 1370, instrument: , major).
[INFO]: Reading track 2.
[INFO]: Track  (length: 1180, instrument: , major).
[INFO]: Final track duration 51.8919 sec.
[EXPORT]: Processing frame 3774/3774.
[EXPORT] Export took 11.063s.

# Export to this directory
+ ./MIDIVisualizer/MIDIVisualizer --midi ./file.mid --size 440 240 --config ./config.ini --export ./ --format MPEG4
[INFO]: 3 tracks (Tempo track (1)).
[INFO]: 480 units per quarter note .
[INFO]: Reading track 0.
[INFO]: Track $1K.516f::96:22:141:41:105:122:11:30:70:121:26:9:112:49:109:78::$0 (length: 147, instrument: , major).
[INFO]: Reading track 1.
[INFO]: Track $1K.516f::96:22:141:41:105:122:11:30:70:121:26:9:112:49:109:78::$0 (length: 1370, instrument: , major).
[INFO]: Reading track 2.
[INFO]: Track  (length: 1180, instrument: , major).
[INFO]: Final track duration 51.8919 sec.
[EXPORT]: Processing frame 3774/3774.
[EXPORT] Export took 10.796s.

# Show working directory (no MP4 file)
+ ls -l
total 20
-rwxr-xr-x 1 djones djones  439 dez 11 13:39 command.sh
-rw-r--r-- 1 djones djones 7416 dez 11 11:02 config.ini
-rw-r--r-- 1 djones djones 2735 dez 11 13:21 file.mid
drwxr-xr-x 8 djones djones 4096 dez 11 10:39 MIDIVisualizer

I guess it is a problem with the --export option. I may have misunderstood it, or exporting is not working on my system, which is Ubuntu Linux 18.04.

I hope we can figure it out.

Thank you very much.

@kosua20
Copy link
Owner

kosua20 commented Dec 11, 2020

Hello @djboni!
Specifying only a directory path for a video export is not currently very well supported, I'll fix this.

But you are right that your initial command line (which specifies an export filename) is correct, and your bash script also seems to use the arguments correctly. Maybe your script doesn't have the autorisation to write in the current directory (but that seems far fetched)?
Another possibility is that the MIDIVisualizer for Ubuntu binary available on the release page is currently built on Ubuntu 20 and people have encountered issues in the past when running it on 18.
On the other hand, if you have compiled MIDIVisualizer on your side, you have to make sure that ffmpeg is available as a dependency. I can give you more details on this if this is the situation you are in.

I hope this helps!

@djboni
Copy link
Author

djboni commented Dec 11, 2020

Hello @kosua20!

Specifying only a directory path for a video export is not currently very well supported, I'll fix this.

I just tried it too. The program says 'Exporting to directory: ./video.mp4' so I thought it should be a directory.

Yes, the script has write permission.

Another possibility is that the MIDIVisualizer for Ubuntu binary available on the release page is currently built on Ubuntu 20 and people have encountered issues in the past when running it on 18.

I compiled it. I did not use pre-compiled version.

make sure that ffmpeg is available as a dependency [...] I can give you more details on this if this is the situation you are in.

It is installed. I processed some videos with ffmpeg some weeks ago.

Please elaborate on these details. There must be something I am missing.

Best regards.

@kosua20
Copy link
Owner

kosua20 commented Dec 12, 2020

Regarding the compilation: when configuring the project with Cmake, ffmpeg libraries are detected automatically and video export support is then enabled. If ffmpeg is not found, video export will be disabled in the compiled binary but there is no warning if you then try to export a video from the command line, I'll fix this in a future release.

In cmake-gui you can check if FFMPEG_LIBRARIES is pointing to the ffmpeg libraries (libavcodec, libavformat,...) and FFMPEG_INCLUDE_DIRS to the proper ffmpeg include directories. You can also override these and re-configure and generate the project.

@djboni
Copy link
Author

djboni commented Dec 12, 2020

Thanks for your response, it put me in the right direction.

I tried opening cmake-gui, but did not find FFMPEG_LIBRARIES or FFMPEG_INCLUDE_DIRS anywhere. I guess I could do something like cmake .. -DFFMPEG_LIBRARIES=PATH for both of these?

Well, I was missing libalsa. I should have seen in cmake output. Now it is installed and I think this is the expected output from cmake, where it says:
enabling video output.

+ cmake ..
-- Using X11 for window creation
-- FFmpeg found, enabling video export.
-- Configuring done
-- Generating done
-- Build files have been written to: /LONGPATH.../MIDIVisualizer-src/build

It compiles and it runs without exporting.

But when I try to export this happens:
Unable to find a suitable output format for './video.mp4'

+ ./MIDIVisualizer --midi ./file.mid --size 480 270 --config ./config.ini --export ./video.mp4 --format MPEG4
[INFO]: 3 tracks (Tempo track (1)).
[INFO]: 480 units per quarter note .
[INFO]: Reading track 0.
[INFO]: Track $1K.516f::104:157:113:103:140:97:159:127:138:88:108:164:137:162:173:170::$0 (length: 160, instrument: , major).
[INFO]: Reading track 1.
[INFO]: Track $1K.516f::104:157:113:103:140:97:159:127:138:88:108:164:137:162:173:170::$0 (length: 1619, instrument: , major).
[INFO]: Reading track 2.
[INFO]: Track  (length: 1246, instrument: , major).
[INFO]: Final track duration 51.8919 sec.
[NULL @ 0x5586242aa0a0] Unable to find a suitable output format for './video.mp4'
Unable to create format context.
[EXPORT]: Processing frame 1/3774.Segmentation fault (core dumped)

The same error happens if I choose MPEG2.

Best regards.

@kosua20
Copy link
Owner

kosua20 commented Dec 12, 2020

Alright, now that we are sure that ffmpeg is used, we can check if the encoders for mpeg2 and mpeg4 are supported by your installation of ffmpeg. ffmpeg is very modular so some formats may or may not be enabled depending on the configuration set by your package repository. Could you post the output of

ffmpeg -encoders | grep mpeg

This will ask ffmpeg to list the supported encoders and filter the list for all mpeg-related encoders.

I'm going to try and replicate the issue but I don't have an Ubuntu 18 system at hand so I'll have to setup a VM. I'll let you know if I find anything new.

@djboni
Copy link
Author

djboni commented Dec 12, 2020

This is the output:

ffmpeg -encoders | grep mpeg
ffmpeg version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  WARNING: library configuration mismatch
  avcodec     configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
 V.S... ffv1                 FFmpeg video codec #1
 VF.... ffvhuff              Huffyuv FFmpeg variant
 V.S... mpeg1video           MPEG-1 video
 V.S... mpeg2video           MPEG-2 video
 V..... mpeg2_vaapi          MPEG-2 (VAAPI) (codec mpeg2video)
 V.S... mpeg4                MPEG-4 part 2
 V..... libxvid              libxvidcore MPEG-4 part 2 (codec mpeg4)
 V..... mpeg4_v4l2m2m        V4L2 mem2mem MPEG4 encoder wrapper (codec mpeg4)
 V..... msmpeg4v2            MPEG-4 part 2 Microsoft variant version 2
 V..... msmpeg4              MPEG-4 part 2 Microsoft variant version 3 (codec msmpeg4v3)

I was able to replicate the same error in a VM with Ubuntu 18.04 (compiles, runs, but gives that error when exporting).
However it works fine in a VM with Ubuntu 20.04. The same code below was run in two fresh installs of these OSs.

#!/bin/sh
set -xe

sudo apt update

case $(lsb_release -sc) in
bionic)
  echo "Ubuntu 18.04 (bionic)"
  sudo apt install -y git cmake gcc g++ build-essential ffmpeg \
                      libx11-dev      \
                      xorg-dev        \
                      libgtk-3-dev    \
                      libavcodec-dev  \
                      libavformat-dev \
                      libavdevice-dev \
                      libavutil-dev   \
                      libswscale-dev  \
                      libpostproc-dev \
                      libasound2-dev
  ;;
focal)
  echo "Ubuntu 20.04 (focal)"
  sudo apt install -y git cmake gcc g++ build-essential ffmpeg \
                      libx11-dev      \
                      xorg-dev        \
                      libgtk-3-dev    \
                      libavcodec-dev  \
                      libavformat-dev \
                      libavdevice-dev \
                      libavutil-dev   \
                      libswscale-dev  \
                      libpostproc-dev \
                      libasound2-dev
  ;;
*)
  echo "UNKNOWN lsb_release: $(lsb_release -sc)"
  exit 1
  ;;
esac

# Git Clone MIDIVisualizer
[ ! -d MIDIVisualizer-src ] &&
git clone https://github.com/kosua20/MIDIVisualizer MIDIVisualizer-src

# Create build directory and change directory
mkdir -p MIDIVisualizer-src/build
cd MIDIVisualizer-src/build

# Build
case $(lsb_release -sc) in
bionic)
  cmake .. -Wno-dev
  ;;
focal)
  cmake .. -Wno-dev
  ;;
*)
  cmake .. -Wno-dev
  ;;
esac

make

# Go back to the original directory and copy the new executable
cd -
rm -f MIDIVisualizer
cp MIDIVisualizer-src/build/MIDIVisualizer .

# Try to convert (this creates a 10 seconds animation without playing notes)
mkdir -p output
./MIDIVisualizer --size 1280 720 --export ./output/test.mp4 --format MPEG4

You may add this code into the project, if you like. I also created a script that creates mp3, mp4 and joins them.

FYI: For now, I have finished what I needed with this project running in that VM with Ubuntu 20.04.
However it was so slow in the VM...

I will provide any information you ask regarding fixing this issue.

I would like to thank you for this nice project! It was very helpful for me and surely will be for many others.

Kindest regards!

@djboni djboni changed the title Not exporting MP4 Not exporting MP4 (on Ubuntu 18.04) Dec 12, 2020
@kosua20
Copy link
Owner

kosua20 commented Dec 12, 2020

Thank you so much for this detailed report!

This was very helpful as I have now realized that on Ubuntu 18, the version of ffmpeg distirbuted is v3.4.X, while I'm using ffmpeg v4.X for the builds available on the release page. There has been a change in the way available codecs and formats are detected in ffmpeg 4.0 (now it's automatic), that's why on Ubuntu 18 no video format was supported by MIDIVisualizer.

I've pushed a fix for this along with improvements to the robustness of direct export options and a clearer error message if a format is not supported.
I will also add details on dependencies and their versions in the Build section of the readme.

kosua20 added a commit that referenced this issue Dec 12, 2020
libavformat requires an initialization call on older versions such as the one used on Ubuntu 18 (#85).
@kosua20
Copy link
Owner

kosua20 commented Dec 12, 2020

The latest v6.2 release should fix this properly.
I'll see if I can add an additional Ubuntu 18 release build as you are no the first one wanting to run MIDIVisualizer on this OS version.

@djboni
Copy link
Author

djboni commented Dec 12, 2020

I just tested and it is working here.

And that was a fast fix.

Best regards!

@kosua20
Copy link
Owner

kosua20 commented Dec 12, 2020

Awesome! I'm closing this now, and I've setup everything so that future releases will have a Ubuntu 18 binary available directly.

@kosua20 kosua20 closed this as completed Dec 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants