openworm / OpenWorm

Repository for the main Dockerfile with the OpenWorm software stack and project-wide issues
http://openworm.org
MIT License
2.57k stars 204 forks source link

Corrupted movie files #280

Closed gsarma closed 5 years ago

gsarma commented 6 years ago

Expected behavior mp4 files with output of body movement simulation

Actual behavior Files are generated, but they appear to be corrupted. Error message: "The file may be damaged or may not be a movie file that is compatible with QuickTime Player."

Steps to reproduce the behavior Machine Info: MacBook Pro 2014 OS X 10.11.16 Python 2.7.11 w/ Anaconda Docker Version 18.03.0-ce-mac60 (23751) Xquartz 2.7.10beta2 OpenWorm Docker image from 4/23/2018

ThatRedMelon commented 5 years ago

I know the cause of this, but not the solution. The error comes from the fail of the 'ffmpeg' command. Normally, running this command would work, but the command is being used in a 'check_output' command which does not allow whitespacing.

ThatRedMelon commented 5 years ago

And I have managed to fix it, although now I get the error pgleeson referenced 11 days ago which is #291.

ThatRedMelon commented 5 years ago

Sorry, if you would like a fix for this (and see if a fix for #291 comes out soon) you need to change line 204-205 from:

command = "ffmpeg -i %s/%s -vf blackdetect=d=0:pic_th=0.70:pix_th=0.10 -an -f null - 2>&1 | grep blackdetect" % (new_sim_out, sibernetic_movie_name) outstr = check_output(command, shell=True to:

outstr = check_output(["ffmpeg", "-i", "%s/%s", "-vf", "blackdetect=d=0:pic_th=0.70:pix_th=0.10", "-an", "-f", "null", "-", "2>&1", "|", "grep", "blackdetect", "%", "(new_sim_out, sibernetic_movie_name)"], shell=True)

mwatts15 commented 5 years ago

@ThatMelon You have changed the meaning of the command with your change -- there is a string format that you have removed and added the string format syntax to the ffmpeg command line.

ThatRedMelon commented 5 years ago

Yeah, I thought something like this would happen. I did say on #291 that I definitely fixed it badly.

ThatRedMelon commented 5 years ago

How can I fix it then?

lungd commented 5 years ago

@ThatMelon you are right, the damaged file issue is related to ffmpeg. If you open a video while ffmpeg is running, you will get such an error.

I am pretty sure that @gsarma faced this issue because Sibernetic crashed (thus, the master_openworm script crahsed before it could stop the running ffmpeg) and not because there is an issue with the ffmpeg command. To change/fix this behavior we should add some error handling / cleanup code (kill ffmpeg).

The crash of Sibernetic, however, is related to another issue as described in https://github.com/openworm/sibernetic/issues/154. I think I was able to fix that one, but I wanted to get some feedback from the authors of Sibernetic.

ThatRedMelon commented 5 years ago

Thanks!

ThatRedMelon commented 5 years ago

But where is the owHelper.cpp in openworm instead of sibernetic?

ThatRedMelon commented 5 years ago

Sorry, I should have tagged you @lungd. How would I go about doing the above?

lungd commented 5 years ago

@ThatMelon you could try the following:

checkout development branch, rebuild the container, and enter the container without running the master_openworm script

OpenWorm$ git checkout development
OpenWorm$ ./build.sh
OpenWorm$ ./run-shell-only.sh

modify owHelper from inside the container:

ow@8b93ae070316:~$ cd sibernetic
ow@8b93ae070316:~/sibernetic$ nano src/owHelper.cpp

change line 656 // membranesFile >> m_count; to membranesFile >> m_count; and save it

rebuild Sibernetic and run master_openworm.py

ow@8b93ae070316:~/sibernetic$ make clean && make all
ow@8b93ae070316:~/sibernetic$ cd ..
ow@8b93ae070316:~$ python master_openworm.py
ThatRedMelon commented 5 years ago

Thanks so much. You're a lifesaver

ThatRedMelon commented 5 years ago

Sorry @lungd, I feel like I'm bothering you so much, unfortunately I still get "ffmpeg returned non-zero exit status 1" from the black screen detect on master_openworm.py.

ThatRedMelon commented 5 years ago

This is because I get:

could not find simulation output file "/home/ow/sibernetic/NeuroML2/results/c302_C2_FW.dat"

ThatRedMelon commented 5 years ago

Right, I'm confused. I ran it again and got 'output file is empty. Nothing was encoded.'

ThatRedMelon commented 5 years ago

It stil says:

could not find simulation output file "/home/ow/sibernetic/NeuroML2/results/c302_C2_FW.dat"

before that though.

ThatRedMelon commented 5 years ago

But I didn't get the ffmpeg error.

slarson commented 5 years ago

@ThatMelon Best thing would be if you can commit your version as a fork to your own repo and share on the issue so others can try what you've done. There's virtually no way to answer your question without your version of the running code loaded locally.

ThatRedMelon commented 5 years ago

@slarson. I have created a fork and uploaded my files to it. Here is my setup:

1: Ran on Ubuntu virtual machine from Windows 10. 2: Used virtualbox. 3: 4096 MB of RAM. 4: 100GB of storage.

ThatRedMelon commented 5 years ago

Also, I had to complete the steps @lungd provided so I didn't get an FFmpeg error due to sibernetic crashing.

slarson commented 5 years ago

@ThatMelon Thanks! Link to the relevant branch?

ThatRedMelon commented 5 years ago

@slarson Sorry I forgot to link it to you. Here it is: https://github.com/ThatMelon/OpenWorm/tree/master

ThatRedMelon commented 5 years ago

@slarson Is there any progress?

lungd commented 5 years ago

@ThatMelon sorry for the delay. I pushed the fix I mentioned above (and some other mostly minor modifications) to my own repo: https://github.com/lungd/OpenWorm/tree/development I tested the container and it worked on my system.

Your issue could also be related to the setup of your system. I think the simulation needs to allocate more than 4GB, thus, a system with only 4GB of RAM and without swap space could also explain such a behavior.

ThatRedMelon commented 5 years ago

Thanks! I shall try this now.

ThatRedMelon commented 5 years ago

Unfortunately, I get:

manifest for openworm/openworm:0.9 not found

ThatRedMelon commented 5 years ago

The tag is not on docker hub.

lungd commented 5 years ago

I think you forgot to run ./build.sh.

BTW, I only tested my repo with ./run-shell-only.sh and then calling python master_openworm.py

ThatRedMelon commented 5 years ago

Ahh. I'm obviously not good at this.

ThatRedMelon commented 5 years ago

I still get the output file is empty error.

lungd commented 5 years ago

Can you please share the entire output of the master_openworm script? (www.pastebin.com)

ThatRedMelon commented 5 years ago

Sure!

ThatRedMelon commented 5 years ago

I'll send you a link soon.

ThatRedMelon commented 5 years ago

Sorry it's taking so long, I'm having to rebuild it due to me messing up my VM hard drive. I'll have a link in around 10 minutes.

lungd commented 5 years ago

You could also monitor memory usage with, e.g., htop (mby you need to install it first) of your VM. Start htop inside a new terminal and check whether your VM runs out of memory (incl swap if available) during the simulation.

ThatRedMelon commented 5 years ago

@lungd. It passes the 512KB limit.

ThatRedMelon commented 5 years ago

On pastebin.

ThatRedMelon commented 5 years ago

I have found an alternative. Here you go @lungd!

https://www.pastefs.com/pid/98591

ThatRedMelon commented 5 years ago

I also have upped the RAM on the VM to 8GB and added 100GB to my virtual hard drive but I still receive the issue.

lungd commented 5 years ago

@ThatMelon now I think that there is a problem with OpenCL. Does your system have an AMD CPU installed?

Try to run Sibernetic without graphical output from inside the docker container.

./run-shell-only.sh
cd sibernetic
./Release/Sibernetic -f worm_crawl_half_resolution device=CPU timelimit=0.0005 -no_g

If Sibernetic works it prints something like that:

...
[[ Step 0 (total steps: 50, t in sim: 0s) ]]
_runHashParticles:      0.610 ms
_runSort:           6.395 ms
_runSortPostPass:       5.869 ms
_runIndexx:             0.398 ms
_runIndexPostPass:      0.415 ms
_runFindNeighbors:     10.041 ms
_runPCISPH:            72.458 ms    3 iteration(s)
membraneHandling:       1.004 ms
_readBuffer:            1.293 ms
------------------------------------
_Total_step_time:      98.484 ms
------------------------------------
====
...
ThatRedMelon commented 5 years ago

@larson how can I install an AMD CPU on my VM?

lungd commented 5 years ago

I wanted to know the vendor/brand of your CPU. Is it an Intel or AMD CPU?

lungd commented 5 years ago

@ThatMelon please post the output of grep flags /proc/cpuinfo | uniq | grep -oP 'sse([^\s]+)*'

larson commented 5 years ago

@ThatMelon I got tagged in this in "how can I install an AMD CPU on my VM" but I think you meant @slarson .

lungd commented 5 years ago

@larson you are right. Seems to be a typo.

ThatRedMelon commented 5 years ago

Sorry yes. I was wrong. I meant to type lungd then accidently thought in my head slarson and then wrote larson by mistake. Sorry!

ThatRedMelon commented 5 years ago

@lungd the output of the cpuinfo command is:

sse sse2 sse3 sse4_1 sse4_2 sse4a sse

lungd commented 5 years ago

@ThatMelon Intel or AMD CPU? output of lscpu | grep Vendor ?

lungd commented 5 years ago

@ThatMelon OpenWorm uses Slack for daily communication. Please fill out the form to get an invitation.

We can further discuss your issue on slack. Because your issue seems to be unrelated to the original issue, we could open a new issue, unless we find a solution.

@gsarma could you please try out the new docker container from https://github.com/lungd/OpenWorm/tree/development and tell me if it works?

pgleeson commented 5 years ago

@lungd I've managed to run the Docker container in your development branch and it generated the movies fine.

Do you want to open some of your sibernetic PRs on my https://github.com/pgleeson/sibernetic/tree/development branch and I'll test them, as there's already a PR open for this to the main sibernetic repo (though you don't seem to have all the changes from that on your branches)?