1Ppmtompeg User Manual(0)                              Ppmtompeg User Manual(0)
2
3
4

NAME

6       ppmtompeg - encode an MPEG-1 bitstream
7
8

SYNOPSIS

10       ppmtompeg [options] parameter-file
11
12

DESCRIPTION

14       This program is part of Netpbm(1).
15
16       ppmtompeg  produces  an MPEG-1 video stream.  MPEG-1 is the first great
17       video compression method, and is what is used in Video CDs (VCD).  ppm‐
18       tompeg  originated  in the year 1995.  DVD uses a more advanced method,
19       MPEG-2.  There is an even newer method  called  MPEG-4  which  is  also
20       called Divx.  I don't know where one finds that used.
21
22       There's technically a difference between a compression method for video
23       and an actual file (stream) format for a movie, and I don't know if  it
24       can be validly said that the format of the stream ppmtompeg produces is
25       MPEG-1.
26
27       Mencoder from the Mplayer package ⟨http://www.mplayerhq.hu⟩  is  proba‐
28       bly  superior  for  most video format generation needs, if for no other
29       reason than that it is more popular.
30
31       The programming library PM2V http://pm2v.free.fr⟩    generates  MPEG-2
32       streams.
33
34       Use  Mplayer  ⟨http://www.mplayerhq.hu⟩  (not part of Netpbm) to do the
35       reverse conversion: to create a  series  of  PNM  files  from  an  MPEG
36       stream.
37
38       param_file is a parameter file which includes a list of input files and
39       other parameters.  The file is described in detail below.
40
41       To understand this program, you need to understand something about  the
42       complex  MPEG-1  format.  One source of information about this standard
43       format is the section Introduction  to  MPEG  in  the  Compression  FAQ
44http://www.faqs.org/faqs/compression-faq⟩ .
45
46

OPTIONS

48       The  -gop,  -combine_gops, -frames, and -combine_frames options are all
49       mutually exclusive.
50
51
52
53       -stat stat_file
54              This option causes ppmtompeg to append the  statistics  that  it
55              write  to  Standard  Output  to the file stat_file as well.  The
56              statistics use  the  following  abbreviations:  bits  per  block
57              (bpb),  bits  per frame (bpf), seconds per frame (spf), and bits
58              per second (bps).
59
60              These statistics include how many I, P, and B frames there were,
61              and information about compression and quality.
62
63
64
65       -quiet num_seconds
66               causes  ppmtompeg  not to report remaining time more often than
67              every num_seconds seconds (unless the time estimate rises, which
68              will  happen  near  the beginning of the run).  A negative value
69              tells ppmtompeg not to report at all.  0 is the default (reports
70              once  after  each  frame).   Note  that the time remaining is an
71              estimate and does not take into account time to read in frames.
72
73
74       -realquiet
75               causes ppmtompeg to run silently, with the only  screen  output
76              being  errors.   Particularly  useful  when  reading  input from
77              stdin.
78
79
80
81       -no_frame_summary
82               This option prevents ppmtompeg from printing a summary line for
83              each frame
84
85
86       -float_dct
87               forces  ppmtompeg to use a more accurate, yet more computation‐
88              ally expensive version of the DCT.
89
90
91       -gop gop_num
92              causes ppmtompeg to encode only the numbered GOP (first  GOP  is
93              0).   The  parameter  file is the same as for normal usage.  The
94              output file will be the  normal  output  file  with  the  suffix
95              .gop.gop_num.   ppmtompeg  does not output any sequence informa‐
96              tion.
97
98
99       -combine_gops
100               causes ppmtompeg simply to combine some GOP files into a single
101              MPEG  output  stream.   ppmtompeg  inserts a sequence header and
102              trailer.  In this case, the parameter file needs only to contain
103              the  SIZE value, an output file, and perhaps a list of input GOP
104              files (see below).
105
106              If you don't supply a list of input GOP files is used, then ppm‐
107              tompeg  assumes  you're  using  the same parameter file you used
108              when you created the input (with the -gop option) and calculates
109              the  corresponding  gop  filenames  itself.   If this is not the
110              case, you can specify input GOP files in the same manner as nor‐
111              mal input files -- except instead of using INPUT_DIR, INPUT, and
112              END_INPUT, use GOP_INPUT_DIR, GOP_INPUT, and GOP_END_INPUT.   If
113              no input GOP files are specified, then the default is to use the
114              output file name with suffix .gop.gop_num, with gop_num starting
115              from 0, as the input files.
116
117              Thus, unless you're mixing and matching GOP files from different
118              sources, you can simply use the same parameter file for creating
119              the  GOP  files  (-gop)  and for later turning them into an MPEG
120              stream (-combine_gops).
121
122
123
124       -frames first_frame last_frame
125              This option causes ppmtompeg to encode only the frames  numbered
126              first_frame to last_frame, inclusive.  The parameter file is the
127              same as for normal usage.  The output will be placed in separate
128              files,  one per frame, with the file names being the normal out‐
129              put file name with the suffix .frame.frame_num.  No  GOP  header
130              information  is  output.   (Thus,  the  parameter  file need not
131              include the GOP_SIZE value)
132
133              Use ppmtompeg -combine_frames to combine these frames later into
134              an MPEG stream.
135
136
137
138       -combine_frames
139               This  option causes ppmtompeg simply to combine some individual
140              MPEG frames (such as you might have created with an earlier  run
141              of  ppmtompeg  -frames) into a single MPEG stream.  Sequence and
142              GOP headers are  inserted  appropriately.   In  this  case,  the
143              parameter  file  needs  to  contain  only  the  SIZE  value, the
144              GOP_SIZE value, an output file, and  perhaps  a  list  of  frame
145              files (see below).
146
147              The  parameter  file  may  specify input frame files in the same
148              manner  as  normal  input  files  --  except  instead  of  using
149              INPUT_DIR,    INPUT,   and   END_INPUT,   use   FRAME_INPUT_DIR,
150              FRAME_INPUT, and FRAME_END_INPUT. If no input  frame  files  are
151              specified,  then the default is to use the output file name with
152              suffix .frame.frame_num, with frame_num starting from 0, as  the
153              input files.
154
155
156
157
158       -nice  This  option  causes  ppmtompeg  to  run  any  remote  processes
159              "nicely," i.e.  at low priority.  (This is relevant only if  you
160              are running ppmtompeg in parallel mode.  Otherwise, there are no
161              remote processes).  See 'man nice.'
162
163
164       -max_machines num_machines
165              This option causes ppmtompeg to use no  more  than  num_machines
166              machines as slaves for use in parallel encoding.
167
168
169       -snr   This  option  causes  ppmtompeg  to  include the signal-to-noise
170              ratio in the reported statistics.  Prints SNR (Y U V)  and  peak
171              SNR  (Y  U  V)  for  each frame.  In summary, prints averages of
172              luminance only (Y).  SNR is defined as 10*log(variance of origi‐
173              nal/variance    of    error).     Peak   SNR   is   defined   as
174              20*log(255/RMSE).  Note that ppmtompeg runs a little slower when
175              you use this option.
176
177
178       -mse   This  option  causes  ppmtompeg to report the mean squared error
179              per block.  It also automatically reports  the  quality  of  the
180              images, so there is no need to specify -snr then.
181
182
183       -bit_rate_info rate_file
184               This option makes ppmtompeg write bit rate information into the
185              file rate_file.  Bit rate information is  bits  per  frame,  and
186              also bits per I-frame-to-I-frame.
187
188
189       -mv_histogram
190               This option causes ppmtompeg to print a histogram of the motion
191              vectors as part of statistics.  There are  three  histograms  --
192              one for P frame, one for forward B frame, and one for backward B
193              frame motion vectors.
194
195              The output is in the form of a matrix, each entry  corresponding
196              to  one  motion  vector  in the search window. The center of the
197              matrix represents (0,0) motion vectors.
198
199
200       -debug_sockets
201              This option causes ppmtompeg to print to  Standard  Output  mes‐
202              sages  that  narrate the communication between the machines when
203              you run ppmtompeg in parallel mode ⟨#parallel⟩ .
204
205
206       -debug_machines
207              This option causes ppmtompeg to print to  Standard  Output  mes‐
208              sages that narrate the progress of the conversion on the various
209              machines when you run ppmtompeg in parallel mode ⟨#parallel⟩ .
210
211
212
213

