Create video from list of images using ruby on rails - ruby-on-rails

Hi I want to create a video from list of images on ruby on rails. I have searched alot and all i found out was ffmeg, but i guess that's a command line tool. How do i create it using pure ruby on rails. Is there any gem or tutorial. Please Help.

Thanks to LordNeckbeard, i found this single command to convert images into video here ffmpeg
.
ffmpeg -framerate 1/3 -pattern_type glob -i '*.jpg' -c:v libx264 out.mp4

there are some gems that work as an interface between ruby and ffmpeg like https://github.com/streamio/streamio-ffmpeg.
There are some other few, try them out!

You can access command line through RoR.
result = %x[some command line call here]
What you would have to do is be sure you have the names path to your end result and confirm the return code from the command line call.

It seems like i will have to use commandline tool as i did'nt find any gem that does all this stuff for me.
install image magick
install ffmpeg
first convert all the jpg images into a gif file
convert -delay 250 -dispose Background *.jpg images.gif
then convert that gif file into mp4 format
ffmpeg -f gif -i images.gif outfile.mp4
I would love to have a better answer than this.

Related

How to create a gif from an image sequence without dither with FFMPEG?

I'm able to create a gif from the image sequence, but I'm struggling to remove the dither from it.
This is the command I'm using to create the gif:
ffmpeg -f image2 -framerate 24 -y -i image_%d.png -loop -1 "C:\Users\agetr\Documents\_tmp\__giuf.gif"
And I've tried to use the paletteuse=dither=none filter in different ways with no luck.
P.S.: I'm very new to the ffmpeg cli
You need to use -sws_dither none (after the -i $file argument, and before the output file). I've tried this on current git/master of FFmpeg and it works as expected, but on older builds (e.g. 4.4.1) this doesn't work. I don't know why exactly, so use a recent (5.0 or any version from 2022, if possible) version/build.

Batch-converting of INTA images

I have a large number of images in the INTA format, an old SGI standard. INTA is a grayscale image with an alpha channel. All of these need to be converted to TGA files. The problem is that neither ImageMagick nor PIL/Pillow seem to be able to parse them correctly. ImageMagick can read and export them but doesn't seem to understand the alpha channel, and PIL fails to open them, with the error ValueError: Unsupported SGI image mode. The one thing that I've found that reads them successfully is GIMP:
An ideal solution would be one that is easy to invoke from a script.
For reference, here is one of the images in question (the same one seen in the screenshot): https://www.dropbox.com/s/8hoppdgtuqxsy26/girder01.inta?dl=0
It seems GDAL is able to read your image and I converted it to a greyscale+alpha PNG using:
gdal_convert YOURIMAGE.sgi result.png
You can easily get to TGA from there.
I am assuming the batching is not an issue, but it would look something like this in bash:
mkdir -p OUTPUT
for f in *.inta ; do
gdal_translate "$f" OUTPUT/"$f"
done
I had all sorts of trouble installing GDAL on macOS so I just used docker like this:
docker run --rm -v /Users:/Users osgeo/gdal:alpine-normal-latest gdal_translate /Users/mark/Downloads/image.sgi /Users/mark/Downloads/result.png

Mixing video and audio files in Rails

I have a Rails app and I get as params in a controller two files. One is audio (WAV) and the other is video (webm).
I need to mix them together so that the output is a video (mp4) with the already mixed audio.
How can I do this?
As #Meier pointed, using Ruby is not the way to go, but using an external program.
Once ffmpeg is installed on host you can run following command inside Rails to have a mkv output video file:
`ffmpeg -i #{video_file.path} -i #{audio_file.path} -acodec copy -vcodec copy -f matroska output.mkv`

Unrecognized option 'filter_complex' using avconv

I would like to mix two audio files using avconv. In the documentation I found the following way of implementing this:
avconv -i INPUT1 -i INPUT2 -filter_complex amix=inputs=2:duration=first:dropout_transition=3 OUTPUT
However, when I'm trying to run this I get the following errors:
Unrecognized option 'filter_complex'
Failed to set value 'amix=inputs=2:duration=first:dropout_transition=3' for option 'filter_complex'
I have been searching for a solution for quite some time, but couldn't find anything.
I have version 0.8.3-4:0.8.3-0ubuntu0.12.04.1 of avconv. Do I need to change anything in the configurations or use a different version of avconv? Is there another way in which I could mix the audio files?
Thank you for your help.
In some versions, the "complex filter" can specified using the "-filter:v" option, like:
avconv -i INPUT -filter:v amix=inputs=2:duration=first:dropout_transition=3 OUTPUT
Today I was reviewing this problem also and the final solution was just to download a fresh static copy of ffmpeg and forget about the problem...
It seems that avconv doesn't implement -filter_complex, although the manual states that it does.
Version problem you have to update ffmpeg with latest.
but we can also -vf instead of filer-complex like:
ffmpeg -i new1.mp4 -vf "movie=wlogo.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" -strict experimental output.mp4
You should use libav9 probably. Version 9.9 had been released recently.

Running a batch with imagemagick

I need to save a bunch (several thousand) of images with imagemagick.
I'm totally new to it, and its documentation seems totally opaque and totally labyrinth. Where's the quickstart guide?
Looking at it, I think I want to use mogrify.
so I cd to my program files directory where I installed imagemagick.
I run mogrify -format png *.png as I see in various examples.
It says:
mogrify: unable to open image `fgimg\': No such file or directory # blob.c/OpenB
lob/2489.
mogrify: unable to open file `fgimg\' # png.c/ReadPNGImage/2865.
How do I instruct it to run on all images in the subdirectory \fgimg?
Thanks a lot!
The problem here is that you're hitting the limit of how much you can put on a command line. You need to split it into chunks that will fit. This should work better:
find -name '*.png' -print0 | xargs -0 -r mogrify -format png
The -print0 and -0 are used to handle spaces in filenames, and the -r means don't run mogrify if there's nothing to do.

Resources