aharmer / pathtrackr

An R package for video tracking and analysing animal movement
29 stars 8 forks source link

Issue with splitvideo #21

Open tombees2807 opened 5 years ago

tombees2807 commented 5 years ago

I have just started using the package and have come across the below issue when attempting to run: splitvideo().

Error: unexpected input in "splitVideo(C:\"

Here is the code I ran: splitVideo(C:\Users\thoma\Desktop\Video-analysis\using-trackr, fps = 60, xpix = 1920 , ypix = 1080)

aharmer commented 5 years ago

Two things: This message is because you haven't put quotation marks around the path names. Also, you have written the path name using windows format (with back-slashes), you need to change to forward-slashes.

aharmer commented 5 years ago

You also need to specify the video filename with extension.

tombees2807 commented 5 years ago

Thanks for the swift response. Following your corrections the code now runs. However, when it runs all is produced is a folder with the name of the mp4 file I am trying to split. Any suggestions would be greatly appreciated.

aharmer commented 5 years ago

Hi, can you please include the code you ran?

tombees2807 commented 4 years ago

My apologies, here is the code I ran:

splitVideo(filepath = "C:/Users/thl18nrz/OneDrive - Bangor University/Laptop/Documents/Biology/PhD/Rothamsted/Summer-twentynineteen-experiment/June-July-/Video-files/20th-Aug-2019/First-round-bee-video/Barry B/T8(2).mp4", fps = 60, xpix = 1920 , ypix = 1080)

aharmer commented 4 years ago

Does the folder produced actually contain the split video files (a series of jpegs), or is the folder empty?

tombees2807 commented 4 years ago

The folder is empty.

aharmer commented 4 years ago

Are you able to send me the video file? I will attempt to see what the problem is.

alapsansky commented 4 years ago

I am having the same issue. The function splitVideo creates a new folder, but it is empty. I have the folder containing the video set as my working directory, so the code is just:

splitVideo(filepath='GH016188.MP4', fps=30, xpix=1980, ypix=1080)

The output from RStudio is: [1]127

alapsansky commented 4 years ago

Outside of R (in the command prompt), I am able to use FFmpeg to extract frames from the same video. Just not using the splitVideo command.

aharmer commented 4 years ago

Do you mind checking the dimensions of your original video file? There is a potential issue that I have seen once where the video wont split if the pixel height is not divisible by 2. Also, feel free to send me your video file.

alapsansky commented 4 years ago

The dimensions are 1980 X 1080.

It seems that the issue might be the length of my video. It's 8 minutes long and recorded at 60 fps. When I test the splitVideo function on a 20-second chunk of the video, it works great!

Is there any way to work around this?

aharmer commented 4 years ago

Hi, I'm really not sure what the problem is there as all splitVideo is doing is making a system call to ffmpeg. If you can successfully split the video from the terminal, then I suggest you do it this way and then just direct the trackPath function to the directory of your split files.

Karinadesa commented 4 years ago

Hello, I'm having a problem with the splitvideo function. when I run the code, the following error appears: Error in splitVideo("C: Users karina Sá Desktop trabalhos padrão de movimento e class test.mp4", : No video file was found... check that the file path to your video is correct. I already checked if the video is in that folder and the answer is yes, I also checked if ffmpeg is properly installed and the answer is also yes. Can you help me? my code is: splitVideo("C:\ Users\ karina Sá\ Desktop\ trabalhos\ padrão de movimento e class\ test.mp4", fps=25, xpix=1366, ypix=768)

dbthomas commented 4 years ago

Looks like the path name has been written using windows format (with back-slashes). Try using forward-slashes, e.g. splitVideo("C:/ Users/karina Sá/Desktop/trabalhos/padrão de movimento e class/test.mp4", fps=25, xpix=1366, ypix=768)

Karinadesa commented 4 years ago

I tried, but I was unsuccessful :'(

Karinadesa commented 4 years ago

I will try using another video

