Docker wrapper for https://github.com/donmelton/video_transcoding
100K+
For more information about this image and its history, please see the Dockerfile repository on Github.
You must be running Docker for Mac, Docker for Linux, or Docker for Windows.
To run the video_transcoding gem in Docker, execute the following:
# Docker for Mac and Linux
$ docker run -itv "`pwd`":/data ntodd/video-transcoding
# Docker for Windows
$ docker run -itv C:\My\Current\Path:/data ntodd/video-transcoding
# Update to the latest image
$ docker pull ntodd/video-transcoding
This will:
ntodd/video-transcoding Docker image (unless already downloaded)For best results on Docker for Mac or Windows, set your CPU count in preferences to the maximum available for your machine.
The docker image is easily scriptable. Below is an example of a ruby script that will batch transcode videos in the current directory. Add the script to your path to execute in any directory.
#!/usr/bin/env ruby
supported_types = %w(mov flv wmv avi divx mpg mpeg mp4 mkv)
output_dir = "./output"
docker_command = "docker run -itv \"`pwd`\":/data ntodd/video-transcoding"
glob = "./*\.{#{supported_types.join(',')}}"
if Dir.glob(glob).length > 0
# Make the output dir
system("mkdir -p #{output_dir}")
# Pull the latest docker image
system("docker pull ntodd/video-transcoding")
else
puts "No supported video types in directory. Supported types: #{supported_types.join(', ')}"
end
Dir.glob(glob).each do |input_path|
output_path = "#{output_dir}/#{File.basename(input_path, '.*')}.mp4"
transcode_command = "transcode-video --crop detect --handbrake-option encoder=x265 --target small --mp4 \"#{input_path}\" -o \"#{output_path}\""
command = "#{docker_command} #{transcode_command}"
begin
IO.popen(command, err: [:child, :out]) do |io|
Signal.trap 'INT' do
Process.kill 'INT', io.pid
end
io.each_char do |char|
print char
end
end
rescue SystemCallError => error
raise "transcoding failed: #{error}"
end
end
This will:
output dir in the current directorysupported_types) to an h265 "small" mp4 with a detected cropThis is not comprehensive, but can be used as a starting point for your own scripts.
Content type
Image
Digest
Size
356.7 MB
Last updated
over 7 years ago
docker pull ntodd/video-transcoding