It is important to know where on the hard disc this notebook is located. The command NotebookDirectory[]will tell us in which directory is our notebook.

NotebookDirectory[]

I find it useful to ask Mathematica for the name of this file. The command NotebookFileName[]will tell us in which directory is our notebook.

NotebookFileName[]

Mathematica also uses the concept of Working Directory. The command Directory[] will tell us the current  Working Directory.

Directory[]

The concept of the Working Directory is important since when we use the command Export[], Mathematica will place the exported file in the  Working Directory.

Therefore we want to set Working Directory to the directory where we want to store exported files. The command SetDirectory[] will set our desired directory as the  Working Directory.  So, what I do next is specific to how I organize files. You should choose your own   Working Directory  to the desired directory of your choice. In the command below you should remove the comment out code  (*  *)  and change the directory to what you want.

(* SetDirectory["C:\\Dropbox\\Work\\myweb\\Courses\\Math_pages\\Math_430\\"] *)

Let us create an animation how a simple string oscillates. The function which describes the oscillations is

Clear[uu]; uu[x_,t_]=Cos[t]Sin[x]

Manipulate[Plot[uu[x,t],{x,0,Pi},PlotStyle->{{Thickness[0.01],RGBColor[0,0,0.5]}},PlotRange->{{-0.1,Pi+0.1},{-1.4,1.4}},AspectRatio->1/5,Frame->True,FrameTicks->{{{},{}},{{},{}}},Axes->False,ImageSize->600],{t,0,2 Pi},ControlPlacement->Top]

To export an animation we need to create a list of many pictures at different times.

OscStr=Table[Plot[uu[x,t],{x,0,Pi},PlotStyle->{{Thickness[0.01],RGBColor[0,0,0.5]}},PlotRange->{{-0.1,Pi+0.1},{-1.4,1.4}},AspectRatio->1/5,Frame->True,FrameTicks->{{{},{}},{{},{}}},Axes->False,ImageSize->600],{t,0,2 Pi,N[Pi/64]}];

Length[OscStr]

We have created a list of 129 pictures. Let us see few of them

{OscStr[[1]],OscStr[[25]],OscStr[[60]],OscStr[[80]]}

One can use the list of pictures to create an animation in Mathematica

ListAnimate[Show[#,ImageSize->600]&/@OscStr,ControlPlacement->Top]

Next I define the list of durations of each time frame that we want

dds=0.1&/@Range[Length[OscStr]]; (* duration of each frame that we want*)

Verify where will the exported file be stored: (We set this earlier with SetDirectory[]

Directory[]

Export["OscStr.gif",OscStr,"AnimationRepetitions"->Infinity,"ImageSize"->600,"DisplayDurations"->dds] ;

Export["OscStr.PNG",OscStr,"AnimationRepetitions"->Infinity,"ImageSize"->600,"DisplayDurations"->dds] ;

The commands below are commented out since they are quite slow. 
If you want to run them, remove the comment out code  (* *)

(* Export["OscStr.mp4",OscStr] ; *)

(* Export["OscStr.mov",OscStr] ; *)

(* Export["OscStr.avi",OscStr] ; *)

I use only gif and png animated files since they are easy to include in html and display on simple webpages.

Unfortunately, I did not find a way of including any of these movie formats into a pdf file. In fact gif and png are easy to include, but pdf shows only the first frame not the animation.

Above I explained how to create and export animations in Mathematica. Much more often we need to export pictures. Like the first picture in our animation

OscStr[[1]]

To export this picture as PNG file we use

Export["OscStrS1.PNG",OscStr[[1]],"ImageSize"->600] ;