added ruby script for concat videos
This commit is contained in:
parent
4e55a6e157
commit
58b0530f17
18
record-and-playback/scripts/README.txt
Executable file
18
record-and-playback/scripts/README.txt
Executable file
@ -0,0 +1,18 @@
|
||||
README file
|
||||
|
||||
Scripts Description:
|
||||
|
||||
===============================================================
|
||||
concat-videos.rb
|
||||
|
||||
The script can create a image video of T seconds taking the logo.jpg file, and can join several videos.
|
||||
Receives N parameters which can be a video filename and/or integer T. Usage:
|
||||
|
||||
ruby concat-videos.rb video1.flv 25 video2.flv
|
||||
output: a result.flv video (video1.flv+imageVideo.flv+video2.flv)
|
||||
|
||||
ruby concat-videos.rb video1.flv 25 video2.flv 60 video3.flv
|
||||
output: a result.flv video (video1.flv+imageVideo.flv+video2.flv+imageVideo.flv+video3.flv)
|
||||
|
||||
NOTE: The videos to join should be in the same directory
|
||||
===============================================================
|
51
record-and-playback/scripts/concat-videos.rb
Executable file
51
record-and-playback/scripts/concat-videos.rb
Executable file
@ -0,0 +1,51 @@
|
||||
class MediaFormatException < StandardError
|
||||
end
|
||||
|
||||
class String
|
||||
def is_i?
|
||||
!!(self =~ /^[-+]?[0-9]+$/)
|
||||
end
|
||||
end
|
||||
|
||||
def executeFfmpeg(command)
|
||||
IO.popen(command) do |pipe|
|
||||
pipe.each("r") do |line|
|
||||
puts line
|
||||
end
|
||||
end
|
||||
raise MediaFormatException if $?.exitstatus != 0
|
||||
end
|
||||
|
||||
def executeMencoder(videos)
|
||||
command="mencoder -forceidx -of lavf -oac copy -ovc copy -o result.flv "
|
||||
videos.each do|a|
|
||||
command << "#{a} "
|
||||
end
|
||||
IO.popen(command) do |pipe|
|
||||
pipe.each("r") do |line|
|
||||
puts line
|
||||
end
|
||||
end
|
||||
raise MediaFormatException if $?.exitstatus != 0
|
||||
end
|
||||
|
||||
def execute(args)
|
||||
videos = []
|
||||
cont=0
|
||||
args.each do|a|
|
||||
if(a.include? ".flv")
|
||||
puts "parsing flv video: #{a}..."
|
||||
executeFfmpeg("ffmpeg -i #{a} -r 1 -y #{a}")
|
||||
videos << a
|
||||
elsif(a.is_i?)
|
||||
puts "creating image video with duration: #{a} seconds..."
|
||||
newImageVideo="tmp#{cont}.flv"
|
||||
executeFfmpeg("ffmpeg -loop_input -t #{a} -i logo.jpg -r 1 #{newImageVideo}")
|
||||
videos << newImageVideo
|
||||
cont=cont+1
|
||||
end
|
||||
end
|
||||
executeMencoder(videos)
|
||||
end
|
||||
|
||||
execute(ARGV)
|
BIN
record-and-playback/scripts/logo.jpg
Executable file
BIN
record-and-playback/scripts/logo.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
Loading…
Reference in New Issue
Block a user