Advertisement
Guest User

Untitled

a guest
Apr 10th, 2024
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 4.37 KB | None | 0 0
  1. @echo off
  2.  
  3. set "input=test.mkv"
  4. set "output=output.avi"
  5.  
  6. set enable_colormatrix_conversion=0  %= like ColorMatrix(mode="Rec.709->Rec.601") =%
  7.  
  8. set "matrix_convert="
  9. if %enable_colormatrix_conversion%==1 set matrix_convert=:matrixin=709:matrix=170m
  10. set vf_params=zscale=720:-16%matrix_convert%
  11.  
  12. set common_params=          ^
  13.     -y -hide_banner         ^%= overwrite files without prompt; hide ffmpeg banner  =%
  14.                             ^%=                                                     =%
  15.     -i "%input%"            ^%=                                                     =%
  16.     -t 10                   ^%= 10s test sample                                     =%
  17.                             ^%=                                                     =%
  18.     -map 0:v:0              ^%=                                                     =%
  19.                             ^%=                                                     =%
  20.     -vf %vf_params%         ^%=                                                     =%
  21.                             ^%=                                                     =%
  22.     -codec:v libxvid        ^%=     {parameter name in xvid_encraw = default value} =%
  23.     -b:v 1100k              ^%=                                       {bitrate=700} =%
  24.     -bf 2                   ^%=                                     {max_bframes=2} =%
  25.     -g 300                  ^%=                              {max_key_interval=300} =%
  26.     -trellis 1              ^%= 0,1 [0]                           {notrellis=UNSET} =%
  27.     -me_quality 6           ^%= 0..6 [4]                               {?quality=6} =%
  28.     -mbd rd                 ^%= macroblock decision algorithm, [simple],bits,rd {?} =%
  29.     -flags +aic             ^%= H263 advanced intra coding/mpeg4 ac prediction  {?} =%
  30.     -qmin 2                 ^%= ? 2..31 [2]  ?                                      =%
  31.     -qmax 31                ^%= ? 2..31 [31] ?                                      =%
  32.     %= ΓΈ =%                 ^%= [ΓΈ],-lumi_aq,-variance_aq               {masking=0} =%
  33.                             ^%=                                                     =%
  34.     -bsf:v mpeg4_unpack_bframes^%= to improve hw compatibility     {nopacked=UNSET} =%
  35.                             ^%=                                                     =%
  36.     -f avi                  ^%= when can't be deduced from extension (NUL, pipe)    =%
  37.     -vtag XVID               %= xvid->XVID somehow helps MediaInfo show more info   =%
  38.  
  39. set pass2_params=           ^
  40.     -map 0:a:0?             ^%= map first audio track if exists (e.g. test videos   =%
  41.     -codec:a libmp3lame     ^%=                                  may have no audio) =%
  42.     -b:a 128k                %=                                                     =%
  43.  
  44.  
  45. ffmpeg %common_params% -pass 1                   NUL     || goto error_handler
  46. echo. & echo. & echo.
  47. set "FFREPORT=file=ffreport_%%t_%output%.log:level=32" %= only for 2nd pass =%
  48.  
  49. ffmpeg %common_params% -pass 2 %pass2_params% "%output%" || goto error_handler
  50. call :cleanup
  51. pause & exit /b
  52.  
  53.  
  54. :error_handler
  55. call :cleanup
  56. echo. & echo ERROR: ffmpeg failed. Aborting... & pause & exit /b
  57.  
  58.  
  59. :cleanup (void)
  60.     del ffmpeg2pass-0.log 2>NUL
  61.     del xvidff.??????     2>NUL %= log duplicated due to ffmpeg bug =%
  62.     exit /b
  63.  
  64. :: exact mapping to these options?
  65. ::   ENCRAW: -quality   integer   : quality ([0..6]) (6)
  66. ::   ENCRAW: -vhqmode   integer   : level of R-D optimizations ([0..4]) (1)
  67. :: https://github.com/ShiftMediaProject/xvid/blob/master/examples/xvid_encraw.c#L69 (some fork, only #line link matters)
  68. :: https://github.com/ShiftMediaProject/xvid/blob/master/examples/xvid_encraw.c#L2627
  69. :: is -me_quality mapped to them or to quality only or ...?
  70. ::   FFMPEG: -me_quality  motion estimation quality [0=no motion estimation]
  71. :: is -mbd mapped to -vhqmode or something?
  72.  
  73. :: further reading:
  74. :: https://ffmpeg.org/ffmpeg-codecs.html#libxvid
  75. :: https://ffmpeg.org/doxygen/trunk/libxvid_8c_source.html
  76. :: http://websvn.xvid.org/cvs/viewvc.cgi/trunk/xvidcore/examples/xvid_encraw.c?view=markup
  77. :: https://superuser.com/questions/1483338/cant-get-same-xvid-quality-and-file-size-out-of-ffmpeg-as-mencoder
  78. :: https://forum.videohelp.com/threads/307131-Does-xvid-cli-(command-line-version-of-xvid)-actually-exist#post1891813
  79. :: https://forum.doom9.org/showthread.php?t=119399 (avs2qxvid.bat links are dead)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement