Skip to content

Instantly share code, notes, and snippets.

@youpy
Created February 26, 2009 06:18
Show Gist options
  • Select an option

  • Save youpy/70691 to your computer and use it in GitHub Desktop.

Select an option

Save youpy/70691 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# remove key frame information from AVI file(codec: xvid)
# a name of AVI file
filename = ARGV.shift
f = open(filename)
data = f.read
f.close
main, index = data.split('idx1')
frames = main.split('00dc')
header = frames.shift
new_frames = []
frames.each_with_index do |frame, i|
unless frame.index("\x00\x01\xb0\x03")
new_frames << frame
end
end
print [([header] + new_frames).join('00dc'), index].join('idx1')
use strict;
use Carp;
use FFmpeg::Command;
my $ffmpeg = FFmpeg::Command->new('/Users/youpy/Desktop/ffmpeg');
my $output_file = 'out.avi';
$ffmpeg->input_options({
file => shift,
});
$ffmpeg->timeout(300);
$ffmpeg->output_options({
file => $output_file,
video_codec => 'libxvid',
format => 'avi',
});
# disable audio
#push @{ $ffmpeg->options }, '-an';
push @{ $ffmpeg->options }, qw/-sameq -aspect 4:3/;
#push @{ $ffmpeg->options }, qw/-sameq/;
my $result = $ffmpeg->exec();
croak $ffmpeg->errstr unless $result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment