Advertisement
Guest User

brandonj

a guest
May 31st, 2008
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.79 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. #                                  #########
  4. #                                  # NOTES #
  5. #                                  #########
  6. #
  7. #
  8. #
  9. #                               ***CROPPING***
  10. #
  11. #  The following comes from the mencoder documentation on calculating the
  12. #  proper crop values:
  13. #  
  14. #  First, we want to determine the appropriate crop rectangle, so we use
  15. #  the cropdetect filter:
  16. #      mplayer dvd://1 -vf cropdetect
  17. #
  18. #  Make sure you seek to a fully filled frame (such as a bright scene,
  19. #  past the opening credits and logos), and you will see in MPlayer's
  20. #  console output:
  21. #      crop area: X: 0..719  Y: 57..419  (-vf crop=720:362:0:58)
  22. #
  23. #  We then play the movie back with this filter to test its correctness:
  24. #      mplayer dvd://1 -vf crop=720:362:0:58
  25. #
  26. #  And we see that it looks perfectly fine. Next, we ensure the width and
  27. #  height are a multiple of 16. The width is fine, however the height is
  28. #  not. Since we did not fail 7th grade math, we know that the nearest
  29. #  multiple of 16 lower than 362 is 352.
  30. #
  31. #  We could just use crop=720:352:0:58, but it would be nice to take a
  32. #  little off the top and a little off the bottom so that we retain the
  33. #  center. We have shrunk the height by 10 pixels, but we do not want to
  34. #  increase the y-offset by 5-pixels since that is an odd number and will
  35. #  adversely affect quality. Instead, we will increase the y-offset by 4
  36. #  pixels:
  37. #      mplayer dvd://1 -vf crop=720:352:0:62
  38. #
  39. #  Another reason to shave pixels from both the top and the bottom is that
  40. #  we ensure we have eliminated any half-black pixels if they exist. Note
  41. #  that if your video is telecined, make sure the pullup filter (or
  42. #  whichever inverse telecine filter you decide to use) appears in the
  43. #  filter chain before you crop. If it is interlaced, deinterlace before
  44. #  cropping. (If you choose to preserve the interlaced video, then make
  45. #  sure your vertical crop offset is a multiple of 4.)
  46. #
  47. #
  48. #
  49. #                              ***SUBTITLES***
  50. #  MPlayer prints the available subtitle IDs when run in verbose (-v) mode.
  51. #  Example:
  52. #      mplayer dvd://1 -v
  53. #
  54. #  You will find a line that says something like this:
  55. #      subtitle ( sid ): 0 language: en
  56. #      number of subtitles on disk: 1
  57. #  
  58. #  Replace the "-sid 0" switch on the first pass to the subtitle ID that you
  59. #  want (the example above shows 1 subtitle with ID 0)
  60. #
  61. #  
  62. #
  63. #                               ***Audio***
  64. #  The script is written to encode into AAC audio.  This is an advanced,
  65. #  high quality codec, capable of storing up to 64 channels of audio.
  66. #  This is probably sufficient for most people, and saves space.  If you
  67. #  want to keep the original sound track and not re-encode the audio, you
  68. #  must use the Matroska container, as the MP4 container only supports AAC.
  69. #  To copy the original audio track, do the following:
  70. #      CHANGE "-oac faac" TO "-oac copy" in both passes
  71. #      REMOVE the "-faacopts ..." line in both passes
  72. #      CHANGE "-o audio.aac" to audio.ac3 in the first pass
  73. #      CHANGE "audio.aac" TO "audio.ac3" in the mkvmerge command
  74. #      COMMENT out the MP4Box command
  75. #
  76. #
  77. #
  78. #                             ***OTHER NOTES***
  79. #
  80. # Keep in mind that this is made for movies - Other videos such as TV
  81. # shows are usually interlaced and at a different framerate.
  82. #
  83. # Don't forget to change your -dvd-device
  84. #
  85. #
  86. #    -Brandon
  87.  
  88. #First pass - dump audio
  89. mencoder dvd://1 \
  90.  -oac faac \
  91.  -faacopts br=256 \
  92.  -alang en \
  93.  -ovc x264 \
  94.  -x264encopts bitrate=1400:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b:threads=auto:pass=1 \
  95.  -vf pullup,softskip,crop=704:352:8:62,hqdn3d=2:1:2,harddup \
  96.  -mc 0 \
  97.  -ofps 24000/1001 \
  98.  -vobsubout subtitles \
  99.  -vobsuboutindex 0 \
  100.  -sid 0 \
  101.  -dvd-device ./ \
  102.  -of rawaudio \
  103.  -o audio.aac
  104.  
  105. #Second pass - dump video
  106. mencoder dvd://1 \
  107.  -oac faac \
  108.  -faacopts br=256 \
  109.  -alang en \
  110.  -ovc x264 \
  111.  -x264encopts bitrate=1400:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b:threads=auto:pass=2 \
  112.  -vf pullup,softskip,crop=704:352:8:62,hqdn3d=2:1:2,harddup \
  113.  -mc 0 \
  114.  -ofps 24000/1001 \
  115.  -dvd-device ./ \
  116.  -of rawvideo \
  117.  -o video.264
  118.  
  119. # This will add audio and video files to an MP4
  120. # "apt-get install gpac" will install MP4Box
  121. MP4Box Muxed.mp4 \
  122.  -add video.264 \
  123.  -add audio.aac \
  124.  -add subtitles.sub \
  125.  -fps 23.976
  126.  
  127. # This will mux the audio and video files to a
  128. # Matroska container
  129. # "apt-get install mkvtoolnix" will install this.
  130. mkvmerge -o Muxed.mkv \
  131.  video.264 \
  132.  audio.aac \
  133.  subtitles.idx
  134.  
  135.  
  136. # Delete all the files - you prolly want to keep this
  137. # commented out and delete these manually.
  138. # rm video.264
  139. # rm audio.aac
  140. # rm divx2pass.log
  141. # rm subtitles.sub
  142. # rm subtitles.idx
  143.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement