Giter Site home page Giter Site logo

Comments (38)

SinDongHwan avatar SinDongHwan commented on July 17, 2024 4

Did you solve the problem?
I solved!!
I will explain from 'convert frames' to 'summary2video' step by step.

step 1. edit 'videos2frames.sh' script in 'SumMe/videos' directory.

  • you edit 'ffmpeg -i "$f" -f image2 frames/"$name"/%5d.png' to
    'ffmpeg -i "$f" -f image2 frames/"$name"/%6d.jpg'
    ( if extract Summe dataset, there is 'SumMe' directory. )

step 2. convert summe dataset to frames.

  • i executed 'videos2frames.sh' in 'SumMe/videos' directory.
    ( you should make each directories about .mp4 as 'SumMe/videos/frames/
    For example, if Air_Force_One.mp4, you should make directory 'SumMe/videos/frames/Air_Force_One' )

step 3. have to map h5.file key and frame dirctory name

  • in my case, i made json file.
    ( For example, {"video_1":"Air_Force_One", "video_2":"...", ... }.
    you can see the information about mapping following code.
import h5py
import sys
h5_file_name = (sys.argv[1])
f = h5py.File(h5_file_name,'r')
for key in f.keys():
    print("{} : {}".format(key, f[key]['video_name'].value))

if you edit properly "summary2video.py", script is performed.

if you need to my help, ask me.^^

from pytorch-vsumm-reinforce.

ShaoDu avatar ShaoDu commented on July 17, 2024 2

from pytorch-vsumm-reinforce.

ShaoDu avatar ShaoDu commented on July 17, 2024 1

from pytorch-vsumm-reinforce.

Swati640 avatar Swati640 commented on July 17, 2024 1

you can generate the frames, the way its feasible for you. I used ffmpeg and "https://github.com/SinDongHwan/pytorch-vsumm-reinforce/blob/master/utils/generate_dataset.py" , for generation of frames and feature extraction on my own dataset. I hope i understood your question properly.

from pytorch-vsumm-reinforce.

PedroJSousa avatar PedroJSousa commented on July 17, 2024 1

I went through this whole comment section, and this is super confusing. This is how I managed to do it, I hope it saved some time.

Note: Make sure you have the correct dataset downloaded, because it is not on github, you can download it here
Note2: In that dataset the videos2frames.sh file is actually named videos2frames.sh~
You have to change the name of the file by running in the terminal:
mv videos2frames.sh~ videos2frames.sh

Step 1: Create a folder called "frames" inside the SumMe/videos folder
Step 2:

  • Install ffmpeg
  • Edit 2 lines in the videos2frames.sh file: Add a new Line before line 10: mkdir frames/"$name". This will create inside the frames folder a folder with the name of each file
  • Edit line 11 to this: ffmpeg -i "$f" -f image2 -vf fps=30 frames/"$name"/%6d.jpg. This will generate the frames and save them into correspondent folder. FPS needs to be set to 30 because the results.h5 file is also at 30 fps.

Step3: Run summary2video.py

  • Check which videos are your test videos. You can see it when you output the results of your training. In my case image below. Note that the videos are numbered. This means e.g. video 25 is the last video in alphabetical order from the dataset: Valparaiso_Downhill
    image
  • Run the function with the inputs:
    -p path of the results file ;
    -d path of where the frames are stored;
    -i is the index of your training videos matrix. So in my case 0 = video 12, 1 = video 25, 2 = video 4 etc
    Choose a video from the 5 test videos and generate the highlight. I chose video 25 and ran

summary2video.py -p log/summe-split0/result.h5 -d datasets/videos/frames/Valparaiso_Downhill -i 1 --fps 30 --save-dir log --save-name summary.mp4

from pytorch-vsumm-reinforce.

SinDongHwan avatar SinDongHwan commented on July 17, 2024

on README,
Visualize summary

You can use summary2video.py to transform the binary machine_summary to real summary video.

You need to have a directory containing video frames.

The code will automatically write summary frames to a video where the frame rate can be controlled. Use the following command to generate a .mp4 video.

maybe, it seems that there aren't frames on "video_frames" directory. but i don't know which frames yet.

Did you solve this problem?

from pytorch-vsumm-reinforce.

ShaoDu avatar ShaoDu commented on July 17, 2024

from pytorch-vsumm-reinforce.

SinDongHwan avatar SinDongHwan commented on July 17, 2024

Did you see this line in summary2video.py?

we have to formate filename as "000001.jpg, 000002.jpg, ..."
and i found about number of video frames.

import h5py
h5_file_name = "datasets/eccv16_dataset_summe_google_pool5.h5"
f = h5py.File(h5_file_name,'r')
print(f['video_1']['n_frames'].value)

i can see "4494".

we can see more information about each h5 files on datasets/readme.txt .

i will try to find fps to convert frames from video correctly.

from pytorch-vsumm-reinforce.

SinDongHwan avatar SinDongHwan commented on July 17, 2024

No, we should save frames in folder.
I told you that read dataset/readme.txt to convert frames from video correctly.
Parameter "summary" of frm2video function consists of [0,1,0,1,0,0,0,...]. this length of list( [0,1,0,1,0,0,0,...] ) is maybe number of frames.

I'm not good at English, so it could be difficult for you to understand about my write.

from pytorch-vsumm-reinforce.

ShaoDu avatar ShaoDu commented on July 17, 2024

from pytorch-vsumm-reinforce.

SinDongHwan avatar SinDongHwan commented on July 17, 2024

if you have dataset video, could you share that? i don't have videos.

from pytorch-vsumm-reinforce.

ShaoDu avatar ShaoDu commented on July 17, 2024

from pytorch-vsumm-reinforce.

SinDongHwan avatar SinDongHwan commented on July 17, 2024

okay. i will try to do summary2video, too. if you can convert, please reply.
if i will be converted, i reply, too.

from pytorch-vsumm-reinforce.

Swati640 avatar Swati640 commented on July 17, 2024

Did you solve the problem?
I solved!!
I will explain from 'convert frames' to 'summary2video' step by step.

step 1. edit 'videos2frames.sh' script in 'SumMe/videos' directory.

* you edit 'ffmpeg -i "$f" -f image2 frames/"$name"/%5d.png' to
  'ffmpeg -i "$f" -f image2 frames/"$name"/%6d.jpg'
  ( if extract Summe dataset, there is 'SumMe' directory. )

step 2. convert summe dataset to frames.

* i executed 'videos2frames.sh' in 'SumMe/videos' directory.
  ( you should make each directories about _.mp4 as 'SumMe/videos/frames/_
  For example, if Air_Force_One.mp4, you should make directory 'SumMe/videos/frames/Air_Force_One' )

step 3. have to map h5.file key and frame dirctory name

* in my case, i made json file.
  ( For example, {"video_1":"Air_Force_One", "video_2":"...", ... }.
  you can see the information about mapping following code.
import h5py
import sys
h5_file_name = (sys.argv[1])
f = h5py.File(h5_file_name,'r')
for key in f.keys():
    print("{} : {}".format(key, f[key]['video_name'].value))

if you edit properly "summary2video.py", script is performed.

if you need to my help, ask me.^^

Hello
i tried to follow the procedure you told above and made the required changes in shell file as well. But, while running a shell file I am getting "Conversion failed error". This is the error "[image2 @ 0x5654ab990a80] Could not open file : SumMe/videos/frames/Valparaiso_Downhill/%6d.jpg
av_interleaved_write_frame(): Input/output error"
frame= 1 fps=0.0 q=8.9 Lsize=N/A time=00:00:00.03 bitrate=N/A speed=1.58x
video:79kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!

Please help!! I am stuck with this conversion process.

from pytorch-vsumm-reinforce.

SinDongHwan avatar SinDongHwan commented on July 17, 2024

@Swati640
Hi, I think can't open file(image).
Did you try to edit shell script?

* you edit 'ffmpeg -i "$f" -f image2 frames/"$name"/%5d.png' to
  'ffmpeg -i "$f" -f image2 frames/"$name"/%6d.jpg'
  ( if extract Summe dataset, there is 'SumMe' directory. )

If you are okay, i can see your shell on Teamviewer?

from pytorch-vsumm-reinforce.

Swati640 avatar Swati640 commented on July 17, 2024

yes, I edited the shell file completely as you told above, but it is not working.

from pytorch-vsumm-reinforce.

SinDongHwan avatar SinDongHwan commented on July 17, 2024

@Swati640
hmm...
If you are okay, could i see your situation on Teamviewer?

from pytorch-vsumm-reinforce.

Swati640 avatar Swati640 commented on July 17, 2024

Hey.. Thanks for the help. It worked for me. Had to do some changes in the shell file :)

from pytorch-vsumm-reinforce.

Harryjun avatar Harryjun commented on July 17, 2024

Hi, @Swati640
FFMPEG generate frames slowly,Can I take video source as input directly,and generate video summary

from pytorch-vsumm-reinforce.

Harryjun avatar Harryjun commented on July 17, 2024

Hi, @SinDongHwan
FFMPEG generate frames slowly,Can I take video source as input directly,and generate video summary

from pytorch-vsumm-reinforce.

SinDongHwan avatar SinDongHwan commented on July 17, 2024

@Harryjun
Thank you for kindly answer, instead of me^^

from pytorch-vsumm-reinforce.

ghagareomkar avatar ghagareomkar commented on July 17, 2024

@SinDongHwan I created a folder named video_frames which contains folder :Air_Force_One,Base_jumping.... and others containing video frames. But still i am getting the same error.Anyone who can help me out. ThankYou

from pytorch-vsumm-reinforce.

SinDongHwan avatar SinDongHwan commented on July 17, 2024

@ghagareomkar
HI, Could you tell me a error message?

from pytorch-vsumm-reinforce.

ghagareomkar avatar ghagareomkar commented on July 17, 2024

@SinDongHwan Thank You for your reply
python summary2video.py -p log/summe-split0/result.h5 -d video_frames/ -i 0 --fps 30 --save-dir log --save-name summary.mp4
this occured:
OpenCV: FFMPEG: tag 0x5634504d/'MP4V' is not supported with codec id 12 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
Traceback (most recent call last):
File "summary2video.py", line 43, in
frm2video(args.frm_dir, summary, vid_writer)
File "summary2video.py", line 27, in frm2video
frm = cv2.resize(frm, (args.width, args.height))
cv2.error: OpenCV(3.4.3) /io/opencv/modules/imgproc/src/resize.cpp:4044: error: (-215:Assertion failed) !ssize.empty() in function 'resize'

This above error i was getting when created a folder named video_frames which contains folder :Air_Force_One,Base_jumping.... and others containing video frames.
But when i put just the frames of only one video in video_frames folder .got no error, working properly got summary for the corresponding video .Is my approach correct? ThankYou

from pytorch-vsumm-reinforce.

SinDongHwan avatar SinDongHwan commented on July 17, 2024

@ghagareomkar
please check data of frm before cv2.resize()
print(frm)

from pytorch-vsumm-reinforce.

ghagareomkar avatar ghagareomkar commented on July 17, 2024

@SinDongHwan ThankYou ,will try this

from pytorch-vsumm-reinforce.

sky-16 avatar sky-16 commented on July 17, 2024

I went through this whole comment section, and this is super confusing. This is how I managed to do it, I hope it saved some time.

Note: Make sure you have the correct dataset downloaded, because it is not on github, you can download it here
Note2: In that dataset the videos2frames.sh file is actually named videos2frames.sh~
You have to change the name of the file by running in the terminal:
mv videos2frames.sh~ videos2frames.sh

Step 1: Create a folder called "frames" inside the SumMe/videos folder
Step 2:

  • Install ffmpeg
  • Edit 2 lines in the videos2frames.sh file: Add a new Line before line 10: mkdir frames/"$name". This will create inside the frames folder a folder with the name of each file
  • Edit line 11 to this: ffmpeg -i "$f" -f image2 -vf fps=30 frames/"$name"/%6d.jpg. This will generate the frames and save them into correspondent folder. FPS needs to be set to 30 because the results.h5 file is also at 30 fps.

Step3: Run summary2video.py

  • Check which videos are your test videos. You can see it when you output the results of your training. In my case image below. Note that the videos are numbered. This means e.g. video 25 is the last video in alphabetical order from the dataset: Valparaiso_Downhill
    image
  • Run the function with the inputs:
    -p path of the results file ;
    -d path of where the frames are stored;
    -i is the index of your training videos matrix. So in my case 0 = video 12, 1 = video 25, 2 = video 4 etc
    Choose a video from the 5 test videos and generate the highlight. I chose video 25 and ran

summary2video.py -p log/summe-split0/result.h5 -d datasets/videos/frames/Valparaiso_Downhill -i 1 --fps 30 --save-dir log --save-name summary.mp4

I was currently using a dataset of 165 MB mentioned in #40. I was getting error in that dataset during generating summary2video.py and I found out I need to use original Summe dataset of 2.2 GB. Can anyone guide me how to start from beginning.
Thanks

from pytorch-vsumm-reinforce.

SinDongHwan avatar SinDongHwan commented on July 17, 2024

Hi, @sky-16.
If you can run teamviewer, send to me email.
i will run a code.

from pytorch-vsumm-reinforce.

wangsen-sen avatar wangsen-sen commented on July 17, 2024

I want to ask, is it necessary to extract all the video frames in the dataset to make a frame dictionary? Or just a few of them? Is it OK to name them in order?

from pytorch-vsumm-reinforce.

wangsen-sen avatar wangsen-sen commented on July 17, 2024

Did you solve the problem?
I solved!!
I will explain from 'convert frames' to 'summary2video' step by step.

step 1. edit 'videos2frames.sh' script in 'SumMe/videos' directory.

  • you edit 'ffmpeg -i "$f" -f image2 frames/"$name"/%5d.png' to
    'ffmpeg -i "$f" -f image2 frames/"$name"/%6d.jpg'
    ( if extract Summe dataset, there is 'SumMe' directory. )

step 2. convert summe dataset to frames.

  • i executed 'videos2frames.sh' in 'SumMe/videos' directory.
    ( you should make each directories about .mp4 as 'SumMe/videos/frames/
    For example, if Air_Force_One.mp4, you should make directory 'SumMe/videos/frames/Air_Force_One' )

step 3. have to map h5.file key and frame dirctory name

  • in my case, i made json file.
    ( For example, {"video_1":"Air_Force_One", "video_2":"...", ... }.
    you can see the information about mapping following code.
import h5py
import sys
h5_file_name = (sys.argv[1])
f = h5py.File(h5_file_name,'r')
for key in f.keys():
    print("{} : {}".format(key, f[key]['video_name'].value))

if you edit properly "summary2video.py", script is performed.

if you need to my help, ask me.^^

excuse me,I want to ask, when I execute 'videos2frames. sh'.
'Processing ./Air_Force_One.webm file...
./Air_Force_One.webm
bash: ffmpeg: command not found' What should I do?

from pytorch-vsumm-reinforce.

SinDongHwan avatar SinDongHwan commented on July 17, 2024

Hi, @wangsen-sen.
Install ffmpeg.
ex) if your OS is ubuntu, "sudo apt-get install ffmpeg".

from pytorch-vsumm-reinforce.

wangsen-sen avatar wangsen-sen commented on July 17, 2024

from pytorch-vsumm-reinforce.

wangsen-sen avatar wangsen-sen commented on July 17, 2024

Hi, @wangsen-sen.
Install ffmpeg.
ex) if your OS is ubuntu, "sudo apt-get install ffmpeg".