PARAMETER FILE

215       The parameter file must contain the following lines (except when  using
216       the -combine_gops or -combine_frames options):
217
218
219
220
221       PATTERN pattern
222              This  statement  specifies the pattern (sequence) of I frames, P
223              frames, and B frames.  pattern is just a sequence of the letters
224              I, P, and B with nothing between.  Example:
225
226                  PATTERN IBBPBBPBBPBBPBB
227
228              See I Frames, P Frames, B Frames ⟨#ipb⟩ .
229
230
231       OUTPUT output file
232              This names the file where the output MPEG stream goes.
233
234
235       INPUT_DIR directory
236              This  statement tells where the input images (frames) come from.
237              If each frame is in a separate file, directory is the  directory
238              where  they  all  are.   You  may  use . to refer to the current
239              directory.  A null directory refers to the root directory of the
240              system file tree.
241
242              To  have  ppmtompeg  read  all the frames serially from Standard
243              Input, specify
244                  INPUT_DIR stdin
245
246
247       INPUT  This line must be followed by a list of the input files (in dis‐
248              play order) and then the line END_INPUT.
249
250              There  are  three  types  of  lines between INPUT and END_INPUT.
251              First, a line may simply be the name of an input file.   Second,
252              the  line  may  be  of  the  form  single_star_expr [x-y].  sin‐
253              gle_star_expr can have a single * in it.  It is replaced by  all
254              the  numbers  between  x  and y inclusive.  So, for example, the
255              line tennis*.ppm [12-15] refers to the files tennis12.ppm,  ten‐
256              nis13.ppm, tennis14.ppm, tennis15.ppm.
257
258              Uniform  zero-padding  occurs,  as  well.  For example, the line
259              football.*.ppm [001-130] refers to the  files  football.001.ppm,
260              football.002.ppm,  ..., football.009.ppm, football.010.ppm, ...,
261              football.130.ppm.
262
263              The third type of line is: single_star_expr [x-y+s],  where  the
264              line  is  treated  exactly  as  above, except that we skip by s.
265              Thus, the line football.*.ppm [001-130+4] refers  to  the  files
266              football.001.ppm,   football.005.ppm,   football.009.ppm,  foot‐
267              ball.013.ppm, etc.
268
269              Furthermore, a line may specify a shell command  to  execute  to
270              generate lines to be interpreted as described above, as if those
271              lines were in the parameter file instead.  Use back ticks,  like
272              in the Bourne Shell, like this:
273
274                  `cat myfilelist`
275
276              If  input  is from Standard Input (per the INPUT_DIR statement),
277              ppmtompeg ignores the INPUT/END_INPUT block, but it  still  must
278              be present.
279
280
281       BASE_FILE_FORMAT {PPM | PNM | YUV |
282                   JPEG  |  JMOVIE}  ppmtompeg must convert all input files to
283              one of the following formats as a first step of processing: PNM,
284              YUV,  JPEG(v4),  or  JMOVIE.   (The conversion may be trivial if
285              your input files are already in one  of  these  formats).   This
286              line  specifies  which  of  the four formats.  PPM is actually a
287              subset of PNM.  The separate specification is allowed for  back‐
288              ward compatibility.  Use PNM instead of PPM in new applications.
289
290
291       INPUT_CONVERT conversion_command
292              You  must specify how to convert a file to the base file format.
293              If no conversion is necessary, then you would just say:
294
295                   INPUT_CONVERT *
296
297              Otherwise, conversion_command is a shell command that causes  an
298              image  in  the format your specified with BASE_FILE_FORMAT to be
299              written to Standard Output.  ppmtompeg executes the command once
300              for  each  line  between INPUT and END_INPUT (which is normally,
301              but not necessarily, a file name).  In the  conversion  command,
302              ppmtompeg replaces each '*' with the contents of that line.
303
304                   If you had a bunch of gif files, you might say:
305                   INPUT_CONVERT giftopnm *
306
307                   If  you  have  a  bunch of separate a.Y, a.U, and a.V files
308              (where
309                   the U and V have already been subsampled), then  you  might
310              say:
311
312                   INPUT_CONVERT cat *.Y *.U *.V
313
314              Input conversion is not allowed with input from stdin, so use
315
316                   INPUT_CONVERT *
317
318              as described above.
319
320
321       SIZE widthxheight
322
323              width  and height are the width and height of each frame in pix‐
324              els.
325
326              When ppmtompeg can get this information  from  the  input  image
327              files, it ignores the SIZE parameter and you may omit it.
328
329              When  the image files are in YUV format, the files don't contain
330              dimension information, so SIZE is required.
331
332              When ppmtompeg is running in parallel mode, not all of the  pro‐
333              cesses in the network have access to the image files, so SIZE is
334              required and must give the same dimensions as  the  input  image
335              files.
336
337
338       YUV_SIZE widthxheight
339              This is an obsolete synonym of SIZE.
340
341
342       YUV_FORMAT {ABEKAS | PHILLIPS | UCB |
343                                    EYUV  |  pattern}  This is meaningful only
344              when BASE_FILE_FORMAT specifies  YUV  format,  and  then  it  is
345              required.  It specifies the sub-format of the YUV class.
346
347
348
349       GOP_SIZE n
350              n  is  the number of frames in a Group of Pictures.  Except that
351              because a GOP must start with an I frame, ppmtompeg makes a  GOP
352              as  much  longer  than n as it has to to make the next GOP start
353              with an I frame.
354
355              Normally, it makes sense to make your GOP  size  a  multiple  of
356              your  pattern  length  (the  latter is determined by the PATTERN
357              parameter file statement).
358
359              See Group Of Pictures ⟨#gop⟩ .
360
361
362       SLICES_PER_FRAME n
363              n is roughly the number of slices per frame.  Note, at least one
364              MPEG player may complain if slices do not start at the left side
365              of an image.  To ensure this does not happen, make sure the num‐
366              ber of rows is divisible by SLICES_PER_FRAME.
367
368
369       PIXEL {FULL | HALF}
370              use  half-pixel  motion  vectors,  or just full-pixel ones It is
371              usually  important  that  you  use  half-pixel  motion  vectors,
372              because  it  results  in both better quality and better compres‐
373              sion.
374
375
376
377       RANGE n
378              Use a search range of n pixels in each of  the  four  directions
379              from  a  subject  pixel.   (So the search window is a square n*2
380              pixels on a side).
381
382
383       PSEARCH_ALG {EXHAUSTIVE | TWOLEVEL |
384                   SUBSAMPLE | LOGARITHMIC}  This  statement  tells  ppmtompeg
385              what kind of search
386                  technique  (algorithm)  to use for P frames.  You select the
387              desired
388                  combination of speed and compression.  EXHAUSTIVE gives the
389                  best compression, but LOGARITHMIC is the fastest.
390                  TWOLEVEL is an exhaustive full-pixel search, followed by a
391                  local half- pixel search around the best  full-pixel  vector
392              (the
393                  PIXEL option is ignored for this search technique).
394
395
396       BSEARCH_ALG {SIMPLE | CROSS2 | EXHAUSTIVE}
397              This statement tells ppmtompeg what kind of search
398                  technique (algorithm) to use for B frames.  SIMPLE means
399                  find best forward and backward vectors, then interpolate.
400                  CROSS2 means find those two vectors, then see what backward
401                  vector best matches the best forward vector, and vice versa.
402                  EXHAUSTIVE does an n-squared search and is
403                  extremely slow in relation to the others (CROSS2
404                  is about half as fast as SIMPLE).
405
406
407       IQSCALE n
408              Use n as the qscale for I frames.
409                   See Qscale ⟨#qscale⟩ .
410
411
412       PQSCALE n
413              Use n as the qscale for P frames.
414                   See Qscale ⟨#qscale⟩ .
415
416
417       BQSCALE n
418              Use n as the qscale for B frames.
419                   See Qscale ⟨#qscale⟩ .
420
421
422       REFERENCE_FRAME {ORIGINAL | DECODED}
423              This  statement  determines  whether ppmtompeg uses the original
424              images or the decoded  images  when  computing  motion  vectors.
425              Using  decoded  images  is more accurate and should increase the
426              playback quality of the output, but it makes the  encoding  take
427              longer and seems to give worse compression.  It also causes some
428              complications with parallel encoding. (see the section on paral‐
429              lel  encoding).   One  thing you can do as a trade-off is select
430              ORIGINAL here, and lower the qscale (see QSCALE if  the  quality
431              is not good enough.
432
433              Original or Decoded? (Normalized)
434
435              ────────────────────────────────────────────────────────────────────
436              Reference   Compression   Speed   Quality I   Quality P   Quality B
437                Decoded      1000       1000      1000         969         919
438               Original       885       1373      1000         912         884
439
440
441
442
443
444
445       The following lines are optional:
446
447
448
449
450       FORCE_ENCODE_LAST_FRAME
451              This statement is obsolete.  It does nothing.
452
453              Before  Netpbm 10.26 (January 2005), ppmtompeg would drop trail‐
454              ing B frames from your movie, since a movie can't end with  a  B
455              frame.   (See  I  Frames, P Frames, B Frames ⟨#ipb⟩ .  You would
456              have to specify FORCE_ENCODE_LAST_FRAME to stop that  from  hap‐
457              pening and get the same function that ppmtompeg has today.
458
459
460
461       NIQTABLE
462              This  statement specifies a custom non-intra quantization table.
463              If you don't specify this statement, ppmtompeg  uses  a  default
464              non-intra quantization table.
465
466              The 8 lines immediately following NIQTABLE specify the quantiza‐
467              tion table.  Each line defines a table row  and  consists  of  8
468              integers, whitespace-delimited, which define the table columns.
469
470
471       IQTABLE
472              This  is  analogous  to NIQTABLE, but for the intra quantization
473              table.
474
475
476       ASPECT_RATIO ratio
477              This statement specifies the aspect ratio for ppmtompeg to spec‐
478              ify in the MPEG output.  I'm not sure what this is used for.
479
480              ratio  must  be  1.0,  0.6735,  0.7031,  0.7615, 0.8055, 0.8437,
481              0.8935, 0.9157,  0.9815,  1.0255,  1.0695,  1.0950,  1.1575,  or
482              1.2015.
483
484
485       FRAME_RATE rate
486              This  specifies  the  frame rate for ppmtompeg to specify in the
487              MPEG output.  Some players use this value to determine the play‐
488              back rate.
489
490              rate must be 23.976, 24, 25, 29.97, 30, 50, 59.94, or 60.
491
492
493       BIT_RATE rate
494              This  specifies  the bit rate for Constant Bit Rate (CBR) encod‐
495              ing.
496
497              rate must be an integer.
498
499
500       BUFFER_SIZE size
501              This specifies the value ppmtompeg is to  specify  in  the  MPEG
502              output for the Video Buffering Verifier (VBV) buffer size needed
503              to decode the sequence.
504
505              A Video Verifying Buffer is a buffer in which  a  decoder  keeps
506              the  decoded  bits  in  order  to  match the uneven speed of the
507              decoding with the required constant playback speed.
508
509              As ppmtompeg  encodes  the  image,  it  simulates  the  decoding
510              process  in  terms  of how many bits would be in the VBV as each
511              frame gets decoded, assuming a VBV of the size you indicate.
512
513              If  you  specify  the  WARN_VBV_UNDERFLOW  statement,  ppmtompeg
514              issues a warning each time the simulation underflows the buffer,
515              which suggests that an underflow would occur on playback,  which
516              suggests the buffer is too small.
517
518              If you specify the WARN_VBV_OVERFLOW statement, ppmtompeg issues
519              a warning each time the simulation overflows the  buffer,  which
520              suggests  that  an  overflow would occur on playback, which sug‐
521              gests the buffer is too small.
522
523
524       WARN_VBV_UNDERFLOW
525
526       WARN_VBV_OVERFLOW
527              See BUFFER_SIZE.
528
529              These options were new in Netpbm 10.26 (January  2005).   Before
530              that, ppmtompeg issued the warnings always.
531
532
533
534
535              The following statements apply only to parallel operation:
536
537
538
539
540       PARALLEL
541              This statement, paired with END PARALLEL, is what causes ppmtom‐
542              peg  to  operate  in  parallel  mode.   See  Parallel  Operation
543              ⟨#parallel⟩ .
544
545
546       END PARALLEL
547              This goes with PARALLEL.
548
549
550       PARALLEL_TEST_FRAMES n
551              The  master starts off by measuring each slave's speed.  It does
552              this by giving each slave n frames to encode and noting how long
553              the  slave  takes  to  finish.   These are not just test frames,
554              though -- they're real frames and the results become part of the
555              output.   ppmtompeg  is  old and measures time in undivided sec‐
556              onds, so to get useful timings, specify enough  frames  that  it
557              will  take  at  least 5 seconds to process them.  The default is
558              10.
559
560              If you specify FORCE_I_ALIGN, ppmtompeg will increase  the  test
561              frames value enough to maintain the alignment.
562
563              If  there aren't enough frames for every slave to have the indi‐
564              cated number of test frames, ppmtompeg  will  give  some  slaves
565              fewer.
566
567
568
569       PARALLEL_TIME_CHUNKS t
570              When  you  specify  this  statement, the master attempts to feed
571              work to the slaves in chunks that take t seconds to process.  It
572              uses  the speed measurement it made when it started up (see PAR‐
573              ALLEL_TEST_FRAMES) to decide how  many  frames  to  put  in  the
574              chunk.   This statement obviously doesn't affect the first batch
575              of work sent to each slave, which is the one used to measure the
576              slave's speed.
577
578              Smaller  values  of  t  increase communication, but improve load
579              balancing.  The default is 30 seconds.
580
581              You  may  specify  only  one  of  PARALLEL_TIME_CHUNKS,   PARAL‐
582              LEL_CHUNK_TAPER,  and PARALLEL_PERFECT.  PARALLEL_CHUNK_TAPER is
583              usually best.
584
585
586       PARALLEL_CHUNK_TAPER
587              When you specify this statement,  the  master  distributes  work
588              like  with  PARALLEL_TIME_CHUNKS, except that the master chooses
589              the number of seconds for the chunks.  It starts  with  a  large
590              number  and, as it gets closer to finishing the job, reduces it.
591              That way, it reduces scheduling overhead when precise scheduling
592              isn't  helpful,  but still prevents a slave from finishing early
593              after all the work has already been  handed  out  to  the  other
594              slaves, and then sitting idle while there's still work to do.
595
596              You   may  specify  only  one  of  PARALLEL_TIME_CHUNKS,  PARAL‐
597              LEL_CHUNK_TAPER, and PARALLEL_PERFECT.  PARALLEL_CHUNK_TAPER  is
598              usually best.
599
600
601
602       PARALLEL_PERFECT
603              If this statement is present, ppmtompeg schedules on the assump‐
604              tion that each machine is about the same speed.  The master will
605              simply  divide  up  the frames evenly between the slaves -- each
606              slave gets the same number of frames.  If some slaves are faster
607              than  others,  they  will finish first and remain idle while the
608              slower slaves continue.
609
610              This has the advantage of minimal  scheduling  overhead.   Where
611              slaves  have  different speeds, though, it makes inefficient use
612              of the fast ones.  Where slaves are the same speed, it also  has
613              the  disadvantage that they all finish at the same time and feed
614              their output to the single Combine  Server  in  a  burst,  which
615              makes  less  efficient  use  of  the Combine Server and thus can
616              increase the total elapsed time.
617
618              You  may  specify  only  one  of  PARALLEL_TIME_CHUNKS,   PARAL‐
619              LEL_CHUNK_TAPER,  and PARALLEL_PERFECT.  PARALLEL_CHUNK_TAPER is
620              usually best.
621
622
623       RSH remote_shell_command
624              ppmtompeg executes the  shell  command  remote_shell_command  to
625              start a process on another machine.  The default command is rsh,
626              and whatever command you specify must have compatible semantics.
627              ssh  is  usually  compatible.  The command ppmtompeg uses is one
628              like this: ssh remote.host.com -l username shellcommand.
629
630              Be sure to set up .rhosts files or SSH key authorizations  where
631              needed.  Otherwise, you'll have to type in passwords.
632
633              On  some  HP machines, rsh is the restricted shell, and you want
634              to specify remsh.
635
636
637       FORCE_I_ALIGN
638              This statement forces each slave to encode  a  chunk  of  frames
639              which  is a multiple of the pattern length (see PATTERN).  Since
640              the first frame in any pattern is an I frame, this  forces  each
641              chunk encoded by a slave to begin with an I frame.
642
643              This document used to say there was an argument to FORCE_I_ALIGN
644              which was the number of frames  ppmtompeg  would  use  (and  was
645              required to be a multiple of the pattern length).  But ppmtompeg
646              has apparently always ignored that argument, and it does now.
647
648
649       KEEP_TEMP_FILES
650              This statement causes ppmtompeg  not  to  delete  the  temporary
651              files  it uses to transmit encoded frames to the combine server.
652              This means you will be left with a file for each frame, the same
653              as you would get with the -frames option.
654
655              This is mostly useful for debugging.
656
657              This  works only if you're using a shared filesystem to communi‐
658              cate between the servers.
659
660              This option was new in Netpbm 10.26 (January 2005).
661
662
663
664
665
666   Parameter File Notes
667        If you use the -combine_gops option, then you need to specify only the
668       SIZE and OUTPUT values in the parameter file.  In addition, the parame‐
669       ter file may specify input GOP files in the same manner as normal input
670       files  --  except instead of using INPUT_DIR, INPUT, and END_INPUT, use
671       GOP_INPUT_DIR, GOP_INPUT, and GOP_END_INPUT.  If you specify  no  input
672       GOP  files,  then  ppmtompeg  uses by default the output file name with
673       suffix .gop.gop_num, with gop_num starting from 0, as the input files.
674
675       If you use the -combine_frames option, then you need  to  specify  only
676       the  SIZE, GOP_SIZE, and OUTPUT values in the parameter file.  In addi‐
677       tion, the parameter file may specify input frame files in the same man‐
678       ner  as normal input files -- except instead of using INPUT_DIR, INPUT,
679       and END_INPUT, use FRAME_INPUT_DIR, FRAME_INPUT,  and  FRAME_END_INPUT.
680       If  no  input frame files are specified, then the default is to use the
681       output file name with suffix .frame.frame_num, with frame_num  starting
682       from 0, as the input files.
683
684       Any  number  of spaces and tabs may come between each option and value.
685       Lines beginning with # are ignored.  Any other lines are ignored except
686       for those between INPUT and END_INPUT.  This allows you to use the same
687       parameter file  for  normal  usage  and  for  -combine_gops  and  -com‐
688       bine_frames.
689
690       The  file  format  is case-sensitive so all keywords should be in upper
691       case.
692
693       The statements may appear in any order, except that the order within  a
694       block statement (such as INPUT ... END INPUT) is significant.
695
696       ppmtompeg  is  prepared  to  handle up to 16 B frames between reference
697       frames when encoding with input from stdin.  (To build a modified  ppm‐
698       tompeg  with a higher limit, change the constant B_FRAME_RUN in frame.c
699       and recompile).
700
701

GENERAL USAGE INFORMATION

703   Qscale
704       The quantization scale values (qscale) give a trade-off between quality
705       and  compression.  Using different Qscale values has very little effect
706       on speed.  The qscale values can be set separately  for  I,  P,  and  B
707       frames.
708
709       You  select  the  qscale  values  with the IQSCALE, PQSCALE, and BSCALE
710       parameter file statements.
711
712       A qscale value is an integer from 1 to 31.  Larger numbers give  better
713       compression,  but worse quality.  In the following, the quality numbers
714       are peak signal-to-noise ratio,  defined  as:  signal-to-noise  formula
715       where MSE is the mean squared error.
716
717
718       Flower garden tests:
719
720       Qscale vs Quality
721
722       ────────────────────────────────────────
723       Qscale   I Frames   P Frames   B Frames
724            1       43.2       46.3       46.5
725            6       32.6       34.6       34.3
726           11       28.6       29.5       30.0
727           16       26.3       26.8       28.6
728           21       24.7       25.0       27.9
729           26       23.5       23.9       27.5
730           31       22.6       23.0       27.3
731
732       Qscale vs Compression
733
734       ────────────────────────────────────────
735       Qscale   I Frames   P Frames   B Frames
736            1          2          2          2
737            6          7         10         15
738           11         11         18         43
739           16         15         29         97
740           21         19         41        173
741           26         24         56        256
742           31         28         73        330
743
744
745
746   Search Techniques
747       There  are several different motion vector search techniques available.
748       There are different techniques available for P frame search and B frame
749       search.  Using different search techniques present little difference in
750       quality, but a large difference in compression and speed.
751
752
753       There are 4 types of P frame search: Exhaustive,  TwoLevel,  SubSample,
754       and Logarithmic.
755
756
757       There are 3 types of B frame search: Exhaustive, Cross2, and Simple.
758
759       The  recommended  search  techniques are TwoLevel and Logarithmic for P
760       frame search, and Cross2 and Simple for B frame search. Here  are  some
761       numbers comparing the different search methods:
762
763       P frame Motion Vector Search (Normalized)
764
765       ─────────────────────────────────────────────────────────────────────
766         Technique   Compression    1   Speed          2   Quality        3
767                     ⟨#smallbetter⟩     ⟨#largefaster⟩     ⟨#largebetter⟩
768        Exhaustive         1000               1000               1000
769         SubSample         1008               2456               1000
770          TwoLevel         1009               3237               1000
771
772       Logarithmic         1085               8229               998
773
774       B frame Motion Vector Search (Normalized)
775
776       ────────────────────────────────────────────────────────────────────
777        Technique   Compression    1   Speed          2   Quality        3
778                    ⟨#smallbetter⟩     ⟨#largefaster⟩     ⟨#largebetter⟩
779       Exhaustive         1000               1000               1000
780           Cross2         975                1000               996
781           Simple         938                1765               991
782
783       1Smaller numbers are better compression.
784
785       2Larger numbers mean faster execution.
786
787       3Larger numbers mean better quality.
788
789       For  some  reason,  Simple  seems  to  give  better compression, but it
790       depends on the image sequence.
791
792       Select the search  techniques  with  the  PSEARCH_ALG  and  BSEARCH_ALG
793       parameter file statements.
794
795
796
797   Group Of Pictures (GOP)
798       A Group of Pictures (GOP) is a roughly independently decodable sequence
799       of frames.  An MPEG video stream is made of one or more GOP's.  You may
800       specify how many frames should be in each GOP with the GOP_SIZE parame‐
801       ter file statement.  A GOP always starts with an I frame.
802
803       Instead of encoding an entire sequence, you can encode  a  single  GOP.
804       To  do  this,  use  the  -gop  command  option.  You can later join the
805       resulting GOP files at any time by running  ppmtompeg  with  the  -com‐
806       bine_gops command option.
807
808
809
810   Slices
811       A  slice  is  an independently decodable unit in a frame.  It can be as
812       small as one macroblock, or it can be as big as the entire frame.  Bar‐
813       ring  transmission  error,  adding  slices  does  not change quality or
814       speed; the only effect is slightly worse compression.  More slices  are
815       used  for noisy transmission so that errors are more recoverable. Since
816       usually errors are not such a problem, we usually just  use  one  slice
817       per frame.
818
819
820       Control  the slice size with the SLICES_PER_FRAME parameter file state‐
821       ment.
822
823       Some MPEG playback systems require that each  slice  consist  of  whole
824       rows  of  macroblocks.  If you are encoding for this kind of player, if
825       the height  of  the  image  is  H  pixels,  then  you  should  set  the
826       SLICES_PER_FRAME  to  some  number which divides H/16.  For example, if
827       the image is 240 pixels (15 macroblocks) high, then you should use only
828       15, 5, 3, or 1 slices per frame.
829
830
831       Note:  these  MPEG  playback  systems  are really wrong, since the MPEG
832       standard says this doesn't have to be so.
833
834
835
836
837   Search Window
838       The search window is the window in which ppmtompeg searches for  motion
839       vectors.   The  window  is  a  square.  You can specify the size of the
840       square, and whether to allow half-pixel motion vectors or not, with the
841       RANGE and PIXEL parameter file statements.
842
843
844   I Frames, P Frames, B Frames
845       In MPEG-1, a movie is represented as a sequence of MPEG frames, each of
846       which is an I Frame, a P Frame, or  a  B  Frame.   Each  represents  an
847       actual  frame  of  the movie (don't get confused by the dual use of the
848       word "frame."  A movie frame is a graphical image.  An MPEG frame is  a
849       set of data that describes a movie frame).
850
851       An  I  frame  ("intra"  frame)  describes a movie frame in isolation --
852       without respect to any other frame in the movie.  A P  frame  ("predic‐
853       tive"  frame) describes a movie frame by describing how it differs from
854       the movie frame described by the latest preceding I  or P frame.   A  B
855       frame ("bidirectional" frame) describes a movie frame by describing how
856       it differs from the the movie frames described by the nearest  I  or  P
857       frame before and after it.
858
859       Note  that  the  first frame of a movie must be described by an I frame
860       (because there is no previous movie frame) and  the  last  movie  frame
861       must  be  described  by an I or P frame (because there is no subsequent
862       movie frame).
863
864       Beyond that, you can choose  which  frames  are  represented  by  which
865       types.   You  specify  a  pattern,  such  as IBPBP and ppmtompeg simply
866       repeats it over and over throughout the  movie.   The  pattern  affects
867       speed,  quality,  and stream size.  Here is a chart which shows some of
868       the trade-offs:
869
870       Comparison of I/P/B Frames (Normalized)
871
872       ────────────────────────────────────
873       Frame Type   Size   Speed   Quality
874         I frames   1000   1000     1000
875         P frames   409     609      969
876         B frames    72     260      919
877
878       (this is with constant qscale)
879
880
881       A standard sequence is IBBPBBPBBPBBPBB.
882
883
884       Select the sequence with the PATTERN parameter file statement.
885
886       Since the last MPEG frame cannot be a B frame (see above), if the  pat‐
887       tern  you  specify  indicates a B frame for the last movie frame of the
888       movie, ppmtompeg makes it an I frame instead.
889
890       Before Netpbm 10.26 (January 2005), ppmtompeg instead drops the  trail‐
891       ing  B  frames  by  default,  and  you need the FORCE_ENCODE_LAST_FRAME
892       parameter file statement to make it do this.
893
894       The MPEG frames don't appear in the MPEG-1 stream  in  the  same  order
895       that the corresponding movie frames appear in the movie -- the B frames
896       come after the I and P frames on which they are based.  For example, if
897       the  movie  is  4 frames that you will represent with the pattern IBBP,
898       the MPEG-1 stream will start with an I frame describing movie frame  0.
899       The next frame in the MPEG-1 stream is a P frame describing movie frame
900       3.  The last two frames in the MPEG-1 stream are  B  frames  describing
901       movie frames 1 and 2, respectively.
902
903
904
905   Specifying Input and Output Files
906       Specify  the  input  frame images with the INPUT_DIR, INPUT, END_INPUT,
907       BASE_FILE_FORMAT, SIZE, YUV_FORMAT  and  INPUT_CONVERT  parameter  file
908       statements.
909
910       Specify the output file with the OUTPUT parameter file statement.
911
912
913
914   Statistics
915       ppmtompeg can generate a variety of statistics about the encoding.  See
916       the  -stat,  -snr,  -mv_histogram,   -quiet,   -no_frame_summary,   and
917       -bit_rate_info options.
918
919
920

PARALLEL OPERATION

922       You  can  run ppmtompeg on multiple machines at once, encoding the same
923       MPEG stream.  When you do, the machines are used as shown in  the  fol‐
924       lowing diagram.  We call this 'parallel mode.'
925
926       ppmtompeg-par.gif
927
928       To do parallel processing, put the statement
929
930           PARALLEL
931
932       in  the  parameter  file,  followed  by  a listing of the machines, one
933       machine per line, then
934
935           END_PARALLEL
936
937       Each of the machine lines must be in one of two forms.  If the  machine
938       has filesystem access to the input files, then the line is:
939
940       machine user executable
941
942       The executable is normally ppmtompeg (you may need to give the complete
943       path if you've built for different architectures).  If the machine does
944       not have filesystem access to the input files, the line is:
945
946       REMOTE machine user executable parameter file
947
948       The  -max_machines command option limits the number of machines ppmtom‐
949       peg will use.  If you specify more machines in the parameter file  than
950       -max_machines  allows,  ppmtompeg  uses only the machines listed first.
951       This is handy if you want to experiment with different amounts of  par‐
952       allelism.
953
954       In  general,  you  should use full path file names when describing exe‐
955       cutables and parameter files.  This includes the parameter  file  argu‐
956       ment on the original invocation of ppmtompeg.
957
958       All file names must be the same on all systems (so if e.g. you're using
959       an NFS filesystem, you must make sure it is mounted at the same  mount‐
960       point on all systems).
961
962       Because  not  all  of the processes involved in parallel operation have
963       easy access to the input files, you must  specify  the  SIZE  parameter
964       file statement when you do parallel operation.
965
966       The  machine  on  which  you  originally invoke ppmtompeg is the master
967       machine.  It hosts a 'combine server,', a 'decode server,' and a number
968       of 'i/o servers,' all as separate processes.  The other machines in the
969       network (listed in the parameter file) are slave machines.  Each  hosts
970       a  single  process  that continuously requests work from the master and
971       does it.  The slave process does the computation to encode MPEG frames.
972       It processes frames in batches identified by the master.
973
974       The  master  uses  a remote shell command to start a process on a slave
975       machine.  By default, it uses an rsh shell command to do this.  But use
976       the  RSH  parameter  file statement to control this.  The shell command
977       the master executes remotely is ppmtompeg, but with options to indicate
978       that it is to perform slave functions.
979
980       The  various  machines  talk  to each other over TCP connections.  Each
981       machine finds and binds to a free TCP port number and tells  its  part‐
982       ners the port number.  These port numbers are at least 2048.
983
984       Use  the  PARALLEL_TEST_FRAMES, PARALLEL_TIME_CHUNKS, and PARALLEL_PER‐
985       FECT parameter file statements to control the way the master divides up
986       work among the slaves.
987
988       Use  the  -nice  command  option  to  cause  all slave processes to run
989       "nicely," i.e. as low priority processes.  That way,  this  substantial
990       and  long-running  CPU load will have minimal impact on other, possibly
991       interactive, users of the systems.
992
993

SPEED

995       Here is a look at ppmtompeg speed, in single-node (not parallel) opera‐
996       tion:
997
998       Compression Speed
999
1000
1001       ───────────────────────────────────────
1002       Machine Type   Macroblocks per second1
1003        HP 9000/755             280
1004       DEC 3000/400             247
1005        HP 9000/750             191
1006           Sparc 10             104
1007           DEC 5000             68
1008       1A macroblock is a 16x16 pixel square
1009
1010       The measurements in the table are with inputs and outputs via a conven‐
1011       tional locally  attached  filesystem.   If  you  are  using  a  network
1012       filesystem  over  a single 10 MB/s Ethernet, that constrains your speed
1013       more than your CPU speed.  In that case, don't  expect  to  get  better
1014       than 4 or 5 frames per second no matter how fast your CPUs are.
1015
1016       Network  speed is even more of a bottleneck when the slaves do not have
1017       filesystem access to the input files -- i.e. you declare them REMOTE.
1018
1019       Where I/O is the bottleneck, size of the input frames can  make  a  big
1020       difference.   So  YUV input is better than PPM, and JPEG is better than
1021       both.
1022
1023       When you're first trying to get parallel mode working, be sure  to  use
1024       the  -debug_machines  option  so  you  can  see what's going on.  Also,
1025       -debug_sockets can help you diagnose communication problems.
1026
1027
1028

AUTHORS

1030       ·      Kevin  Gong  -  University   of   California,   Berkeley,   kev‐
1031              ing@cs.berkeley.edu
1032
1033
1034       ·      Ketan   Patel   -   University  of  California,  Berkeley,  kpa‐
1035              tel@cs.berkeley.edu
1036
1037
1038       ·      Dan  Wallach  -  University  of  California,   Berkeley,   dwal‐
1039              lach@cs.berkeley.edu
1040
1041
1042       ·      Darryl   Brown   -  University  of  California,  Berkeley,  dar‐
1043              ryl@cs.berkeley.edu
1044
1045
1046       ·      Eugene   Hung   -   University    of    California,    Berkeley,
1047              eyhung@cs.berkeley.edu
1048
1049
1050       ·      Steve    Smoot    -    University   of   California,   Berkeley,
1051              smoot@cs.berkeley.edu
1052
1053
1054
1055netpbm documentation             23 July 2006         Ppmtompeg User Manual(0)
Impressum