dvd2ogm.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #!/bin/sh
  2. #
  3. # dvd2ogm.sh INPUT.ISO TITLE
  4. #
  5. tc_input="$1"
  6. tc_title="$2"
  7. tc_audio=0
  8. tc_bitrate=1024
  9. tc_keyfrms=50
  10. tc_vorbisq=5
  11. tc_fps=25
  12. tc_divxlog="./divx4.log"
  13. xvidconf="./xvid4.cfg"
  14. outfile="./out.ogm"
  15. transcode_common()
  16. {
  17. transcode -H 10 -a $tc_audio -T $tc_title,-1 -x dvd \
  18. -i "$tc_input" \
  19. -w $tc_bitrate,$tc_keyfrms \
  20. --a52_drc_off \
  21. -b 0,1,$tc_vorbisq \
  22. -J smartyuv=threshold=10:Blend=1:diffmode=2:highq=1 \
  23. -f $tc_fps \
  24. --export_par 106,100 \
  25. --progress_meter 1 --progress_rate $tc_fps \
  26. $@
  27. }
  28. transcode_pass1()
  29. {
  30. echo "Starting encoding pass 1 ..."
  31. transcode_common -R "1,$tc_divxlog" -y xvid,ogg -o /dev/null -m "$outfile.audio"
  32. echo "Pass 1 done."
  33. }
  34. transcode_pass2()
  35. {
  36. echo "Starting encoding pass 2 ..."
  37. transcode_common -R "2,$tc_divxlog" -y xvid,null -o "$outfile.video"
  38. echo "Pass 2 done."
  39. }
  40. ogg_merge()
  41. {
  42. ogmmerge -o "$outfile" "$outfile.audio" "$outfile.video"
  43. }
  44. mkxvidconf()
  45. {
  46. cat << EOF
  47. ##############################################
  48. # #
  49. # Configuration file for XviD 1.0.0 (API-4) #
  50. # #
  51. # Generated by xvid4conf v1.12 #
  52. # #
  53. ##############################################
  54. #
  55. # Feature settings
  56. #
  57. [features]
  58. quant_type = h263
  59. motion = 6
  60. chromame = 1
  61. vhq = 1
  62. max_bframes = 2
  63. bquant_ratio = 150
  64. bquant_offset = 100
  65. bframe_threshold = 0
  66. quarterpel = 0
  67. gmc = 0
  68. trellis = 0
  69. packed = 1
  70. closed_gop = 1
  71. interlaced = 0
  72. cartoon = 0
  73. hqacpred = 1
  74. frame_drop_ratio = 0
  75. stats = 0
  76. greyscale = 0
  77. turbo = 0
  78. #
  79. # Quantizer settings
  80. #
  81. [quantizer]
  82. min_iquant = 2
  83. max_iquant = 31
  84. min_pquant = 2
  85. max_pquant = 31
  86. min_bquant = 2
  87. max_bquant = 31
  88. #quant_intra_matrix =
  89. #quant_inter_matrix =
  90. #
  91. # CBR settings
  92. #
  93. [cbr]
  94. reaction_delay_factor = 16
  95. averaging_period = 100
  96. buffer = 100
  97. #
  98. # VBR settings
  99. #
  100. [vbr]
  101. keyframe_boost = 0
  102. overflow_control_strength = 5
  103. curve_compression_high = 0
  104. curve_compression_low = 0
  105. max_overflow_improvement = 5
  106. max_overflow_degradation = 5
  107. kfreduction = 20
  108. kfthreshold = 1
  109. container_frame_overhead = 24
  110. EOF
  111. }
  112. clean()
  113. {
  114. rm -f "$tc_divxlog" "$xvidconf" "$outfile.video" "$outfile.audio"
  115. }
  116. set -e
  117. [ -e "$outfile" ] && { echo "outfile exists"; exit 1; }
  118. clean
  119. mkxvidconf > "$xvidconf"
  120. transcode_pass1
  121. transcode_pass2
  122. ogg_merge
  123. clean
  124. exit 0