Welcome Guest ( Log In | Register )


Important

The forums will be closing permanently the weekend of March 15th. Please see the notice in the announcements forum for details.

Pages: (2) [1] 2  ( Go to first unread post )
External Encoders Using Batch File Helpers.
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
raffriff42
Posted: Dec 10 2013, 02:01 AM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



I have been using a better way to call external encoders lately. Instead of calling external programs directly, I call batch files, and the batch files call the programs. This has the following advantages:
  • Error trapping. I can test the arguments being sent to the external programs and stop if any are not valid (for example, neroaac.exe dies if sample rate is greater than 48 kHz; this can be tested for, and processing can quit with a helpful error message in the log instead of quitting with no explanation)
  • Log control. I can control what goes to the Virtualdub log, adding helpful error messages and hiding unhelpful messages. Some programs fill the log with useless 'progress' messages, causing important earlier messages to be lost.
  • Complex processing. Doing things not possible with Virtualdub's settings alone.
A few months ago, I wrote about this batch technique here. Now I use batch files for all external encoders, where possible (calling ffmpeg as a video encoder has not worked for me, so far).

So here is a ZIP file (version 1; see below) with batch files & virtualdub profiles for the two encoders I use most often:
  • .mp4 out, bat->x264 video, bat->neroaac audio, bat->mp4box muxing
  • .mov out, ffmpeg/x264 video, bat->ffmpeg/PCM audio, bat->ffmpeg muxing + qt-faststart postprocessing.


EDIT 1-Aug-2014: revised settings & batch files; seems to be more reliable. Here is the new ZIP file, or you can see the files in the next few posts below.
  • .mp4 out, bat->x264 video, bat->neroaac audio, bat->ffmpeg muxing;
  • .mov out, bat->x264 video, bat->ffmpeg/PCM audio, bat->ffmpeg muxing.
Unzip to C: (root folder). When unzipped you will have a folder tree like this:
CODE
C:\
   VirtualDub\
       excoders\
           ffmpeg
           neroaac
           x264

You don't have to move Virtualdub itself to this location, but you can if you wish.

Install ffmpeg, x264 etc to the subfolders under "excoders." There will be download links in each subfolder.

Open Virtualdub and import the .vdprof file as explained in my external encoders quick start guide.

If you have unzipped to some other location besides "C:\VirtualDub," you will have to edit the program locations in the batch files, and edit the external encoder settings to point to the batch files.

Now make a test encode and examine the log. You will see some added information there, including time stamps, and actual command lines sent to each program cool.gif If something goes wrong in the encode (EDIT and there are lots of ways for something to go wrong sad.gif), there is at least a chance now of a useful error message.

Hopefully after playing around with these files, you will get inspired to make your own variations... (my early notes on creating batch files can be found here)

EDIT 7-Sep-2014: 2-pass encoding.

This post has been edited by raffriff42 on Sep 7 2014, 07:28 PM
 
     Top
raffriff42
Posted: Aug 2 2014, 03:22 AM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



Here is excoders-bat.vdprof from excoders2.zip above; this sets up your encoder sets to call the batch files, listed below. Note I have a naming convention:
  • Audio encoders (and their .BAT files) start with "A," video with "V," muxers with "M."
  • Encoders called through .BAT files have "bat" in their names.
  • Encoder sets (eg "mov x264 r18 709 +pcm +") start with the container ("mov"); then the video codec with quality etc ("x264 r18 709"), a "+" sign, the audio codec ("pcm"), and optional comment ("+", meaning I like this one)
CODE
{
"description": "VirtualDub external encoder profile collection",
"externalEncoders": {
 "sets": {
  "mp4 x264 r18 709 +aac": {
   "videoEncoder": "V bat x264 r18 709",
   "audioEncoder": "A bat nero aac q035",
   "multiplexer": "M bat ff mp4",
   "description": "mp4",
   "extension": "mp4",
   "processPartial": false,
   "useOutputAsTemp": false
  },
  "mov x264 r18 709 +pcm +": {
   "videoEncoder": "V bat x264 r18 709",
   "audioEncoder": "A bat ff pcm",
   "multiplexer": "M bat ff mov",
   "description": "mov",
   "extension": "mov",
   "processPartial": true,
   "useOutputAsTemp": false
  }
 },
 "profiles": {
  "V bat x264 r18 709": {
   "name": "V bat x264 r18 709",
   "program": "V-x264.bat",
   "commandArguments": "%(width) %(height) %(fpsnum) %(fpsden) \"%(tempvideofile)\" 18 bt709",
   "outputFilename": "%(outputname).264",
   "type": 0,
   "inputFormat": 0,
   "checkReturnCode": true,
   "logStdout": true,
   "logStderr": true,
   "bypassCompression": false,
   "predeleteOutputFile": false
  },
  "A bat nero aac q035": {
   "name": "A bat nero aac q035",
   "program": "A-nero-aac.bat",
   "commandArguments": "%(channels) %(audioprecision) %(samplingrate) \"%(tempaudiofile)\" 0.35",
   "outputFilename": "%(outputname).aac",
   "type": 1,
   "inputFormat": 1,
   "checkReturnCode": true,
   "logStdout": true,
   "logStderr": false,
   "bypassCompression": true,
   "predeleteOutputFile": false
  },
  "A bat ff pcm": {
   "name": "A bat ff pcm",
   "program": "A-ff-pcm.bat",
   "commandArguments": "%(channels) %(audioprecision) %(samplingrate) \"%(tempaudiofile)\"",
   "outputFilename": "%(outputname).wav",
   "type": 1,
   "inputFormat": 1,
   "checkReturnCode": true,
   "logStdout": true,
   "logStderr": true,
   "bypassCompression": true,
   "predeleteOutputFile": false
  },
  "M bat ff mov": {
   "name": "M bat ff mov",
   "program": "M-mov-ffmpeg.bat",
   "commandArguments": "\"%(tempvideofile)\"  \"%(tempaudiofile)\" \"%(outputfile)\" %(fps)",
   "outputFilename": "",
   "type": 2,
   "inputFormat": 0,
   "checkReturnCode": true,
   "logStdout": true,
   "logStderr": true,
   "bypassCompression": false,
   "predeleteOutputFile": false
  },
  "M bat ff mp4": {
   "name": "M bat ff mp4",
   "program": "M-mp4-ffmpeg.bat",
   "commandArguments": "\"%(tempvideofile)\"  \"%(tempaudiofile)\" \"%(outputfile)\" %(fps)",
   "outputFilename": "",
   "type": 2,
   "inputFormat": 0,
   "checkReturnCode": true,
   "logStdout": true,
   "logStderr": true,
   "bypassCompression": false,
   "predeleteOutputFile": false
  }
 }
}
}


This post has been edited by raffriff42 on Aug 2 2014, 03:42 PM
 
     Top
raffriff42
Posted: Aug 2 2014, 03:26 AM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



