Return to Snippet

Revision: 44538
at April 15, 2011 15:29 by daxumaming


Updated Code
#!/bin/bash

############################################################
## License: Public Domain
## Author: Dax Solomon Umaming
## 
## Save in ~/bin then execute on a directory
## with the videos you wish to convert
## 
## Take note that you'll need ffmpeg restricted libraries
## On Ubuntu, you can download and install them from the
## Medibuntu Repository at http://medibuntu.org/
## check the howtos for instruction on how to install them
## you'll need the *-unstripped and *-extra libraries
## 
## You'll also need to have libnotify1 package installed
## Since ffmpeg already outputs tons of messages on the
## terminal, the messages this script outputs will only
## be readable (or even usable) using the desktop
## notification daemon
## 
############################################################

# get filenames in a directory
for origfilename in *
do 

	# skip mp4 files, since that is - afterall - our target file format
	if expr "$origfilename" : "\(.*\.[Mm][Pp]4$\)" > /dev/null 2>&1
	
		then echo "Skipping $origfilename"
		
	# process non-mp4 files
	else
		# placeholder to be utilized by the array
		newfilename=$origfilename
	
		# set video file extensions in an array
		vidextensions=(flv avi mkv 3gp ogv m4v f4v)
		
		# remove above-declared extensions from the file name
		for vidext in "${vidextensions[@]}"
		do
			newfilename=`echo $newfilename|sed 's/\.'${vidext[@]}'$//g'`
		done
		
		# convert video files to mp4 format
		notify-send "Converting $origfilename to mp4"
		ffmpeg -i "$origfilename" -acodec libfaac -ac 2 -vcodec mpeg4 -r 25 -s qvga -metadata title="$newfilename" "$newfilename.mp4"
		
	fi

done
notify-send "Done converting all videos to MP4"

Revision: 44537
at April 13, 2011 19:32 by daxumaming


Initial Code
#!/bin/bash

for origfilename in *
do 
	# remove flv extension
	newfilename=`echo $origfilename|sed 's/\.flv$//g'`
	
	# convert video files to mp4 format
	notify-send "Converting $origfilename to mp4"
	ffmpeg -i "$origfilename" -acodec libfaac -ac 1 -vcodec mpeg4 -r 25 -s qvga -metadata title="$newfilename" "$newfilename.mp4"

done
notify-send "Done converting all videos to MP4"

Initial URL

                                

Initial Description
This will convert videos to MP4 that's optimized and plays on my phone. The said videos should be stored on a directory so this script could parse them.

Requires unstripped codecs from the Medibuntu repository (libavcodec-unstripped-52, libavdevice-unstripped-52, libavformat-unstripped-52, etc.) which contains the MP4 and libfaac Encoders. See: http://ubuntuforums.org/showthread.php?t=1117283 and http://www.medibuntu.org/repository.php

This script also requires the libnotify1 package for the notify-send command (or you can just echo it, instead of using the desktop notification daemon)

Update the ffmpeg statement as needed, check the documentation at http://www.ffmpeg.org/ffmpeg-doc.html

Initial Title
Convert Flash Videos on a directory to MP4

Initial Tags

                                

Initial Language
Bash