Converting flash videos

Getting flash videos
You can download flash videos with websites such as keepvid or using Firefox add-ins such as Video DownloadHelper.

Converting flash videos
Use Mediainfo to find out how the flash video was encoded, and use this info to set your encode options. Converting flash videos to xvid

mencoder comes with the package media-video/mplayer. The problem is that the sound doesn't match the video so we have to re-convert it with media-video/avidemux.

Converting flash videos to MP3
Flash videos are not the pinnacle of audio quality. For example, Youtube converts the sound to a 22050 sampling rate mono mp3 with 64K bitrate.

Using ffmpeg
-i is to specified input file, -ab audio bitrate, -ar audio sampling frequency

Using mplayer
dump audio as mp3

dump audio as wav and re-encode

This will output a file named audiodump.wav, then convert this file to mp3 or any other codec:

Perl scripts
i've made a perl script in order to make the conversion with mencoder more easy i've hardcoded the directories...feel free to fork it Sample Script Sample Script Info for the perl scripts

in order to convert flash videos with blank space in the name use the simple quote:

by the way the name of my scripts are audio.pl and video.pl (so they don't interfere with others command) GUI Perl script

i have made a giu in order to transform flash video in mp3 here are the dependencies:

emerge dev-perl/gtk2-perl Sample Script GUI for converting flash videos in xvid {{Code|Sample Script|
 * 1) !/usr/bin/perl
 * 2) This program is free software: you can redistribute it and/or modify
 * 3) it under the terms of the GNU General Public License as published by
 * 4) the Free Software Foundation, either version 3 of the License, or
 * 5) (at your option) any later version.
 * 6) This program is distributed in the hope that it will be useful,
 * 7) but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 8) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * 9) GNU General Public License for more details.
 * 10) You should have received a copy of the GNU General Public License
 * 11) along with this program. If not, see .
 * 1) You should have received a copy of the GNU General Public License
 * 2) along with this program. If not, see .

use strict ; use Gtk2 '-init' ; use Gtk2::Helper; use Glib qw(TRUE FALSE); use Time::HiRes qw(usleep); use FileHandle;

our $filename; our $save_as; our $progressbar;

sub quit{ Gtk2->main_quit; }

sub pulse { $progressbar->set_pulse_step(1/10); $progressbar->pulse; return 1; }
 * 1) $progressbar = shift;

sub finished { my $finished = Gtk2::Dialog->new ('The conversion has finished', undef,'destroy-with-parent',                                                           'ok' => '4'); my $label = Gtk2::Label->new("you can find the xvid here: $save_as"); $finished->vbox->add ($label); $finished->signal_connect (response => \&quit ); $finished->show_all; }
 * 1) print "the conversion has finished\n"

sub progressbar { Gtk2->main_iteration while Gtk2->events_pending; $progressbar->pulse; usleep(100000); }
 * 1) $progressbar->set_pulse_step(0.1 ) ;

sub file_chooser { my $file_chooser = Gtk2::FileChooserDialog->new ('Choose a flash video to convert to xvid',                                undef, 'open',                                 'gtk-cancel' => 'cancel',                                      'gtk-ok' => 'ok');

my $preview_widget = Gtk2::Label->new; $preview_widget->set_line_wrap (TRUE); $preview_widget->set_size_request (150, -1); $file_chooser->set (preview_widget => $preview_widget,                   preview_widget_active => TRUE); $file_chooser->signal_connect (selection_changed => sub {  $filename = $file_chooser->get_preview_filename;   # we'll hide the preview widget if the selected item is a directory.   # in practice, you may find this really annoying, as it causes the   # window to change size.   my $active = defined $filename && not -d $filename;   if ($active) {      my $size = sprintf '%.1fK', (-s $filename) / 1024;      my $desc = `file '$filename'`;      $desc =~ s/^$filename:\s*//;      $preview_widget->set_text ("$size\n$desc");   }   $file_chooser->set (preview_widget_active => $active); });
 * 1) create a preview widget, which will show a quick summary of information
 * 2) about the selected file, updated whenever the selection changes.
 * 3) note that this assumes you're on a unix-like system with the 'file'
 * 4) utility installed.

