Showing posts with label flash. Show all posts
Showing posts with label flash. Show all posts

Friday, 22 April 2011

Batch flv to mp4 conversion

If you have been happily downloading and storing flash videos you may end up with a whole pile of flv files. My instructions above included a command to convert each file into an mp4 file which is much easier to work with.

What about converting a whole folder full at once?

Try this:

for file in *.flv ; do ffmpeg -i $file -acodec copy -vcodec copy ${file%.flv}.mp4 ; done

That three stage command does the following (in english):

The first bit before the semi colon means, [for] each [*] file that you find in the current folder with the extension [flv], take the full name of the file forward into the next part of the command as a variable [file]. The next bit says that you [do] the command [ffmpeg] using as an [i]nput the variable [$] called [file]. The options for the ffmpeg command are to [copy] the [a]udio [codec] and the [v]ideo codec, so no recompression. You retain the same data but in a different container. The output of the command is a file with a name made up of the variable [$] called [file] minus [%] the characters [.flv] PLUS the characters [.mp4]. The last bit after the second semi colon closes the command sequence started by the [do]. If you felt brave you could stick a [r]e[m]ove command in here to get rid of your input files in before the [; done].

Friday, 11 March 2011

Downloading Flash Videos

OK, so is your ISP are bandwidth throttling you, getiplayer sorts out patchy video from the Beeb, but what about youtube et al? There is actually a simple way to store flash video using ubuntu without the need to purchase downloadsaverproextreme. You just grab the downloaded file from Ubuntu's temp space.

First of all you want to be sure that firefox knows it has enough cache space to download whatever it is we are viewing. Enter this into the address bar of firefox:

about:config

Then search for the following settings and change them as suggested:

browser.cache.disk.capacity = 500000
media.cache_size = 500000

Incidentally, none of that may be necessary, but the next step certainly is. Change to the temporary folder:

cd /tmp

And view the contents of the folder:

ls -alhSr

That lists [a]ll files with a[l]l information, with file sizes in [h]uman readable format, [r]everse ordered by [S]ize so that the largest is last. I prefer it in the easier to remember sequence:

ls -Sharl

Now, go to firefox, open the webpage that the video is on, and start the video playing. Pause it right away so that the stutter of slowly downloading video doesn't drive you mental. Run the [ls] command above from time to time and you can watch the video file increase in size. It is probably going to end up as the largest file in the /tmp folder - and therefore at the bottom of the list.

Copy this file to ~/Videos, while the firefox tab is still open. This is important, if you navigate away from the page the temporary file is deleted immediately. If the video is from youtube it should just be a x264 video and aac audio in a flv wrapper. You can change wrappers to .mp4 to make the video file compatible with your video player of choice with ffmpeg, while keeping the actual video and audio data unchanged with this command:

ffmpeg -i [your filename here].flv -vcodec copy -acodec copy [output name].mp4