jarun / nnn

n³ The unorthodox terminal file manager
BSD 2-Clause "Simplified" License
19.1k stars 760 forks source link

preview-tui: mpv #1825

Closed h14turkiye closed 7 months ago

h14turkiye commented 7 months ago

Environment details (Put x in the checkbox along with the information)

Exact steps to reproduce the issue

I have nnn 4.8, saw that mpv is on 4.9, just copied the preview-tui file, installed mpv via flatpak made an alias for it "mpv". When I use the plugin only a black screen appears, when I remove the --no-audio, audio plays so the video plays but there is no vision...

Running kitty and using mpv command inside works.

jarun commented 7 months ago

@luukvbaal please have a look.

duong-db commented 7 months ago

@h14turkiye In the terminal, try to open a video inside Kitty and verify if it works:

$ mpv --vo=kitty <your_video_file>

I caught this error:

 (+) Video --vid=1 (*) (h264 1920x1080 29.970fps)
 (+) Audio --aid=1 (*) (aac 2ch 48000Hz)
[vo] Video output kitty not found!
Error opening/initializing the selected video_out (--vo) device.
Video: no video

It seems that there was a problem with the video output (--vo) configuration of mpv. However, by setting --vo=tct, the video played normally but resulted in a very low resolution.

EDIT. I realized that my problem was caused by the old version of mpv package in the Ubuntu repo (0.34 vs 0.37-newest). However, the following solution may suit anyone who want to use timg as the video output backend for kitty instead of mpv.

A possible solution.

Screenshot from 2024-02-21 23 09 59

Download the timg package and replace the line 468 in your preview-tui configuration file with:

timg -p kitty --center "$3" &

Now, the video previewing function in nnn works. (You may need to modify some other small details in the code to make it more consistent)

h14turkiye commented 7 months ago

@h14turkiye In the terminal, try to open a video inside Kitty and verify if it works:

$ mpv --vo=kitty <your_video_file>

I caught this error:

 (+) Video --vid=1 (*) (h264 1920x1080 29.970fps)
 (+) Audio --aid=1 (*) (aac 2ch 48000Hz)
[vo] Video output kitty not found!
Error opening/initializing the selected video_out (--vo) device.
Video: no video

It seems that there was a problem with the video output (--vo) configuration of mpv. However, by setting --vo=tct, the video played normally but resulted in a very low resolution.

EDIT. I realized that my problem was caused by the old version of mpv package in the Ubuntu repo (0.34 vs 0.37-newest). However, the following solution may suit anyone who want to use timg as the video output backend for kitty instead of mpv.

A possible solution.

Screenshot from 2024-02-21 23 09 59

Download the timg package and replace the line 468 in your preview-tui configuration file with:

timg -p kitty --center "$3" &

Now, the video previewing function in nnn works. (You may need to modify some other small details in the code to make it more consistent)

I downloaded flatpak version mpv, which is 0.37 and did work with kitty but not with nnn. timg produced same thing, working with kitty but not with nnn. Both also work within a split window when used in kitty but not with nnn.

I use kitty nnn -deioa to launch nnn

duong-db commented 7 months ago

@h14turkiye How did you get the preview-tui config file? You may have an older version of preview-tui if you follow this installation instruction as reported here. It is recommended to download it manually and make the file executable.

h14turkiye commented 7 months ago

@h14turkiye How did you get the preview-tui config file? You may have an older version of preview-tui if you follow this installation instruction as reported here. It is recommended to download it manually and make the file executable.

Because the file I downloaded via curl did not have preview-video section, I just copy pasted the file from the github.

h14turkiye commented 7 months ago

I just upgraded to 4.9 via here, and ran the installation instruction again. It still doesn't provide the latest version of preview-tui.

duong-db commented 7 months ago

I just upgraded to 4.9 via here, and ran the installation instruction again. It still doesn't provide the latest version of preview-tui.

Does preview-tui work with .gif files in your kitty?

h14turkiye commented 7 months ago

I just upgraded to 4.9 via here, and ran the installation instruction again. It still doesn't provide the latest version of preview-tui.

Does preview-tui work with .gif files in your kitty?

Nope.

duong-db commented 7 months ago

Does preview-tui work with .gif files in your kitty?

Nope.

@h14turkiye Remove mpv and check it again.

If it works, it indicates that mpv was likely causing this issue. By default, icat (kitty) is responsible for previewing .gif files. When having mpv installed, kitty will use mpv to preview both gifs and videos instead.

h14turkiye commented 7 months ago

Does preview-tui work with .gif files in your kitty?

Nope.

@h14turkiye Remove mpv and check it again.

If it works, it indicates that mpv was likely causing this issue. By default, icat (kitty) is responsible for previewing .gif files. When having mpv installed, kitty will use mpv to preview both gifs and videos instead.

After deleting mpv, I checked the gifs and it didn't work. I tried snap(I really prefer flatpak, so I didn't use snap first) and the video and gif worked for me. Flatpak version of mpv is bugged.

N-R-K commented 7 months ago

@luukvbaal Maybe the exists mpv checks should be replaced to actually check if the requested vo exists or not since kitty/sixel are optional and can be complied out. Or the mpv version might be outdated.