Thank you very much for your reply. This problem has just been solved. If you have any questions, I'll ask you again.Good luck to you.

from pytorch-vsumm-reinforce.

wangsen-sen avatar wangsen-sen commented on July 17, 2024

Hi, @wangsen-sen.
Install ffmpeg.
ex) if your OS is ubuntu, "sudo apt-get install ffmpeg".

Hello, excuse me again. I want to ask if the final video summary can be obtained through the file, which frame is included in the original video?

from pytorch-vsumm-reinforce.

SinDongHwan avatar SinDongHwan commented on July 17, 2024

Hi, @wangsen-sen.

you can check which frames is selected in result.h5 file.
selected frames are assigned '1', not selected frames are assigned '0'.

from pytorch-vsumm-reinforce.

wangsen-sen avatar wangsen-sen commented on July 17, 2024

Hi, @wangsen-sen.

you can check which frames is selected in result.h5 file.
selected frames are assigned '1', not selected frames are assigned '0'.

Hello,I processed the result.h5 file and got the final videos tested, but I want to know which frame of the video summary is composed of. Where should I look?

from pytorch-vsumm-reinforce.

SinDongHwan avatar SinDongHwan commented on July 17, 2024

Hi, @wangsen-sen.

you can check selected frames using following code.

summary = h5_res[key]['machine_summary'][...]

from pytorch-vsumm-reinforce.

wangsen-sen avatar wangsen-sen commented on July 17, 2024

from pytorch-vsumm-reinforce.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.