audio_to_video 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/audio_to_video.rb +25 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c3faa451c33d355e31c7c84c67b5b3d987421e2f7650edc4b72393ac06bc08fc
4
+ data.tar.gz: 365ab1e5d0b392f167e8059d89dba52b70f2a8da7531a594b5b64fabef5fcce0
5
+ SHA512:
6
+ metadata.gz: 35355672ccddca23677f282434b6c2a66eb3e8a92ad76357725ddf4f5034b8e4e6fa4650a115b20cd73642cf2a9a133d80944a88dcac94c956436ee553d71be1
7
+ data.tar.gz: 702da6d661b4d38b685c553b1506c58044c784bc18a8d8ca911e56db26db467a2e1b980a794b57875165a0bc7b2b7a2d628dcaa30b34048de4c06da272e8d4a4
@@ -0,0 +1,25 @@
1
+ # Videos for your Songs
2
+ class AudioToVideo
3
+ def self.audio_to_video(audio, image: "./black-background.webp")
4
+ # Supports Files or ActiveStorage::Attachment
5
+ loop_option = if image.blob.content_type.downcase.include?("gif")
6
+ "-ignore_loop 0"
7
+ else
8
+ "-loop 1"
9
+ end
10
+
11
+ directory = 'tmp/audio_to_video'
12
+ # Create the directory if it doesn't exist
13
+ Dir.mkdir(directory) unless File.directory?(directory)
14
+
15
+ output_path = Rails.root.join("#{directory}/audio_#{Time.zone.now.strftime("%s_%m_video")}.mp4")
16
+
17
+ audio.open do |local_audio|
18
+ image.open do |local_image|
19
+ command = "ffmpeg #{loop_option} -i #{local_image.path} -i #{local_audio.path} -c:v libx264 -tune stillimage -c:a aac -strict experimental -b:a 192k -shortest #{output_path}"
20
+ system(command)
21
+ end
22
+ end
23
+ output_path
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: audio_to_video
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Enoch Tamulonis
8
+ - Kurt Tamulonis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2024-01-08 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Convert an Audio and an Image into Videos easily!
15
+ email: wavclouds@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/audio_to_video.rb
21
+ homepage: https://rubygems.org/gems/audio_to_video
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubygems_version: 3.4.22
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: AudioToVideo#audio_to_video method lets you create videos easily
44
+ test_files: []