Here is V-x264.bat from excoders2.zip above; this calls the video encoder x264.exe, while attempting to send better error messages to the VirtualDub log window if anything goes wrong (that's what all those @echo commands are for)
CODE
@echo off

::** CONFIGURATION SECTION **
set x264="C:\VirtualDub\excoders\x264\x264.exe"
::** END CONFIGURATION SECTION **

@echo **** VIDEO: X264 ***********

:: USAGE  W   H  fpsnum fpsden output-path crf [matrix=none]
::        1   2    3      4         5       6     7

if (%1)==() goto BADARG
if (%2)==() goto BADARG
if (%3)==() goto BADARG
if (%4)==() goto BADARG
if (%5)==() goto BADARG
if (%6)==() goto BADARG

if %1 lss 1 goto BADARG
if %2 lss 1 goto BADARG
if %3 lss 1 goto BADARG
if %4 lss 1 goto BADARG
if %6 lss 1 goto BADARG
if %6 gtr 31 goto BADARG

if (%7)==() set a_matrix=
if (%7)==() goto NOMATRIX

set a_matrix=--colorprim %7 --transfer %7 --colormatrix %7  

:NOMATRIX
set a_crf=%6

set a_tune=--preset veryfast --subme 6 --psy-rd 0.5 --bframes 2 --keyint 15

::set a_deblock=
set a_deblock=--deblock -1:-1

if exist %5 del /f %5

@echo %time%
ver > nul
@echo on
%x264% --crf %a_crf% %a_tune% %a_deblock% --demuxer raw ^
--input-res %1x%2 --fps %3/%4 ^
%a_matrix% --no-progress -o %5 -

@echo off

@echo %time%
if ERRORLEVEL 1 goto DUMPARGS
exit 0

:BADARG
@echo VIDEO ERROR: BAD OR MISSING ARGUMENT
goto DUMPARGS

:DUMPARGS
@echo USAGE W H fpsnum fpsden output-path crf [matrix=none]
if (%1)==() goto :DUMPEND
if (%2)==() goto :DUMPEND
@echo input-size = %1x%2
if (%3)==() goto :DUMPEND
if (%4)==() goto :DUMPEND
@echo fps = %3/%4
if (%5)==() goto :DUMPEND
@echo output = %5
if (%6)==() goto :DUMPEND
@echo crf = %6
if (%7)==() goto :DUMPEND
@echo matrix = %7
:DUMPEND
exit 1


This post has been edited by raffriff42 on Aug 2 2014, 01:38 PM
 
     Top
raffriff42
Posted: Aug 2 2014, 03:29 AM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



Here is A-nero-aac.bat from excoders2.zip above; this calls the audio encoder NeroAacEnc.exe. It attempts to test for non-supported sample rates and channel layouts. Better to throw an error here, at the beginning, than in the muxer...
CODE
@echo off

::** CONFIGURATION SECTION **
set nero_aac="C:\VirtualDub\excoders\neroaac\neroAacEnc.exe"
::** END CONFIGURATION SECTION **

@echo **** AUDIO: Nero AAC ***********

:: USAGE %(channels) %(audioprecision) %(samplingrate) output-path [qfactor=0.35]
::            1             2                 3             4         5

:: approx. average bitrate <-> Quality table
::
::               Quality       Bitrate            
:: bad             0.05  ....  ~  16                
::                 0.15        ~  33                
::                 0.25        ~  66                
:: good (default)  0.35  ....  ~ 100              
::                 0.45        ~ 146              
:: better          0.55  ....  ~ 192              
::                 0.65        ~ 238              
::                 0.75        ~ 285              
:: ridiculous      0.85  ....  ~ 332              
::                 0.95        ~ 382              

if (%1)==() goto BADARG
if (%2)==() goto BADARG
if (%3)==() goto BADARG
if (%4)==() goto BADARG

if %1 leq 0 goto BADARG
if %1 gtr 8 goto BADARG

if %2 lss 16 goto BADARG
if %2 gtr 32 goto BADARG

if %3 lss 22050 goto BADARG
if %3 gtr 96000 goto BADARG

if not (%5)==() set qual=%5
if (%5)==() set qual=0.35
if %qual% lss 0.01 goto BADARG
if %qual% gtr 0.95 goto BADARG

if exist %4 del /f %4

@echo %time%
ver > nul
@echo on
%nero_aac% -q %qual% -ignorelength -if - -of %4
@echo off
@echo %time%
if ERRORLEVEL 1 goto DUMPARGS
exit 0

:BADARG
@echo AUDIO ERROR: BAD OR MISSING ARGUMENT
goto DUMPARGS

:DUMPARGS
@echo USAGE channels bitwidth samplingrate output-path [qfactor=0.35]
if (%1)==() goto :DUMPEND
@echo channels = %1
if (%2)==() goto :DUMPEND
@echo bitwidth = %2
if (%3)==() goto :DUMPEND
@echo samplingrate = %3
if (%4)==() goto :DUMPEND
@echo output = %4
if (%5)==() goto :DUMPEND
@echo qfactor = %5
:DUMPEND
exit 1


This post has been edited by raffriff42 on Aug 2 2014, 01:39 PM
 
     Top
raffriff42
Posted: Aug 2 2014, 03:31 AM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



Here is A-ff-pcm.bat from excoders2.zip above; this uses ffmpeg.exe to create PCM uncompressed audio:
CODE
@echo off

::** CONFIGURATION SECTION **
set ffmpeg="C:\VirtualDub\excoders\ffmpeg\ffmpeg.exe"
::** END CONFIGURATION SECTION **

@echo **** AUDIO: FFmpeg PCM ***********

:: USAGE channels audioprecision samplingrate output-path [output-samplingrate]
::            1         2             3           4               5

if (%1)==() goto BADARG
if (%2)==() goto BADARG
if (%3)==() goto BADARG
if (%4)==() goto BADARG

if %1 leq 0 goto BADARG
if %1 gtr 8 goto BADARG

::** (audioprecision is sometimes 0)
::if %2 lss 16 goto BADARG
::if %2 gtr 16 goto BADARG

if %3 lss 32000 goto BADARG
if %3 gtr 96000 goto BADARG

if (%5)==() set samplerate=
if (%5)==() goto DOIT
if %5 lss 32000 goto BADARG
if %5 gtr 96000 goto BADARG
set samplerate=-ar %5

:DOIT
@echo %time%
ver > nul
@echo on
%ffmpeg% -y -i - -vn -c:a pcm_s16le %samplerate% -f wav %4
@echo off
@echo %time%
if ERRORLEVEL 1 goto DUMPARGS
exit 0

:BADARG
@echo AUDIO ERROR: BAD OR MISSING ARGUMENT
goto DUMPARGS

:DUMPARGS
@echo USAGE channels bitwidth samplingrate output-path [output-samplingrate]
if (%1)==() goto :DUMPEND
@echo channels = %1
if (%2)==() goto :DUMPEND
@echo bitwidth = %2
if (%3)==() goto :DUMPEND
@echo samplingrate = %3
if (%4)==() goto :DUMPEND
@echo output = %4
if (%5)==() goto :DUMPEND
@echo output-samplingrate = %5
:DUMPEND
exit 1
 
     Top
raffriff42
Posted: Aug 2 2014, 03:33 AM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



Here is M-mp4-ffmpeg.bat from excoders2.zip above; this uses ffmpeg.exe to mux the audio and video into an .MP4 container:
CODE
@echo off

::** CONFIGURATION SECTION **
set ffmpeg="C:\VirtualDub\excoders\ffmpeg\ffmpeg.exe"
::** END CONFIGURATION SECTION **

@echo **** MUXING: ffmpeg ***********

if (%1)==() goto BADARG
if (%2)==() goto BADARG
if (%3)==() goto BADARG

if not exist %1 goto BADARG
if not exist %2 goto BADARG

if /I (%~x3) neq (.mp4) goto BADEXT

set ffps=-r %4
if (%4)==() set ffps=

if exist %3 del /f %3

@echo %time%
ver > nul
@echo on
%ffmpeg% -i %1 -i %2 %ffps% -c:v copy -c:a copy -f mp4 -movflags faststart %3
@echo off
@echo %time%
if ERRORLEVEL 1 goto DUMPARGS

::@echo on
::copy /y %3 "%~dpn3-$bak.mp4"
::@echo off

exit 0

:BADARG
@echo MUXER ERROR: BAD OR MISSING ARGUMENT
goto DUMPARGS

:BADEXT
@echo MUXER ERROR: OUTPUT FILE EXTENSION NOT .MP4
goto DUMPARGS

:DUMPARGS
@echo USAGE video-src-path audio-src-path output-path
if (%1)==() goto :DUMPEND
@echo video-src = %1
if (%2)==() goto :DUMPEND
@echo audio-src = %2
if (%3)==() goto :DUMPEND
@echo output = %3
if (%4)==() goto :DUMPEND
@echo fps = %4
:DUMPEND
exit 1
 
     Top
raffriff42
Posted: Aug 2 2014, 03:35 AM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



Here is M-mov-ffmpeg.bat from excoders2.zip above; this uses ffmpeg.exe to mux the audio and video into a .MOV container:
CODE
@echo off

::** CONFIGURATION SECTION **
set ffmpeg="C:\VirtualDub\excoders\ffmpeg\ffmpeg.exe"
::** END CONFIGURATION SECTION **


@echo **** MUXING: ffmpeg ***********

:: USAGE video-src-path audio-src-path output-path [fps]

if (%1)==() goto BADARG
if (%2)==() goto BADARG
if (%3)==() goto BADARG

if not exist %1 @echo *ERROR* video source missing
if not exist %1 goto BADARG
if not exist %2 @echo *ERROR* audio source missing
if not exist %2 goto BADARG

if /I (%~x3) neq (.mov) goto BADEXT

set ffps=-r %4
if (%4)==() set ffps=

@echo %time%
ver > nul
@echo on
%ffmpeg% -y -i %1 -i %2 %ffps% -c:v copy -c:a copy -f mov -movflags faststart %3
@echo off
@echo %time%
if ERRORLEVEL 1 goto DUMPARGS

::@echo on
::copy /y %3 "%~dpn3-$bak.mov"
::@echo off

exit 0

:BADARG
@echo MUXER ERROR: BAD OR MISSING ARGUMENT
goto DUMPARGS

:BADEXT
@echo MUXER ERROR: OUTPUT FILE EXTENSION NOT .MOV
goto DUMPARGS

:DUMPARGS
@echo USAGE video-src-path audio-src-path output-path [fps]
if (%1)==() goto :DUMPEND
@echo video-src = %1
if (%2)==() goto :DUMPEND
@echo audio-src = %2
if (%3)==() goto :DUMPEND
@echo output = %3
if (%4)==() goto :DUMPEND
@echo fps = %4
:DUMPEND
exit 1
(that's all folks)
 
     Top
supermax
Posted: Sep 5 2014, 06:25 PM


Member


Group: Members
Posts: 15
Member No.: 38193
Joined: 1-August 14



QUOTE (raffriff42 @ Aug 2 2014, 03:26 AM)
Here is V-x264.bat from excoders2.zip above; this calls the video encoder x264.exe, while attempting to send better error messages to the VirtualDub log window if anything goes wrong (that's what all those @echo commands are for)
CODE
@echo off

::** CONFIGURATION SECTION **
set x264="C:\VirtualDub\excoders\x264\x264.exe"
::** END CONFIGURATION SECTION **

@echo **** VIDEO: X264 ***********

:: USAGE  W   H  fpsnum fpsden output-path crf [matrix=none]
::        1   2    3      4         5       6     7

if (%1)==() goto BADARG
if (%2)==() goto BADARG
if (%3)==() goto BADARG
if (%4)==() goto BADARG
if (%5)==() goto BADARG
if (%6)==() goto BADARG

if %1 lss 1 goto BADARG
if %2 lss 1 goto BADARG
if %3 lss 1 goto BADARG
if %4 lss 1 goto BADARG
if %6 lss 1 goto BADARG
if %6 gtr 31 goto BADARG

if (%7)==() set a_matrix=
if (%7)==() goto NOMATRIX

set a_matrix=--colorprim %7 --transfer %7 --colormatrix %7  

:NOMATRIX
set a_crf=%6

set a_tune=--preset veryfast --subme 6 --psy-rd 0.5 --bframes 2 --keyint 15

::set a_deblock=
set a_deblock=--deblock -1:-1

if exist %5 del /f %5

@echo %time%
ver > nul
@echo on
%x264% --crf %a_crf% %a_tune% %a_deblock% --demuxer raw ^
--input-res %1x%2 --fps %3/%4 ^
%a_matrix% --no-progress -o %5 -

@echo off

@echo %time%
if ERRORLEVEL 1 goto DUMPARGS
exit 0

:BADARG
@echo VIDEO ERROR: BAD OR MISSING ARGUMENT
goto DUMPARGS

:DUMPARGS
@echo USAGE W H fpsnum fpsden output-path crf [matrix=none]
if (%1)==() goto :DUMPEND
if (%2)==() goto :DUMPEND
@echo input-size = %1x%2
if (%3)==() goto :DUMPEND
if (%4)==() goto :DUMPEND
@echo fps = %3/%4
if (%5)==() goto :DUMPEND
@echo output = %5
if (%6)==() goto :DUMPEND
@echo crf = %6
if (%7)==() goto :DUMPEND
@echo matrix = %7
:DUMPEND
exit 1

Congratulations, fantastic.
1.Eu wonder if it would be possible to make a pass2 version (V-x264pass2.bat ) in a single batch file ?

I edicts many videos and I need to make many cuts in them, could use other alternatives without making a new encoder, but no other alternative is as accurate and as easy to use as virtualdub.O what I do then is edit the video and make a new encode and try to use the same bitrate of the original file, since Strem Direct Copy is not possible in Virtualdub to MP4 files.
2 Is there an easier way to do this?
2.1 Is there any automatic way (perhaps with a batch file) that identifies the bitrate of the video (input) and choose this value to use the encoder (output)?
That would be very useful for me to use Queue Bacht operation, since the files released in Queue operation Bacht not store the bitrate on external encoders. Only if I create an Encoder Sets for each bitrate, which would not be very practical.

already agracedo attention,
 
     Top
raffriff42
Posted: Sep 6 2014, 02:01 AM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



Thanks, I'm glad you like it. I have zero experience in 2-pass encoding, but something like this might work:
CODE
(start code omitted. . . )

@echo pass 1...
@echo %time%
ver > nul
@echo on

%x264% --preset medium --pass 1 --bitrate 3000 ^
--stats "%~dpn5-stats" ^
%a_tune% %a_deblock% --demuxer raw ^
--input-res %1x%2 --fps %3/%4 ^
%a_matrix% --no-progress -o NUL -

@echo off

@echo %time%
if ERRORLEVEL 1 goto DUMPARGS

:: WAIT 10 SEC (maybe??)
ping -n 11 127.0.0.1>nul

@echo pass 2...
@echo %time%
ver > nul
@echo on

%x264% --preset medium --pass 2 --bitrate 3000 ^
--stats "%~dpn5-stats" ^
%a_tune% %a_deblock% --demuxer raw ^
--input-res %1x%2 --fps %3/%4 ^
%a_matrix% --no-progress -o %5 -

@echo off

@echo %time%
if ERRORLEVEL 1 goto DUMPARGS
exit 0
(end code omitted. . . )


Regarding your other questions, I have no idea. Reading the source bitrate in VirtualDub and transferring that information to a batch file? I don't think it can be done. It would be better to do the decoding, editing and encoding all within a batch file, or something.

Although I don't see the point of what you are trying to do, if you want to set the bitrate, encode in constant bitrate mode. 2-pass is for controlling the final file size, not bitrate.
CODE
(start code omitted. . . )

@echo %time%
ver > nul
@echo on

%x264% --preset medium --bitrate 3300 ^
%a_tune% %a_deblock% --demuxer raw ^
--input-res %1x%2 --fps %3/%4 ^
%a_matrix% --no-progress -o %5 -

@echo off

@echo %time%
if ERRORLEVEL 1 goto DUMPARGS
exit 0
(end code omitted. . . )


Making Bitrate a batch argument (so it can be set from VirtualDub) is pretty easy...just reuse argument %6, currently used for CRF. If you do, change the argument test "if %6 gtr 31 goto BADARG" to something that makes more sense, like "if %6 gtr 250000 goto BADARG"

This post has been edited by raffriff42 on Sep 6 2014, 02:24 AM
 
     Top
supermax
Posted: Sep 6 2014, 02:52 PM


Member


Group: Members
Posts: 15
Member No.: 38193
Joined: 1-August 14



QUOTE (raffriff42 @ Sep 6 2014, 02:01 AM)
Thanks, I'm glad you like it. I have zero experience in 2-pass encoding, but something like this might work:
CODE
(start code omitted. . . )

@echo pass 1...
@echo %time%
ver > nul
@echo on

%x264% --preset medium --pass 1 --bitrate 3000 ^
--stats "%~dpn5-stats" ^
%a_tune% %a_deblock% --demuxer raw ^
--input-res %1x%2 --fps %3/%4 ^
%a_matrix% --no-progress -o NUL -

@echo off

@echo %time%
if ERRORLEVEL 1 goto DUMPARGS

:: WAIT 10 SEC (maybe??)
ping -n 11 127.0.0.1>nul

@echo pass 2...
@echo %time%
ver > nul
@echo on

%x264% --preset medium --pass 2 --bitrate 3000 ^
--stats "%~dpn5-stats" ^
%a_tune% %a_deblock% --demuxer raw ^
--input-res %1x%2 --fps %3/%4 ^
%a_matrix% --no-progress -o %5 -

@echo off

@echo %time%
if ERRORLEVEL 1 goto DUMPARGS
exit 0
(end code omitted. . . )


Regarding your other questions, I have no idea. Reading the source bitrate in VirtualDub and transferring that information to a batch file? I don't think it can be done. It would be better to do the decoding, editing and encoding all within a batch file, or something.

Although I don't see the point of what you are trying to do, if you want to set the bitrate, encode in constant bitrate mode. 2-pass is for controlling the final file size, not bitrate.
CODE
(start code omitted. . . )

@echo %time%
ver > nul
@echo on

%x264% --preset medium --bitrate 3300 ^
%a_tune% %a_deblock% --demuxer raw ^
--input-res %1x%2 --fps %3/%4 ^
%a_matrix% --no-progress -o %5 -

@echo off

@echo %time%
if ERRORLEVEL 1 goto DUMPARGS
exit 0
(end code omitted. . . )


Making Bitrate a batch argument (so it can be set from VirtualDub) is pretty easy...just reuse argument %6, currently used for CRF. If you do, change the argument test "if %6 gtr 31 goto BADARG" to something that makes more sense, like "if %6 gtr 250000 goto BADARG"

thanks for the tips.
I will try to follow their codes to make a batch file to x264 2-pass.
 
     Top
supermax
Posted: Sep 7 2014, 09:31 AM


Member


Group: Members
Posts: 15
Member No.: 38193
Joined: 1-August 14



I could not make it work with 2pass in the same batch file.
Worked perfectly, separating each pass in an encoder sets.
when they are in the same batch file at the end of the first stage (1pass) the progress window of VirtualDub reaches 100% to begin the second stage, and the virtualdub should spend some instruction that is to stop, because the process has reached 100% (which is not true, reached 100% only the first instruction) and then the instruction with 2pass stops. Tried using pause even with high values&#8203;&#8203;, did not work.
May have to pass some information to the VirtualDub: that the encoder has two steps and the first of these is only 50% of the process. I do not know if this is possible, or if this can be done using the parameters of virtualdub, but it is beyond my knowledge sad.gif smile.gif

The log is actually much more useful, notice what happens, mainly in the end which signaled (<<<<<<<<<<):

CODE

[*] Beginning dub operation.
[i] Dub: Input (decompression) format is: YUV420.
[i] Dub: Output (compression) format is: YUV420.
[i] VideoEnc: **** VIDEO: X264 ***********
[i] VideoEnc: pass 1...
[i] VideoEnc:  6:02:10,50
[i] VideoEnc:
   D:\Videos\prov\teste>"D:\Videos\excoders\x264\x2
   64.exe" --pass 1 --bitrate 1000 --stats
   "D:\Videos\prov\teste\teste22.mp4-stats" --preset medium
   --subme 11 --psy-rd 0.5 --bframes 2 --keyint 15 --deblock -1:-1  --demuxer
   raw --input-res 1280x536 --fps 999/40 --colorprim bt709 --transfer bt709
   --colormatrix bt709   --no-progress -o
   "D:\Videos\prov\teste\teste22.mp4-pass1.264" -  
[i] AudioEnc: **** AUDIO: Nero AAC ***********
[i] AudioEnc:  6:02:10,58
[i] AudioEnc: D:\Videos\prov\teste>"C:\Program
   Files\MediaCoder\codecs\neroAacEnc.exe" -q 0.35 -ignorelength -if - -of
   "D:\Videos\prov\teste\teste22.mp4.aac"
[i] VideoEnc: raw [info]: 1280x536p 0:0 @ 999/40 fps (cfr)
[i] VideoEnc: x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2  AVX
[i] VideoEnc: x264 [info]: profile Main, level 3.1
[i] VideoEnc: x264 [info]: frame I:24    Avg QP:30.90  size: 37386
[i] VideoEnc: x264 [info]: frame P:124   Avg QP:35.34  size:  3608
[i] VideoEnc: x264 [info]: frame B:112   Avg QP:37.17  size:   347
[i] VideoEnc: x264 [info]: consecutive B-frames: 30.0% 21.5% 48.5%
[i] VideoEnc: x264 [info]: mb I  I16..4: 48.9%  0.0% 51.1%
[i] VideoEnc: x264 [info]: mb P  I16..4:  7.7%  0.0%  0.0%  P16..4: 27.9%  
   0.0%  0.0%  0.0%  0.0%    skip:64.3%
[i] VideoEnc: x264 [info]: mb B  I16..4:  0.3%  0.0%  0.0%  B16..8:  3.7%  
   0.0%  0.0%  direct: 0.5%  skip:95.5%  L0:44.2% L1:49.3% BI: 6.5%
[i] VideoEnc: x264 [info]: final ratefactor: 30.84
[i] VideoEnc: x264 [info]: coded y,uvDC,uvAC intra: 59.0% 43.5% 9.6% inter:
   3.3% 2.4% 0.0%
[i] VideoEnc: x264 [info]: i16 v,h,dc,p: 27% 28% 29% 16%
[i] VideoEnc: x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 24% 17%  7%  7%
   6%  9%  5% 10%
[i] VideoEnc: x264 [info]: i8c dc,h,v,p: 64% 19% 13%  4%
[i] VideoEnc: x264 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
[i] VideoEnc: x264 [info]: kb/s:1063.14
[i] VideoEnc: encoded 260 frames, 147.48 fps, 1063.14 kb/s
[i] VideoEnc:  6:02:12,50   (<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<)
[i] VideoEnc: pass 2...
[i] VideoEnc:  6:02:22,60
[i] VideoEnc:
   D:\Videos\prov\teste>"D:\Videos\excoders\x264\x2
   64.exe" --pass 2 --bitrate 1000 --stats
   "D:\Videos\prov\teste\teste22.mp4-stats" --preset medium
   --subme 11 --psy-rd 0.5 --bframes 2 --keyint 15 --deblock -1:-1  --demuxer
   raw --input-res 1280x536 --fps 999/40 --colorprim bt709 --transfer bt709
   --colormatrix bt709   --no-progress -o
   "D:\Videos\prov\teste\teste22.mp4.264" -
[i] VideoEnc: raw [info]: 1280x536p 0:0 @ 999/40 fps (cfr)
[i] VideoEnc: x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
   AVX
[i] VideoEnc: x264 [info]: profile High, level 3.1
[i] VideoEnc:  6:02:22,69   (<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<)
[i] AudioEnc:  6:02:22,80
[*] Ending operation.

 
     Top
dloneranger
Posted: Sep 7 2014, 10:00 AM


Moderator


Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07



Doing 2pass like this (two passes in one set) will never work as virtualdub will only send the video/audio frames one time, so the second call to the encoder won't have anything to process and will just sit there waiting for something to do while virtualdub sits there waiting for the .bat to exit
It'd need to be supported in virtualdub itself for this to work

--------------------
MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask
Windows7/8 Codec Chooser
All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3
 
    Top
raffriff42
Posted: Sep 7 2014, 11:42 AM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



OK thanks dloneranger. In that case I think one would have to create two "encoders" - one for the 1st pass, another for the 2nd. I think this has been done (but without batch files) but I can't find where it was posted. If anyone knows, please tell me! Meanwhile I will make some experiments.

(EDIT sorry supermax, I skipped your last post, I see you are working on it)

This post has been edited by raffriff42 on Sep 7 2014, 12:36 PM
 
     Top
dloneranger
Posted: Sep 7 2014, 11:53 AM


Moderator


Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07



You could make a new 'set' that was just the video encoder for pass one
But you'd have to queue the pass one and then the pass two
Plus, this would fail if you used multiple virtualdubs on a jobs file using master/multiple-slaves mode as both the first and second pass would try running at the same time by different virtualdubs and it'd all go splat


--------------------
MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask
Windows7/8 Codec Chooser
All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3
 
    Top
supermax
Posted: Sep 7 2014, 02:29 PM


Member


Group: Members
Posts: 15
Member No.: 38193
Joined: 1-August 14



QUOTE (raffriff42 @ Sep 7 2014, 11:42 AM)
OK thanks dloneranger. In that case I think one would have to create two "encoders" - one for the 1st pass, another for the 2nd. I think this has been done (but without batch files) but I can't find where it was posted. If anyone knows, please tell me! Meanwhile I will make some experiments.

(EDIT sorry supermax, I skipped your last post, I see you are working on it)

QUOTE (dloneranger @ Sep 7 2014, 11:53 AM)
You could make a new 'set' that was just the video encoder for pass one
But you'd have to queue the pass one and then the pass two
Plus, this would fail if you used multiple virtualdubs on a jobs file using master/multiple-slaves mode as both the first and second pass would try running at the same time by different virtualdubs and it'd all go splat


Thanks for the feedback.
@raffriff42, I do not know where it is now, but I had seen and this solution is what I'm using and it really works.
I made an adjustment to 2pass with batch files, and also worked. That is, 2pass work, but with 2 encoder sets (x264-2pass1.bat-V and V-x264-2pass2.bat). It's a shame not work all in one batch file, but I think neither x264vfw works at once, you also need to do the two-step process.

-----
QUOTE (raffriff42 @ Aug 2 2014, 03:22 AM)
Here is excoders-bat.vdprof from excoders2.zip above; this sets up your encoder sets to call the batch files, listed below. Note I have a naming convention:
  • Audio encoders (and their .BAT files) start with "A," video with "V," muxers with "M."
  • Encoders called through .BAT files have "bat" in their names.
  • Encoder sets (eg "mov x264 r18 709 +pcm +") start with the container ("mov"); then the video codec with quality etc ("x264 r18 709"), a "+" sign, the audio codec ("pcm"), and optional comment ("+", meaning I like this one)


I also really liked the way you organize your sets and passed to adopt the same scheme, just adapted and instead of signaling batch files with "bat", I just includes a point "." at the front:

"M bat ff mp4" ~ ".M ff mp4"


Another thing that I think would be more, is spending several configurations of times instead of just the crf or BT709, like so:
CODE

%(width) %(height) %(fpsnum) %(fpsden) "%(tempvideofile)" 18 bt709
%(width) %(height) %(fpsnum) %(fpsden) "%(tempvideofile)" "--crf 18.0 --preset veryfast --bframes 2 --keyint 15" bt709


so, if you need, I can make various modifications without having to change the batch file.


And finally, for me to take a doubt, this setting you use (--colorprim %7 --transfer %7 --colormatrix %7)

I must need to use those filters that you directed in another topic (alias format and confert format)?

grateful
 
     Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
25 replies since Dec 10 2013, 02:01 AM Track this topic | Email this topic | Print this topic
Pages: (2) [1] 2 
<< Back to Codec Discussion