a thoughtful web.
Good ideas and conversation. No ads, no tracking.   Login or Take a Tour!
comment by am_Unition
am_Unition  ·  1551 days ago  ·  link  ·    ·  parent  ·  post: Why is my bash loop not working?

Not sure this will help much, but when I first generate the files (ImageMagick) that I later want to combine into a video, I append on a suffix: filename"_0000".png, filename"_0001".png, etc., and then when I call ffmpeg, I don't feed it a list, I just turn it loose in the subdirectory containing the files with:

ffmpeg -r 30 current_directory/filename_%4d.png -vcodec libx264 -pix_fmt yuv420p

Maybe your script isn't ingesting mylist.txt correctly, and getting hosed up? Using a new naming convention, with "$4d" instead of feeding it a .txt list, should test that.

Note: "filename" is just one string, never changing, for all files.

I would say I'm something of a "just bangin' two rocks together" type of programmer, fair warning.





Cumol  ·  1551 days ago  ·  link  ·  
This comment has been deleted.
Cumol  ·  1551 days ago  ·  link  ·  

My files are created by a program I cannot edit so I am bound to that. They are in numeric order, however, they are msCam1.avi, msCam2.avi,... msCam15.avi

I am using the -v in the first script to get the natural sorting of the files so they are in the correct order and then passing it to ffmpeg

Any suggestion how I could achieve the same without going through the first loop?

am_Unition  ·  1551 days ago  ·  link  ·  

I'm pretty sure the sorting is doing msCam1.avi, then msCam10.avi, msCam11.avi, all the way up to msCam19, before it makes it to msCam2. I just checked, and that's how my "ls -v" command sorts things.

Not sure about the rest, but that's probably gotta get fixed first. I deal with shit like this all of the time, but not in a command shell (bash). I primarily use IDL, Matlab, and Python, so I'm not terribly helpful here. Apologies!

Also, I suspect you're working on distilling security cam footage, a cam which is triggered by a motion sensor apparently at least 15 times per day. Did I win?

Cumol  ·  1550 days ago  ·  link  ·  

    Also, I suspect you're working on distilling security cam footage, a cam which is triggered by a motion sensor apparently at least 15 times per day. Did I win?

Nope. :D

It is actually some small program that accesses a webcam and saves a video after 1000 frames. They are videos of mouse behavior in a kind of place preference test that is modified to test the preference of the animals to temperature.

I wanted to switch to something easier (like micromanager) but because I started all my analysis with that (and trained a neural net to do the analysis for me using these outputs) I am just sticking with it until the project is finished.

I was thinking of using python instead as I know I could just use the natsort package to do the sorting and there is probably some python wrapper for ffmpeg like this one.

am_Unition  ·  1550 days ago  ·  link  ·  

Nice. Mice.

Yep, you could just make a wrapper script in whatever language you're comfortable renaming and/or handling everything, and pass strings to a terminal for running ffmpeg, but then bfv might kill both of us.

Up to you :/.

Edit: hahhaha I wrote this before I saw that he solved it :). OK bfv, now I know who to bother when my attempts at parallelizing processes for GPU architectures go up in possibly actual flames

user-inactivated  ·  1550 days ago  ·  link  ·  

If you really want to freak out your coworkers, put a bag of popcorn on top of the GPU.