if ('ok' eq $file_chooser->run) { # you can get the user's selection as a filename or a uri. }
 * 1) add an app-specific entry to the shortcut list.
 * 2) $file_chooser->add_shortcut_folder ('/tmp');
 * 3) eval { $file_chooser->add_shortcut_folder_uri ('http://localhost/'); };
 * 4) warn "couldn't add shortcut: $@\n" if $@;
 * 1)    my $uri = $file_chooser->get_uri;
 * 2)    print "uri $uri\n";
 * 3)    $filename = $file_chooser->get_filename;
 * 4)    print "$filename\n";

$file_chooser->destroy; }

sub file_saver { my $dialog = Gtk2::FileChooserDialog->new('Save as',undef,'save',                                         'gtk-ok', 'ok',                                          'gtk-cancel', 'cancel'); my $response = $dialog->run; # this blocks

if ($response eq 'ok') { $save_as = $dialog->get_filename; }

$dialog->destroy;

} my $main_app_window; my $dialog = Gtk2::Dialog->new ('flv->xvid convertissor', $main_app_window,                               'destroy-with-parent',                       'Choose a  flv file' => '1',                           'Save in Xvid format' => '2',            'Convert' => '3',            "Afficher l'endroit ou se trouve le xvid" => '4'                  );

$dialog->signal_connect (response => \&button_response ); $dialog->signal_connect(delete_event => \&quit);

$progressbar = Gtk2::ProgressBar->new; $dialog->vbox->add ($progressbar);

sub button_response { my ($dialog, $response_id) = @_;

if ($response_id eq '1') { file_chooser; }

if ($response_id eq '2') { file_saver; }

if ($response_id eq '3') { chdir "/tmp"; my $pipe = FileHandle->new; open $pipe, '-|', "mencoder '$filename' -ovc xvid -oac mp3lame -xvidencopts bitrate=1500 -o '$save_as'" or die "can't do the processing"; my $watch; $watch = Gtk2::Helper->add_watch ( $pipe->fileno, 'in', sub {          watcher_callback( $pipe, $watch );         }); sub watcher_callback { my ($pipe, $watch) = @_;
 * 1) $test=1;
 * 1) open my $pipe, '-|', "mencoder '$filename' -ovc xvid -oac mp3lame -xvidencopts bitrate=1500 -o '$save_as'" or die "can't do the processing";
 * 2) my $tag;
 * 3) $tag = Gtk2::Helper->add_watch( fileno( $pipe ), in => sub {
 * 4)     if ( eof( $pipe ) ) {
 * 5)         Gtk2::Helper->remove_watch( $tag );
 * 6)         close( $pipe );
 * 7) my $finished = Gtk2::Dialog->new ('The conversion has finished', undef,'destroy-with-parent',                                                            'ok' => '4');
 * 8) my $label = Gtk2::Label->new("you can find the xvid here: $save_as");
 * 9) $finished->vbox->add ($label);
 * 10) $finished->signal_connect (response => \&quit );
 * 11) $finished->show_all;
 * 12)     }
 * 13)     else {
 * 14) # $progressbar->{timer} = Glib::Timeout->add(100,\&pulse);
 * 15) Gtk2->main_iteration while Gtk2->events_pending;
 * 16) # $progressbar->set_pulse_step(0.1 ) ;
 * 17) $progressbar->pulse;
 * 18) usleep(100000);
 * }
 * }

# we safely can read a chunk into $buffer my $buffer;

if ( ! sysread($pipe, $buffer, 4096) ) { # obviously the connected pipe was closed finished; Gtk2::Helper->remove_watch ($watch) or die "couldn't remove watcher"; close($pipe); return 1; }

# do something with $buffer ... progressbar;
 * 1)             print $buffer;

# *always* return true return 1; }

return 1;

if ($response_id eq '4') { print "$save_as\n"; }

} } $dialog->show_all; Gtk2->main; }} GUI for converting all the flash videos that are in a folder in mp3 Sample Script