dbthomas commented 4 years ago

OK, please let us know how you get on with the other video.

Karinadesa commented 4 years ago

got it. Now, it generates a folder with the file name, but it is empty

dbthomas commented 4 years ago

Can you provide more detail about the video you are using (duration, format, etc.), the code you are using (e.g. splitVideo("C:/ Users/karina Sá/Desktop/trabalhos/padrão de movimento e class/test.mp4", fps=25, xpix=1366, ypix=768)), and any error messages you receiving from R?

Karinadesa commented 4 years ago

I'm using the same video, but now the R is no longer showing errors. When I use the splitVideo function, it generates a folder (where the jpegs should be) but it is empty. The code I'm using: splitVideo("C:/Users/karina Sá/Desktop/trabalhos/padrão de movimento e class/padrao de mov/test.mp4", fps=25, xpix=1366, ypix=768)

the video is in mp4 format, is 8 seconds long and 25 frames per second. size: 1366 x 768

dbthomas commented 4 years ago

I am not sure why splitVideo is not working. The best I can offer is for you to send me your video so that I can test it myself (d.b.thomas@massey.ac.nz).

dbthomas commented 4 years ago

I can repeat the error of producing an empty folder that doesn't contain any split frames, but only when I have white space in the directory name or file name. For example, when I run the following line I get an empty folder:

splitVideo("D:/Projects/Aaron spider/test_Trim.mp4", fps = 10, xpix = 320, ypix = -1)

However, when I replace the white space between the words Aaron and spider with an underscore I get a folder that is filled with split frames: splitVideo("D:/Projects/Aaron_spider/test_Trim.mp4", fps = 10, xpix = 320, ypix = -1)

Perhaps try removing white spaces as a potential solution.

Karinadesa commented 4 years ago

thanks for the return, i will try that!

Karina Santos Guedes de Sá Fisioterapeuta (CREFITO- 281216F) Aluna de pós-graduação em Ciência do Movimento Humano (PPCMH)


De: dbthomas notifications@github.com Enviado: terça-feira, 18 de agosto de 2020 20:26 Para: aharmer/pathtrackr pathtrackr@noreply.github.com Cc: Karinadesa karina-sa@outlook.com; Comment comment@noreply.github.com Assunto: Re: [aharmer/pathtrackr] Issue with splitvideo (#21)

I can repeat the error of producing an empty folder that doesn't contain any split frames, but only when I have white space in the directory name or file name. For example, when I run the following line I get an empty folder:

splitVideo("D:/Projects/Aaron spider/test_Trim.mp4", fps = 10, xpix = 320, ypix = -1)

However, when I replace the white space between the words Aaron and spider with an underscore I get a folder that is filled with split frames: splitVideo("D:/Projects/Aaron_spider/test_Trim.mp4", fps = 10, xpix = 320, ypix = -1)

Perhaps try removing white spaces as a potential solution.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/aharmer/pathtrackr/issues/21#issuecomment-675750449, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AQDBFMYAEAQBO3QOMKU2KLLSBL5Z5ANCNFSM4JG4S2PA.

rupertoverall commented 3 years ago

I have encountered the same issue and it is due to special characters in the filename - not the video file itself. Whitespace and characters such as "-" or "\" will cause the external ffmpeg command to run using a non-existent file (it seems to be happy about this and reports no error). This will create the output folder but clearly not fill it with anything! A fix is to wrap the fileames in quotes (in the splitVideo function code). I will test and submit a suggested fix soon...

LaurieAgro commented 3 years ago

Hi, Thanks a lot for your work! I have the same issue with an empty folder resulting from the spliVideo function. Here is my code: splitVideo("C:/Users/MAGNIN/Documents/Agroscope/Test_video/chap_colza_1.AVI", fps = 1, xpix = 1280, ypix = 720) [1] 127 The video pix have even numbers and I don't have special characters in the filname or in the path... Do you have updates for this issues ?