How to structure a Sass project

One of the most useful features of Sass is being able to separate your stylesheets into separate files. You can then use the @import directive to include the source of your individual files into one master stylesheet.

But how should you structure your Sass projects? Is there a standard way of separating out your CSS files?

Basic directory structure

I like to layout my Sass projects like this:

stylesheets/
|
|-- modules/              # Common modules
|   |-- _all.scss         # Include to get all modules
|   |-- _utility.scss     # Module name
|   |-- _colors.scss      # Etc...
|   ...
|
|-- partials/             # Partials
|   |-- _base.sass        # imports for all mixins + global project variables
|   |-- _buttons.scss     # buttons
|   |-- _figures.scss     # figures
|   |-- _grids.scss       # grids
|   |-- _typography.scss  # typography
|   |-- _reset.scss       # reset
|   ...
|
|-- vendor/               # CSS or Sass from other projects
|   |-- _colorpicker.scss
|   |-- _jquery.ui.core.scss
|   ...
|
`-- main.scss            # primary Sass file

Primary stylesheet

This allows me to keep my primary Sass file extremely clean:

// Modules and Variables
@import "partials/base";

// Partials
@import "partials/reset";
@import "partials/typography";
@import "partials/buttons";
@import "partials/figures";
@import "partials/grids";
// ...

// Third-party
@import "vendor/colorpicker";
@import "vendor/jquery.ui.core";

Modules, partials, and vendor

As you can see this divides my project into three basic types of files. Modules, partials, and vendored stylesheets.

  • The modules directory is reserved for Sass code that doesn’t cause Sass to actually output CSS. Things like mixin declarations, functions, and variables.
  • The partials directory is where the meat of my CSS is constructed. A lot of folks like to break their stylesheets into header, content, sidebar, and footer components (and a few others). As I’m more of a SMACSS guy myself, I like to break things down into much finer categories (typography, buttons, textboxes, selectboxes, etc…).
  • The vendor directory is for third-party CSS. This is handy when using prepackaged components developed by other people (or for your own components that are maintained in another project). jQuery UI and a color picker are examples of CSS that you might want to place in the vendor directory. As a general rule I make it a point not to modify files in my vendor directory. If I need to make modifications I add those after the vendored files are included in my primary stylesheet. This should make it easy for me to update my third-party stylesheets to more current versions in the future.

Using a base partial

In my partials directory you will also notice that I have a base partial. The purpose of this partial is to load up my Sass environment so that it’s easy to construct a stylesheet.

It might look something like this:

// Use Compass ('cause it rocks!)
@import "compass";

// Font weights
$light: 100;
$regular: 400;
$bold: 600;

// Base Font
$base-font-family: sans-serif;
$base-font-weight: $regular;
$base-font-size: 13px;
$base-line-height: 1.4;

// Fixed Font
$fixed-font-family: monospace;
$fixed-font-size: 85%;
$fixed-line-height: $base-line-height;

// Headings
$header-font-weight: $bold;

@import "modules/all";

The base stylesheet sets a couple of global variables and loads up all of my Sass modules. Again modules are not allowed to contain anything that would cause CSS output when importing. Tying all of my varibles and modules up into a base partial gives me access to my entire Sass environment whenever I’m setting up a new stylesheet with a single import statement. This allows me to build multiple stylesheets by importing different partials. Multiple stylesheets are handy once a project grows to a certain size.

One step further

At UserVoice we take this pattern one step further. Since we have multiple sub-projects all bundled together in a single Rails app, we bundle each sub-project into a separate top-level directory. Our stylesheet directory looks more like this:

stylesheets/
|
|-- admin/           # Admin sub-project
|   |-- modules/
|   |-- partials/
|   `-- _base.scss
|
|-- account/         # Account sub-project
|   |-- modules/
|   |-- partials/
|   `-- _base.scss
|
|-- site/            # Site sub-project
|   |-- modules/
|   |-- partials/
|   `-- _base.scss
|
|-- vendor/          # CSS or Sass from other projects
|   |-- _colorpicker-1.1.scss
|   |-- _jquery.ui.core-1.9.1.scss
|   ...
|
|-- admin.scss       # Primary stylesheets for each project
|-- account.scss
`-- site.scss

As you can see each sub-project has it’s own primary stylesheet, modules, partials, and base. Vendored stylesheets are typically versioned and have their own top-level directory. This is a handy pattern to use on very large Sass projects.

Further exploration

Now that I’ve laid out my own method for this, you may want to explore how other people have structured their Sass projects. There’s actually a lot of variation in what you can do here. And some methods may work better on different projects:

Create cross-platform apps with PhoneGap and jQuery Mobile

One of the biggest challenges of developing mobile applications is trying to port the application to multiple platforms. This can lead to extensive development costs, and the need for multiple skillsets internally in order to maintain the application. This has led to the development of a number of technologies that provide a cross-platform solution.

Arguably, the most popular of these technologies is PhoneGap. The solution allows developers to create applications with a familiar tool set: HTML, CSS, and JavaScript.

androidlogo2.jpg

 When PhoneGap is combined with a mobile web development framework, it’s possible to develop cross-platform mobile applications quickly. One of the most popular frameworks is jQuery Mobile due to its simplicity and native look and feel.

I’ll demonstrate how to develop a simple application that uses PhoneGap APIs with jQuery Mobile to search for a list of contacts by name and display them (Figure A). Then, I’ll show how to deploy the application to your Android device with PhoneGap.  Follow along with the step-by-step tutorial, or download and import the project.

Figure A

phonegap_jquerymobile_010214.png

1. Install PhoneGap. It’s platform dependent, so I refer you to the PhoneGap documentation.

2. Execute the following lines in a terminal window to create the application in the current directory:

$ phonegap create ContactsList
$ cd ContactsList
$ phonegap run android

3. PhoneGap provides a variety of plugins for accessing the native APIs of a device.  This example will make use of the PhoneGap Contacts Plugin. To add the Contacts Plugin, execute the following at the command line:

$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts.git

4. Enable the plugin within your PhoneGap application by adding this line to the app/res/xml/config.xml file:

<plugin name="Contacts" value="org.apache.cordova.ContactManager" />

5. You must provide permissions to contacts within the AndroidManifest.xml, so within the application, add these lines to the app/AndroidManifest.xml file:

<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />

6. Now you’re ready to start developing the application. The first step is to create a page that will hold the list of contacts you’re attempting to show. With jQuery Mobile, this is achieved using the <div data-role=”page”> element. Copy this code snippet into the www/index.html file of your application:

<!DOCTYPE html> 
<html> 
	<head> 
	<title>Page Title</title> 

	<meta name="viewport" content="width=device-width, initial-scale=1"> 

  <link rel="stylesheet" 
    href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
  <script type="text/javascript" src="phonegap.js"></script>
  <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
  <script 
    src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
  <script type="text/javascript" src="js/index.js"></script>
</head> 
<body>
  <div data-role="page">
    <div data-role="header">
      <h1>Show My Contacts</h1>
    </div><!-- /header -->

    <div data-role="content">	
      <div id="contactsList">
      </div>
    </div><!-- /content -->
  </div><!-- /page -->

</body>
</html>

We included the jQuery Mobile script and stylesheet in the <head>; this is all that is needed to use the jQuery Mobile framework. Within the <div data-role=”page”> element, we define the <div data-role=”header”> and <div data-role=”content”> elements. These elements define what content will be rendered in the page header and the content section, respectively.

7. In the previous snippet, there was an empty <div id=”contactsList”>; this <div> element will contain your contacts list. You can use JavaScript to retrieve the contacts and display them. PhoneGap provides an event to hook into the moment the application is loaded, and the device is ready. Replace the code in the www/js/index.js file with the following:

 

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    // find all contacts with 'Jacob' in any name field
    var options = new ContactFindOptions();
    options.filter = "Jacob";
    options.multiple = true; 
    var fields = ["displayName", "name", "phoneNumbers"];
    navigator.contacts.find(fields, onSuccess, onError, options);
}

This code snippet adds a listener that will retrieve all contacts with “Jacob” anywhere in the name once the device is ready. The data returned from the retrieval will contain the contact names and phone numbers, and will be passed to an onSuccess method.

8. After retrieving the contacts, you need to display them to the user. You can use the jQuery Mobile Collapsible List to display the contact names and allow them to be expanded to show the phone numbers. Add the following snippet to the www/js/index.js file:

 

function onSuccess(contacts) {
  for(var i = 0; i < contacts.length; i++) {
    var html = '<div data-role="collapsible" data-inset="false">';

    html += '<h2>' + contacts[i].displayName + '</h2>';
    html += '<ul data-role="listview">'

    var contact = contacts[i];

    for(var j = 0; j < contact.phoneNumbers.length; j++) {
      html += '<li>' + contact.phoneNumbers[j].type + 
        ": " + contact.phoneNumbers[j].value + '</li>';
    }

    html += '</ul></div>';

    $('#contactsList').append(html);
  }

  $('[data-role=collapsible]').collapsible().trigger('create');
}

function onError(contactError) {
  alert('onError!');
}

Notice that we make use of the PhoneGap Contact object here. Be sure to specify the fields you want to use when finding the contacts list.9. If you have your Android device or an emulator set up appropriately, execute this command to deploy the application:

 

$ phonegap install android

Keep exploring

Try deploying the application to other platforms and using additional PhoneGap APIs. It may just convince you to use the platform for your next app.

How to Configure Nginx to Execute PHP Using PHP-FPM

Nginx is pronounced as “Engine-X”, which is a web server and reverse proxy server. Nginx is well known for its speed and ability to handle large number of requests simultaneously with optimal use of resources.

PHP-FPM stands for “PHP-FastCGI process manager”. CGI refers to the common gateway interface which is scripted to work as a interface between the web server and dynamic content serving programs. It listens on a port much like the web server itself does, and passes the request between the PHP and web server.

This tutorial provides instructions on how to install and configure Nginx with PHP-FPM, which will help you to execute PHP programs in Nginx.

As we discussed earlier in Apache vs Nginx, when compared to Nginx, Apache is relatively slow while handling heavy load and processing large number of requests.

1. Install Nginx

You can either install Nginx from source, or install it using the package management tool that comes with your distro.

For example, on Ubuntu you can install nginx using apt-get as shown below.

$ sudo apt-get install nginx

Start the nginx server as shown below:

$ sudo service nginx start

Go to http://{your-ip-address} and make sure you see the Nginx’s welcome page.

2. Install PHP5-FPM

Next, install php5-fpm using the package management tool that comes with your distro.

For example, on Ubuntu you can install php5-fpm using apt-get as shown below.

$ sudo apt-get install php5-fpm

3. Add PHP Configuration to Nginx

Next, modify the /etc/nginx/sites-available/default file, and add the following lines.

$ sudo vi /etc/nginx/sites-available/default
server {
  listen   80;
  root /usr/share/nginx/www;
  index index.php index.html index.htm;
  server_name example.com;
  location / {
    try_files $uri $uri/ /index.html;
  }
  error_page 404 /404.html;
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
    root /usr/share/nginx/www;
  }
  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
}

4. Set listen Parameter in php5-fpm www.conf

Next, we need to make the following changes in the php-frpm configuration.

By default, you’ll see the following listen entry in the www.conf file

$ sudo vi  /etc/php5/fpm/pool.d/www.conf
listen =  127.0.0.1:9000

In the www.conf file, leave everything as it is, and replace the above listen line with the one shown below.

$ sudo vi  /etc/php5/fpm/pool.d/www.conf
listen = /var/run/php5-fpm.sock

5. Restart the Nginx and PHP5-FPM and Test it

Restart php5-fpm and nginx as shown below

$ sudo service nginx restart

$ sudo service php5-fpm restart

Finally, create the following index.php file in the nginx document root, and test it.

$ sudo vi /usr/share/nginx/www
<?php
  phpinfo( );
?>

Finally, open your browser and go to http://localhost/index.php (or use your ip-address), which will execute the index.php file and display the php information.

How To Install and Setup Postfix on Ubuntu 12.04

About Postfix


Postfix is a free, open source Mail Transfer Agent which works to route and deliver email.

Prerequisites

Before installing Postfix, you will need to have a Fully Qualified Domain Name pointing to the server that you will be using.

You can find instructions on that here:
How to Set Up a Host Name with DigitalOcean

Install Postfix


Postfix can easily be installed through apt-get:

sudo apt-get install postfix

During the installation, you will see a dialogue box appear, asking you which kind of installation you would prefer. Select “Internet Site”.

Follow up by entering the name of your domain.

Once Postfix is installed there are a few steps that need to be taken before it is fully functional.

Configure Postfix

Once Postfix is installed, go ahead and open the main configuration file.

sudo nano /etc/postfix/main.cf

There are a few changes that should be made in this file.

myhostname = example.com

Put in name of your domain into myhostname.

If you want to have mail forwarded to other domains, replace alias_maps with virtual_alias_maps and point it to /etc/postfix/virtual.

virtual_alias_maps = hash:/etc/postfix/virtual

The rest of the entries are described below

mydestination defines the domains that postfix is going to serve, in this case—localhost and your domain (eg. example.com).

relayhost can be left, as is the default, empty.

mynetworks defines who can use the mail server. This should be set to local—creating an open mail server is asking for SPAM. This will usually have damaging effects on your server and may put you in line for discipline from your web hosting provider.

If it is not set up by default, as it should be, make sure you have the following text on that line:

mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128

The rest of the lines are set by default. Save, exit, and reload the configuration file to put your changes into effect:

sudo /etc/init.d/postfix reload

Configure Additional Emails

To redirect emails to specific emails, you can add users to the alias file. By default each user on the server will be able to read emails directed to their username@domain-name.com.

Open up the the alias database:

sudo nano /etc/postfix/virtual

Within that file, enter in the names of your users. For example:

sales@example.com username1
me@example.com username2

Once you are finished, save, exit, and run the following command:

postmap /etc/postfix/virtual

The last step is to reload postfix once more.

sudo /etc/init.d/postfix reload

Conclusion

Once Postfix is installed, mail can be sent to and from the server, although without a mail server like Dovecot or Cyrus, you will only be able to see the email on the server.

You send out email from the command line with the command “sendmail” and where you want the mail sent to:

sendmail sample-email@example.org

Once you enter the command, type your message, and when it is completed, you can send it off with ctrl-D

Incoming mail gets delivered into /var/mail/username

Compile FFmpeg on Ubuntu, Debian, or Mint

This guide for supported releases of UbuntuDebian, and Linux Mint will provide a local install of the latest FFmpeg tools and libraries including several external encoding and decoding libraries (codecs). This will not interfere with repository packages.

You may also refer to the Generic FFmpeg Compilation Guide for additional information.

Recent ​static builds are also available for lazy people or those who are unable to compile.


Get the Dependencies

Copy and paste the whole code box for each step.

sudo apt-get update
sudo apt-get -y install autoconf automake build-essential libass-dev libgpac-dev \
  libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libx11-dev \
  libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev
mkdir ~/ffmpeg_sources
  • Server users can omit the ffplay and x11 dependencies: libsdl1.2-dev libva-dev libvdpau-dev libx11-dev libxext-dev libxfixes-dev.
  • Lucid lacks the package libva-dev. This can be ignored.

Compilation & Installation

You can compile ffmpeg to your liking. If you do not require certain encoders you may skip the relevant section and then remove the appropriate ./configure option in FFmpeg. For example, if libopus is not needed, then skip that section and then remove --enable-libopus from the Install FFmpeg section.

This guide will create several directories in your home directory:

  • ffmpeg_sources – Where the source files will be downloaded.
  • ffmpeg_build – Where the files will be built and libraries installed.
  • bin – Where the resulting binaries (ffmpegffplayffserverx264, and yasm) will be installed.

You can easily undo any of this as shown in Reverting Changes Made by This Guide.

Yasm

The first step is to compile Yasm which is an assembler used by x264 and FFmpeg. Ubuntu 13.10, Ubuntu 13.04, and Mint 15 users can alternatively install the yasm package from the repository instead of compiling.

cd ~/ffmpeg_sources
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"
make
make install
make distclean
export "PATH=$PATH:$HOME/bin"

libx264

H.264 video encoder. See the x264 Encoding Guide for more information and usage examples. NOTE: FFmpeg’s ./configure requires –enable-libx264 and –extra-libs=”-ldl”.

cd ~/ffmpeg_sources
wget http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
tar xjvf last_x264.tar.bz2
cd x264-snapshot*
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static
make
make install
make distclean

libfdk-aac

AAC audio encoder. See the AAC Encoding Guide for more information and usage examples.

cd ~/ffmpeg_sources
wget -O fdk-aac.zip https://github.com/mstorsjo/fdk-aac/zipball/master
unzip fdk-aac.zip
cd mstorsjo-fdk-aac*
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
make distclean

libmp3lame

MP3 audio encoder.

Most users can install the repository package:

sudo apt-get install libmp3lame-dev

Ubuntu 10.04 and Debian Squeeze users must compile:

sudo apt-get install nasm
cd ~/ffmpeg_sources
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --prefix="$HOME/ffmpeg_build" --enable-nasm --disable-shared
make
make install
make distclean

libopus

Opus audio decoder and encoder.

cd ~/ffmpeg_sources
wget http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz
tar xzvf opus-1.1.tar.gz
cd opus-1.1
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
make distclean

libvpx

VP8/VP9 video encoder and decoder. See the vpx (WebM) Encoding Guide for more information and usage examples.

cd ~/ffmpeg_sources
wget http://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2
tar xjvf libvpx-v1.3.0.tar.bz2
cd libvpx-v1.3.0
./configure --prefix="$HOME/ffmpeg_build" --disable-examples
make
make install
make clean

ffmpeg

Note: Server users should remove --enable-x11grab.

cd ~/ffmpeg_sources
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
export PKG_CONFIG_PATH
./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" \
   --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --extra-libs="-ldl" --enable-gpl \
   --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora \
   --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
make
make install
make distclean
hash -r

Conclusion

Installation is now complete and ffmpeg is now ready for use. Your newly compiled FFmpeg programs are in ~/bin. To use it:

  • Navigate to ~/bin and execute the binary: cd ~/bin && ./ffmpeg -i ~/input.mp4 ~/videos/output.mkv (notice the ./)
  • Or you can use the full path to the binary: /home/yourusername/bin/ffmpeg -i ../input.mp4 ../videos/output.mkv
  • Or if you simply want to just issue the ffmpeg command and have your shell use your compiled binary see the Persistent Environment Variables section below.

Persistent Environment Variables

You can tell your shell (assuming you’re using Bash) to persistantly use your new ffmpeg in ~/bin. The first command will allow you to simply run man ffmpeg to get the FFmpeg man pages. The second command will source ~/.profile which will add ~/bin to your $PATH. In short, the following commands will allow you to simply type ffmpeg and man ffmpeg in your terminal and they will “just work”:

echo "MANPATH_MAP $HOME/bin $HOME/ffmpeg_build/share/man" >> ~/.manpath
. ~/.profile

Note:

  • This may reset custom variables in the current shell session.
  • This assumes you are using the default ~/.profile (and therefore ~/.bashrc).
  • This assumes you are using Bash shell.
  • Sourcing the default ~/.profile will also source ~/.bashrc.
  • You may have to log out and then log in for man ffmpeg to work.
  • Don’t worry: you can undo any of this as shown in Reverting Changes Made by This Guide.

See ​Ubuntu Wiki: Persistent Environment Variables for more info.

Additional Notes

  • See the x264 Encoding Guide for some encoding examples.
  • If you do not see FFmpeg developers in your ffmpeg console output then something went wrong and you’re probably using the ​fake “ffmpeg” from the repository.
  • HTML formatted documentation is available in ~/ffmpeg_build/share/doc/ffmpeg.
  • You can keep the ffmpeg_sources directory if you plan on updating later. See Updating FFmpeg below for more details followed by instructions for reverting all changes made by this guide.

Updating FFmpeg

Development of FFmpeg is active and an occasional update can give you new features and bug fixes. First you need to delete (or move) the old files:

rm -rf ~/ffmpeg_build ~/ffmpeg_sources ~/bin/{ffmpeg,ffprobe,ffserver,vsyasm,x264,yasm,ytasm}

Now just follow the guide from the beginning.


Reverting Changes Made by This Guide

rm -rf ~/ffmpeg_build ~/ffmpeg_sources ~/bin/{ffmpeg,ffprobe,ffserver,vsyasm,x264,yasm,ytasm}
sudo apt-get autoremove autoconf automake build-essential libass-dev libgpac-dev \
  libmp3lame-dev libopus-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev \
  libvorbis-dev libvpx-dev libx11-dev libxext-dev libxfixes-dev texi2html zlib1g-dev
sed -i '/ffmpeg_build/c\' ~/.manpath
hash -r

If You Need Help

Feel free to ask questions at the #ffmpeg IRC channel or the ​ffmpeg-user mailing list.

How to batch convert/multiplex any files with ffmpeg

With ffmpeg can you convert and multiplex almost every video file. And as it’s a command line converter can you batch convert all your files at once with a basic windows/dos script. Like convert all your video files to mp4 with custom ffmpeg commands. Convert all video files audio to wav.

Tools:
ffmpeg

Guide:
Download ffmpeg from http://ffmpeg.zeranoe.com/builds/ and choose latest 32bit Static version.

Extract the ffmpeg.exe from the 7z file with 7zip and put it in same folder as your video files.
Create a folder named newfiles in your video folder.
Click image for larger version

Name:	batch0.png
Views:	269
Size:	63.5 KB
ID:	18041

Start notepad and type the following to convert all your video files to mp4 with h264 video and aac audio. See more examples at the bottom of this guide.

Code:
for %%a in ("*.*") do ffmpeg -i "%%a" -c:v libx264 -preset slow -crf 20 -c:a libvo_aacenc -b:a 128k "newfiles\%%~na.mp4"
pause

Now save it, File->Save as, change to All files under Save as type and save it as batch.bat.
Click image for larger version

Name:	batch1b.png
Views:	227
Size:	73.6 KB
ID:	18071

Just double click on the batch.bat to start converting. You will see any errors in the command line box.
Name:  batch3.png
Views: 3164
Size:  50.4 KB

When it’s done just press enter in the command line window.
Name:  batch2b.png
Views: 3049
Size:  45.0 KB

Done!

Batch ffmpeg examples:

Convert all *.avi files to mp4 with h264 and aac audio

Code:
for %%a in ("*.avi") do ffmpeg -i "%%a" -c:v libx264 -preset slow -crf 20 -c:a libvo_aacenc -b:a 128k "newfiles\%%~na.mp4"
pause

Convert *.mkv files to mp4 and just copy the video and audio streams

Code:
for %%a in ("*.mkv") do ffmpeg -i "%%a" -vcodec copy -acodec copy "newfiles\%%~na.mp4"
pause

Convert *.* files to wav audio

Code:
for %%a in ("*.*") do ffmpeg -i "%%a" "newfiles\%%~na.wav"
pause

Multiplex *.avi and *.wav files with same name to avi

Code:
for %%a in ("*.avi") do ffmpeg -i "%%~na.wav" -i "%%~na.avi" -acodec copy -vcodec copy "newfiles\%%~na.avi"
pause

Other tips:
Put ffmpeg.exe in for example C:\ffmpeg and make the newfiles folder under C:\newfiles and you never have to move around the ffmpeg.exe and make new newfiles folder all the time. You just make the batch.bat file in the video folder.
Your batch.bat script should look this then:

Code:
for %%a in ("*.*") do "C:\ffmpeg\ffmpeg" -i "%%a" -c:v libx264 -preset slow -crf 20 -c:a libvo_aacenc -b:a 128k "C:\newfiles\%%~na.mp4"
pause

More ffmpeg examples:

http://ffmpeg.org/trac/ffmpeg/wiki
http://cfc.kizzx2.com/index.php/muxing-audio-and-video-with-ffmpeg/

ffmpeg commands explained:

http://ffmpeg.org/ffmpeg.html

How to Build an Online Community for Your Small Business

Having previously discussed email list building strategies as a means of reaching new prospects and turning them into customers, it’s now time to look at the benefits on community-building, both online and offline.

These days, most people think of “social media” when they hear “community building,” but forums, membership sites and old-fashioned meet-ups are also good places to promote your brand, share your expertise and attract customers.

Membership Sites: Exclusive Resources, for a Fee

One way of building an online community is by creating a membership site, where you charge a membership fee in exchange for exclusive resources that can range from tutorials to software programs. Just make sure the information that you’ll provide is unique, has high value and is unavailable elsewhere for free.

You can take several approaches with pricing. One is a fixed price, paid up front, for one year of membership. Another is a fixed monthly price. A third option is a low introductory price that will then roll over into a monthly fee.

Using a monthly rate as opposed to a yearly fee will ease sticker shock. For example, a yearly price of $199 could turn off potential customers, but a monthly fee of $19.95 may not—and with the latter fee, you would actually earn more over the course of a year. Monthly rates also make subscribers less likely to cancel their membership, since they don’t see the larger $199 fee recurring once a year. ClickBank has some tools that will allow you to create a recurring fee structure for a membership site.

Founderfly

One site that takes a low-end approach is FounderFly, a site for online marketers that offers videos, marketing tools and forums where members can interact, ask questions and share resources. Initially, you can test the site for a three-day, $1 trial; after that membership is $19.95 per month.

MemberGate

Another membership site option is MemberGate, a program for managing membership or subscription sites. MemberGate itself is a subscription-based service ($197 per month with a three-month minimum) with features that include integrated shopping carts, credit card processing, discussion groups and support for numerous membership plans. Businesses that use MemberGate include publishers, trade associations, hospitality firms and nonprofits.

WishList

Finally, if you’re comfortable with WordPress, you could WishList, which will let you integrate a membership component into your WordPress site.

WishList, which has a one-time cost of $97 for a single-site license and $297 for unlimited domains (with updates available for an additional $47 per year), also offers shopping cart and autoresponder integration, flexible membership options and affiliate program integration, as well as secure RSS feeds.

Forums: Learn From, Share With Peers

Warrior Forum

Online forums offer an opportunity to learn from and share your expertise with peers. The Warrior Forum, a popular destination for Internet marketers, gives users a place to discuss topics such as coding and marketing and to share special offers with the community. The idea here is not only to make sales but to entice people to sign up for your list; once they do, you can market more expensive products to them.

A useful technique for communicating with potential customers in an online forum is using signature files, which typically includes text and images about a product or service and a call to action. Here’s an example:

Signature File

If you participate in numerous forums, this is a great way to increase your visibility and generate interest in your brand. A quick online search will point you to the forums that apply to your market—or you can ask your peers to recommend the sites they frequent.

Social Media: You Can’t Build an Online Community Without It

Social media sites are an obvious target for any brand–large or small–trying to build a community. Sites are free to join, so membership is huge, but that also makes the sites breeding grounds for social media scams, so small business owners need to keep online security basics in mind as they increase their social networking endeavors.

Helping people on LinkedIn can also help you build a following. By working with freelance writers on several LinkedIn forums, I built a list of 70 new subscribers in a single week. I did this by answering questions and directing users to a squeeze page where, they signed up for my email list in exchange for a free report.

Related: 5 LinkedIn Features You May Not (But Should) Know About

Another good community building strategy is to build a community—that is, to form a LinkedIn Group. Launched in 2009, LinkedIn Groups are communities based on common interests, experiences and affiliations. If you are willing to put the time and effort into cultivating a group related to your professional expertise, a LinkedIn Group, over time, could become a significant source of contacts and revenue.

Facebook is popular among many marketing professionals for promoting their products and services as well as participating in Facebook Groups that pertain to their interests. These groups can have quite a wide reach, too; the Internet Marketing Super Friends, for example, has more than 4,200 members.

As for promoting and building your business on Facebook, services such as Get 10,000 Fans and FB Profit Method may be worth a look. Tread carefully, though, and avoid any service through which you “buy” followers, since those new followers could be fake Facebook accounts, spammers or worse. It’s better to have a small, active and loyal group of followers than a large number of followers who aren’t real.

Tips: How to Spot a Social Media Scam
How-to: How and Why to Launch a Business Presence on Twitter

The same goes for Twitter, which is also popular for community-building, posting information about products and services and sharing information about your particular industry. Quality followers who will engage with you (and your followers) are better than fake, spam or porn accounts.

There are a couple other ways to use Twitter to for branding and community building. One way is to have conversations, or Tweet Chats, on a regular basis about a particular topic. All you need to do is designate a hashtag—a phrase with a # in front of it—set a time and spread the word. Another way is to schedule an offline event, known as a Tweetup, during which nearby Twitter followers can meet you in real life at a coffee shop, restaurant or other spot where it’s easy to have a casual conversation.

Additional social media sites to consider include Pinterest, an “online scrapbook” site that recently unveiled Pinterest Business Pages, and Google Plus, a social networking site tightly integrated with other Google products such as Blogger, Picasa and YouTube.

Tips: 14 Ways to Use Pinterest for Business

As you use various online marketing tools to build email lists and communicate with your customers, you’ll start to see support for social networking sites. With iContact, for example, you can send a message to Twitter, Facebook and LinkedIn followers in addition to your list.

As you can see, community building requires legwork both online and off. Depending on your business model, one or more of the strategies listed here—likely, a combination of several—will work best for you. Be sure to research the websites and strategies discussed here before you get started, both to use the tools more effectively and to avoid costly or embarrassing mistakes.

(from www.cio.com)