openvolley / ovva

An R Shiny app for volleyball video analysis
https://ovva.openvolley.org
Other
6 stars 0 forks source link

Create_clip_button_ui seems to not be working #3

Closed Niels-c-Scholten closed 1 month ago

Niels-c-Scholten commented 1 year ago

Hi. first of all, all the resources of openvolley are amazing. Thank you so much.

For me, the button for downloading the clip of a playlist is not working. I am using local files for my video sources, and I have a playlist that consists of multiple plays. I am using the Lighttpd video server. All files in my season directory have local video sources.

The code that is responsible for showing the button is from shiny_server.R

output$create_clip_button_ui <- renderUI({
            ok <- !is.null(playlist()) && nrow(playlist()) > 0 && !video_player_type() %in% c("youtube", "twitch")
            ## also check that videos are not remote
            ok <- ok && !any(grepl("^https?://", playlist()$video_src, ignore.case = TRUE))
            if (ok) {
                actionButton("create_clip_button", "Download clip")
            } else {
                NULL
            }
        })

All these conditions should be met, but the button does not appear.

I cannot print any of them as I can only read the package files, and not edit them.

This issue happens both for Chrome and Edge browsers.

raymondben commented 1 year ago

Hi @Niels-c-Scholten thanks for the feedback and spotting the bug. It should be fixed in v0.12.3 (https://github.com/openvolley/ovva/commit/cc4f5f2bda8180646dbcd806ae45cd3ad7618c64), please reinstall and let us know how it goes.

Bear in mind though that this conversion is fairly rudimentary. It'll look for a system-installed ffmpeg and use that to generate a standalone mp4 version of the current playlist. Even though it uses parallel processing it's likely to be slow for a big conversion job and I don't think you can stop it once it starts. A better option would be to integrate our editry package, which takes of installing the system dependencies as well as producing much nicer videos (with e.g. subtitles and transitions between clips). But that is some time off, haven't gotten there yet ...

Niels-c-Scholten commented 1 year ago

Thank you very much for the fast response @raymondben. The button is now appearing on screen, however it is not working. after a few seconds, it prompt "Sorry, something went wrong. The error message was: Executing 'ffmpeg' failed with status -2".

I am using a freshly installed version of ffmpeg (ffmpeg-git-full.7z from here) which seem to be working (I was able to concatenate two videos using ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output.mp4)

During startup of the server, I am getting 2 warnings shown below:

Warning: There were 2 warnings in `mutate()`.
The first warning was:
ℹ In argument: `game_date = min(as.Date(.data$time), na.rm = TRUE)`.
ℹ In group 1: `match_id = "b7afd39c816cb9cbb6576c78e9e6ac67|b1142e791d9c40f4a46dc08aae68ef19"`.
Caused by warning in `min.default()`:
! no non-missing arguments to min; returning Inf

Maybe this can be related? The file was created using ovscout2

I tried testing the command given by the server on line 1009 of shiny_server.R

res <- sys::exec_internal("ffmpeg", c("-ss", plitem$start_time, "-i", infile, "-strict", "-2", "-t", plitem$duration, outfile))

Performing this in a command prompt with a test file worked fine

ffmpeg -ss 20 -i "input.mp4" -strict -2 -t 8 "output.mp4"

This resulted in an 8s clip without sound.

Would you know what could be the cause?

raymondben commented 1 year ago

The warning about the match date doesn't matter, but if you want to avoid it you can add a date to the match file via "Edit match data" button in ovscout2. (I'll also fix the code to avoid the warning since it isn't very helpful.)

For the ffmpeg - not sure, things work for me on my (Linux) machine, I'll investigate on Windows when I get a chance. Possibly ffmpeg isn't on the system path and ovva can't find it. Or possibly something else with file paths.

But I am wondering if this is better done by saving the playlist and converting it separately anyway. That gives more control over it. In any case this might be a reasonable workaround for the time being. Two options - first save the playlist to csv using the 'Download playlist CSV' file, then:

## reinstall ovideo if you don't have the latest version v0.20.1, I updated it yesterday
library(ovideo)
p <- read.csv("~/Downloads/playlist.csv")
## we need the locations of local video files directly, not through the web server that ovva was using
p$video_src <- p$file
## now convert using ffmpeg
ov_playlist_to_video(p, "playlist.mp4", seamless = TRUE) ## add debug = TRUE if it doesn't work

or via editry, see https://github.com/scienceuntangled/editry

library(editry)
## see help("ov_editry_clips") for more examples
clips <- ovideo::ov_editry_clips(p, label_col = "subtitleskill", seamless = TRUE)
my_spec <- er_spec(out_path = "playlist.mp4", clips = clips)
er_exec_wait(spec = my_spec, fast = TRUE) ## fast = TRUE gives low-quality preview

Maybe worth thinking about a Shiny app specifically around this, but I am a bit wary of investing effort into reinventing video editing tools that will never be as good as already-available software.

Niels-c-Scholten commented 12 months ago

This solution (I've used the ovideo one) is working great. Thank you.

I think the problem is that ovva and ovscout2 (and maybe the ffmpeg application) have different definitions for the home directory ~. the DVW files as downloaded from ovscout2 were not working with ovva. It appears that ovva and ovscout are working with different definitions for the home directory of my system. Ovscout2 saves the video file path in the DVW files with ~ refering to my Documents folder.

Camera0=~/Matches/filename.mp4

While ovva only works when I modify the DVW files as if my Users folder is my home directory ~.

Camera0=~/Niels/Documents/Matches/filename.mp4 

Maybe the ffmpeg function is using the documents folder as home directory, thus explaining the -2 error code.

There's no need to fix this quickly, the method you described above is great. But I figured you would like to know. Again thank you for this amazing software.

raymondben commented 11 months ago

To do: change https://github.com/openvolley/ovva/blob/master/R/shiny_server.R#L1001 to use ovideo::ov_ffmpeg_exe() and associated functions

raymondben commented 1 month ago

Finally got around to using ovideo::ov_ffmpeg_exe() instead of relying purely on system-installed ffmpeg