ozmartian / vidcutter

A modern yet simple multi-platform video cutter and joiner.
GNU General Public License v3.0
1.77k stars 137 forks source link

Git clone & install results in--- ImportError: libmpv version is incorrect. Required 2.0 got 1.109. Missing AAC audio track leads to hang at 66% on save. #393

Closed mythtvuser closed 3 months ago

mythtvuser commented 8 months ago

After installing vidcutter (using snap on Ubuntu 22.04) It would hang on attempting to write out file. Searching for existing fixes resulted in the "hang at 60%" fault (a persistent issue concerning vidcutter's default temp file in /tmp by dates of prior instances). Uninstalled snap version and attempted local build from repo (git clone etc. using svonidze's reply from https://github.com/ozmartian/vidcutter/issues/171)

A side issue was "pip not found" when attempting "sudo pip install -U pyopengl" (resolved with "sudo apt install python3-pip")

After "cd vidcutter" --- "python3 setup.py build" and "sudo pip install ." running "vidcutter" gives result: Traceback (most recent call last): File "/usr/local/bin/vidcutter", line 5, in from vidcutter.main import main File "/usr/local/lib/python3.10/dist-packages/vidcutter/main.py", line 41, in from vidcutter.videocutter import VideoCutter File "/usr/local/lib/python3.10/dist-packages/vidcutter/videocutter.py", line 57, in from vidcutter.libs.mpvwidget import mpvWidget File "/usr/local/lib/python3.10/dist-packages/vidcutter/libs/mpvwidget.py", line 63, in import vidcutter.libs.mpv as mpv File "vidcutter/libs/pympv/mpv.pyx", line 46, in init vidcutter.libs.mpv raise ImportError( ImportError: libmpv version is incorrect. Required 2.0 got 1.109.

The snap install is a read-only filesystem, so attempts at editing/replacing files in snap install (suggested as fixes for the above elsewhere) would not work, hence all above.

EDIT: (5 hours after above:) Uninstalled the above, installed flatpak of vidcutter. Result: Back to original situation/issue -- (With frame accurate cutting de-selected) progress bars hit 66%, then freeze. (With frame accurate cutting selected) after clicking "save media" -- no file save at all, progress bars remain at 0%. No rise in CPU activity in system monitor or htop indicating processing of cuts.

Advice given by others on previous requests seeking resolution of the above, suggest it concerns vidcutter's using /tmp in the system root for storing data during "save media" and that setting up an alternate //tmp file with a symlink was a workaround which needed to be re-applied after any system reboot. If this is the case, perhaps a vidcutter config file where such options could be saved by users, taking account of their system configuration, would be appropriate.

System: Ryzen 5 4600, 32GB RAM, 2x1TB ssd (only 4% use of / so temp file space should not be an issue)... vidcutter version 6.0.5.1 (from github page)

Looking (hoping) for a frame-accurate editor for h.264 content after using DVBCut on 720p Mpeg2 files.

mythtvuser commented 8 months ago

From https://github.com/ozmartian/vidcutter/issues/248 LordMelldrum suggested: "this is because the file you want to work with has an audio stream not supported by MPEG TS stream. .... You can try transcode just the audio with AviDemux to AAC and then VidCutter works flawlessly. But would be nice to have this in one step."

EDIT: (from memory AviDemux is a windows program but Linux options exist - see below)

I will check if incompatible source audio is the cause of issue.

As a preliminary step I had used VLC to convert .ts files (DVB-T recordings) with dual audio tracks to .ps files, eliminating subtitles etc., reducing file size for temporary storage, but somehow had retained only MP2 stereo Audio (the AAC audio track was dropped but the .ps file used in my testing retained a second empty audio track! -- VLC playing source file shows a second audio track, but no audio out when it's selected.... VLC's convert function does not include option to select/drop individual audio tracks.)

Notes: using VLC failed to encode an AAC audio track from the mp2 existing in the source file. However, the mp2 audio is selected and plays normally in vidcutter's edit window. Vidcutter appears to automatically select the mp2 track for the edit phase, but parameters passed to FFMpeg may not select mp2 audio for transcoding to AAC in output!). I am therefore reprocessing my test video in Shotcut to export a file with AAC audio. I will confirm AAC audio track using VLC, then re-test.

Partial success.

New test file has AAC audio and no extra blank audio tracks. With smartcut enabled, processing Save Media commenced with rapid progress bar rise to 10%, then to 50% after a delay, and stopped at 66% (at which time CPU load decreased to around 70% then dropped to background task level.)

Ubuntu Logs [Info ] available RAM = 27632160 KB showed free RAM at around 26GB (of 32GB) during above. (I have read suggestions that multiple processing of clips hogs all system RAM. This appears not to be the cause here.)

With smartcut disabled, processing Save Media was rapid, and saved an edited file (all clips) with audio!

Conclusion(s): Audio stream in video to be edited must be AAC. MP2 audio stream or second non-AAC audio stream may be cause of "hang on save media at 66%" often reported.... Re-encoding MP2 audio to AAC before loading into vidcutter appears to alleviate the above.

Frame accurate cutting remains on wish list.

Feature request(s) (from above): Check source video for AAC encoded audio track when loaded and report when AAC missing so user can rectify. Option to select one audio track if more than one present in source file. Option to stream/convert source file out via FFMpeg, transcoding a selected audio stream to AAC (perhaps as separate utility??)

(Still wishing for frame accurate edits - Thanks to all contributors for ongoing efforts!!!)

I include below the tail of the vidcutter log file of successful output/save, in case it highlights other issues... 2023-11-16 03:33 - root - CRITICAL - <class 'KeyError'>: '' 2023-11-16 03:42 - vidcutter.libs.videoservice - INFO - SmartCut resulted in zero length file, trying again without all stream mapping 2023-11-16 03:42 - vidcutter.libs.videoservice - INFO - SmartCut resulted in zero length file, trying again without all stream mapping 2023-11-16 03:42 - root - CRITICAL - File "/app/lib/python3.11/site-packages/vidcutter/libs/videoservice.py", line 406, in smartcheck self.smartcut_jobs[index].procs[name].started.disconnect()

2023-11-16 03:42 - root - CRITICAL - <class 'TypeError'>: disconnect() failed between 'started' and all its connections 2023-11-16 03:42 - vidcutter.libs.videoservice - INFO - smartcut files are MPEG based so join via MPEG-TS 2023-11-16 03:42 - vidcutter.libs.videoservice - INFO - SmartCut resulted in zero length file, trying again without all stream mapping 2023-11-16 03:42 - vidcutter.libs.videoservice - INFO - SmartCut resulted in zero length file, trying again without all stream mapping 2023-11-16 03:42 - root - CRITICAL - File "/app/lib/python3.11/site-packages/vidcutter/libs/videoservice.py", line 406, in smartcheck self.smartcut_jobs[index].procs[name].started.disconnect()

2023-11-16 03:42 - root - CRITICAL - <class 'TypeError'>: disconnect() failed between 'started' and all its connections 2023-11-16 03:45 - vidcutter.libs.videoservice - INFO - smartcut files are MPEG based so join via MPEG-TS 2023-11-16 04:01 - root - CRITICAL - File "/app/lib/python3.11/site-packages/vidcutter/videocutter.py", line 861, in openProject mo = self.project_files[project_type].match(line)



2023-11-16 04:01 - root - CRITICAL - <class 'KeyError'>: ''
2023-11-16 04:01 - vidcutter.libs.mpvwidget - INFO - [ffmpeg] AVHWDeviceContext: Cannot load libcuda.so.1
2023-11-16 04:01 - vidcutter.libs.mpvwidget - INFO - [ffmpeg] AVHWDeviceContext: Could not dynamically load CUDA
2023-11-16 04:01 - root - CRITICAL -   File "/app/lib/python3.11/site-packages/vidcutter/videocutter.py", line 861, in openProject
    mo = self.project_files[project_type].match(line)
         ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^

2023-11-16 04:01 - root - CRITICAL - <class 'KeyError'>: ''
2023-11-16 04:06 - vidcutter.videocutter - INFO - source file is MPEG based so join via MPEG-TS
coffeemonk-exe commented 5 months ago

How was the libmpv version incorrect error fixed? Can you elaborate?

ozmartian commented 3 months ago

In vidcutter/libs/pympv/mpv.pyx, lines 33-36. You'll see the previous version commented. Whenever changing this you need to also delete vidcutter/libs/pympv/mpv.c so that it regenerates when building or executing the project.

ozmartian commented 3 months ago

The code in the repo has been set to 2.0 for sometime so please let me know if all is okay so I can close this issue.