#!/bin/sh ## ## Nautilus ## SCRIPT: 30d_1mkvCapFile_CONVERTto_WEBM-VP8-VORBIS_4html5_ffmpeg2pass_PRELIM.sh ## ## PURPOSE: Using 'ffmpeg', this script converts an input movie file ## to a '.webm' container movie file. ## ## This script is intended to use as input '.mkv' (Matroska container) ## movie files that are 'lossless' H264-and-PCM ## screen-and-audio-captures from a 'XscreenANDpulseAUDIO_CAPTURE' ## script --- but it may work with other movie file inputs, that is, ## different container formats, such as '.flv' or '.avi' or '.mpg'. ## ## The input video stream (possibly near LOSS-LESS) is converted to ## a *LOSSY* VP8 video stream and the input audio stream (possibly ## near LOSS-LESS) is converted to a *LOSSY* VORBIS audio stream. ## ## METHOD: Uses 'zenity --info' to show info on how this utility works. ## ## Uses 'zenity --entry' to prompt for an image size (x,y-pixels) ## for the output movie file. ## ## Runs 'ffmpeg' in 2 passes --- once with '-an -vcodec libvpx' parms, and ## once with '-vcodec libvpx' and '-acodec libvorbis' parms. ## ## No '-f' parm, for now, in this preliminary version. ## (May need to install a post-2010 version of 'ffmpeg' to ## create the webm container and the vp8 video stream.) ## ## REFERENCE: http://ubuntuforums.org/archive/index.php/t-1392026.html ## "HOWTO: Proper Screencasting on Linux" by verb3k ## ## Runs 'ffmpeg' in an 'xterm' so that messages can be seen. ## ## When the conversion is done, this script ## shows the '.webm' file in a movie player. ## ## HOW TO USE: In Nautilus, select a (.mkv) movie file. ## Then right-click and choose this script to run (name above). ## ## NOTE on usage of this script: ## This script was designed to be run after the feNautilusScript ## 'XscreenANDpulseAUDIO_CAPTURE' ## which captures an X11 desktop and Pulse audio session into ## a 'lossless' H.264 video stream and a 'lossless' PCM audio stream ## in a '.mkv' (Matroska container) movie file. ## ################################################################################ ## Started: 2011may09 ## Changed: 2011dec11 Removed '--no-wrap' from the 'zenity --entry' prompt for ## image size. '--no-wrap' is not implemented for '--entry'. ## Changed: 2012may24 Changed script name in comments above and touched up ## the comments. Changed some indenting below. ########################################################################### ## FOR TESTING: (display statements that execute) # set -x ########################################### ## Get the INPUT movie filename. ######################################################################## ## We know that a LOSSLESS H264-PCM-MKV file from the script ## '30a_VIDpulseAUD_screenCAPTURElossless_toH264-PCM-MKV_ffmpeg_Qquit.sh' ## is successfully convertible to an VP8-VORBIS-WEBM video file, ## via the following 'ffmpeg' command. (according to 'verb3k') ####################################################################### FILENAME="$1" ###################################### ## Prepare the OUTPUT '.webm' filename. ## (The suffix determines the container ## type that 'ffmpeg' creates.) ###################################### FILEOUT="/tmp/${USER}_MOVIEfileCONVERTEDto_LOSSY-vp8-vorbis.webm" if test -f "$FILEOUT" then rm -f "$FILEOUT" fi ########################################## ## Show info on how this utility works. ########################################## CURDIR="`pwd`" CURDIRFOLDED=`echo "$CURDIR" | fold -55` SCRIPT_BASENAME=`basename $0` zenity --info \ --title "INFO on this CONVERT-a-VIDEO utility." \ --no-wrap \ --text "\ This utility, $SCRIPT_BASENAME , will use 'ffmpeg' to (try to) convert the INPUT file $FILENAME in directory $CURDIRFOLDED into lossy VP8 video and lossy VORBIS audio in a WEBM container in OUTPUT file $FILEOUT 'ffmpeg' will be started (twice) in a terminal window so that startup and encoding messages can be watched. When the 2nd-stage 'ffmpeg' is done (that is, when coding messages stop), CLOSE the terminal window. The output file, if good, will be shown in a video player. Now, CLOSE this window to get a PROMPT for image size of the output --- and to, after that, START the 1st of 2 ffmeg-windows." ############################################################ ## Ask for the image SIZE for the NEW LOSSY file that we ## are about to make from the INPUT video file. ############################################################ NEWSIZE="" NEWSIZE=$(zenity --entry \ --title "ENTER image SIZE for the new VP8-VORBIS-WEBM file to be made." \ --text "\ Enter an image size for the WEBM file $FILEOUT that will now be made from the INPUT file $FILENAME Examples: 320x240 = QVGA (4:3 = 1.33...) 352x288 = CIF (1.22...) 640x480 = VGA (4:3 = 1.33...) 720x480 = NTSC screen size (1.5) 720x576 = PAL screen size (1.25) 800x600 = SVGA (4:3 = 1.33...) 1024x768 = XGA (4:3 = 1.33...) 1280x720 = HD720 (16:9 = 1.77...) 1280x1024 = SXGA (5:4 = 1.25) 1920x1080 = HD1080 (16:9 = 1.77...) 1600x1200 = UXGA (4:3 = 1.33...) 0 = same size as input file 'ffmpeg' CONVERSION will be started in a terminal window (twice) so that startup and coding messages can be watched. When the 2nd 'ffmpeg' run is done, CLOSE the terminal window. The output file, if good, will be shown in a video player." \ --entry-text "640x480") if test "$NEWSIZE" = "" then exit fi if test "$NEWSIZE" = "0" then SPARM="" else SPARM="-s $NEWSIZE" fi ########################################################### ## Convert the input movie file into a lossy VP8 video ## stream and lossy VORBIS audio stream in a WEBM container. ## NOTE: This is a two-step process - 2 invocations of 'ffmpeg'. ################################################################### ## WebM is a new, high-quality, free/open format that can be played ## in modern web browsers that support the HTML5