openworm/OpenWorm

Corrupted movie files

Closed this issue · 51 comments

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

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.

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

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)

@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.

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

How can I fix it then?

lungd commented

@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 openworm/sibernetic#154.
I think I was able to fix that one, but I wanted to get some feedback from the authors of Sibernetic.

Thanks!

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

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

lungd commented

@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

Thanks so much. You're a lifesaver

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.

This is because I get:

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

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

It stil says:

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

before that though.

But I didn't get the ffmpeg error.

@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.

@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.

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

@ThatMelon Thanks! Link to the relevant branch?

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

@slarson Is there any progress?

lungd commented

@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.

Thanks! I shall try this now.

Unfortunately, I get:

manifest for openworm/openworm:0.9 not found

The tag is not on docker hub.

lungd commented

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

Ahh. I'm obviously not good at this.

I still get the output file is empty error.

lungd commented

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

Sure!

I'll send you a link soon.

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

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.

@lungd. It passes the 512KB limit.

On pastebin.

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

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

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

@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
------------------------------------
====
...

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

lungd commented

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

lungd commented

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

@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

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

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

@lungd the output of the cpuinfo command is:

sse
sse2
sse3
sse4_1
sse4_2
sse4a
sse

lungd commented

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

lungd commented

@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?

@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)?

lungd commented

@pgleeson thank you for testing.

There is a new issue now describing a problem when running a Linux VM inside a Windows host.
I think I can close this issue, because the original issue seems to be solved.