|
|
| raffriff42 |
| Posted: Sep 2 2013, 02:28 PM |
 |
|

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

|
Using a batch file as a muxer: useful for performing additional steps in the muxing phase. The possibilities are endless.
1. Create the batch file. Things to note: - don't wrap arguments in quotes ("%1", etc) - they will be quoted once already
- No command window will be shown, so you can't pause execution. Trying to do so seems to cause an error.
- For debugging, you can write to a log file as shown below.
- Working directory seems to be set to the output directory
- The final line of the batch file must be "exit 0" or else VirtualDub will think the muxer has failed.
example-ff-mux.bat (demonstrates running a quicktime video through qtfaststart after normal muxing.)
| CODE | @echo off
::** USAGE: [scriptname] video-src-path audio-src-path output-path framerate :: 1 2 3 4
::** set up program locations set ffmpeg="C:\Program Files\ffmpeg\bin\ffmpeg.exe" set qtfaststart="C:\Program Files\ffmpeg\bin\qt-faststart.exe" ::** get qtfaststart for windows: http://ffmpeg.zeranoe.com/blog/?p=59
::** debugging example: echo the arguments @echo arg1=%1 >ffmux.log @echo arg2=%2 >>ffmux.log @echo arg3=%3 >>ffmux.log @echo arg4=%4 >>ffmux.log
::** normal ffmpeg muxing @echo on %ffmpeg% -i %1 -i %2 -c:v copy -c:a copy -r %4 -f mov "temp314159.mov" @echo off
::** post processing with qtfaststart @echo on %qtfaststart% "temp314159.mov" %3 @echo off
::** clean up and exit del /q "temp314159.mov"
exit 0
|
2. Set up the external encoder profile:- type=multiplexer
- program=<path to BAT file, no quotes>
- arguments="%(tempvideofile)" "%(tempaudiofile)" "%(outputname)" %(fps)
- options: check all
3. Make an encoder set in the normal way.
4. Go! In use, it's a little odd because the progress bar stays at 100% during muxing. You know it's finished when the CPU usage goes down :\
Edit: added framerate: "%(fps)" and "-r %4"
Edit: skip down to my next post for an example of enhanced error handling in batch files. Skip down again for an example of using vdub.exe as a muxer.
This post has been edited by raffriff42 on Jul 24 2014, 01:26 PM |
 |
| DarrellS |
| Posted: Oct 10 2013, 07:36 PM |
 |
|
Advanced Member
  
Group: Members
Posts: 567
Member No.: 1061
Joined: 28-November 02

|
Any way to mux 6 channel ac3 in avi without using ffmpeg as the muxer. There is a bug in ffmpeg that changes the codec from CM Big Endian A_AC3 to Extensible FFFE or Audio Coding 3 00001000-0000-0020-8000-00AA00389B71. I'm not sure if these avi will play in a Philips DivX certified DVD player with the odd audio tag.
The only way to do it now is to save the audio as ac3 through Save WAV, create a video only avi and then add the audio to the avi and direct stream copy both audio and video. Might as well just use Save as using internal encoders instead of using the external encoder. I guess this is probably the best way to do it anyway since there is not a command line encoder for DIVX which is twice as fast as XVID. |
 |
| raffriff42 |
| Posted: Oct 10 2013, 11:24 PM |
 |
|

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

|
Have you tried ac3enc? http://www.ac3filter.net/wiki/AC3Filter_tools#ac3enc
How about aften? http://aften.sourceforge.net/longhelp.html
eac3to, which wraps aften? http://forum.doom9.org/showthread.php?t=125966
BeSweet? BeLight? BeHappy? There's a lot of choices... http://www.videohelp.com/tools/sections/audio-encoders
Sorry, this is outside my experience. Hopefully a helpful AC3 command line expert will come along...
As long as I'm here, I'll post a few more BAT files. I'm trying to wrap the encoders when possible, not just the muxer. The error trapping they add to the log output is invaluable. Have had no success so far wrapping the ffmpeg video encoder.
1. x264 | CODE | @echo off
::** CONFIGURATION SECTION ** set x264="C:\Program Files\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
::set a_deblock= set a_deblock=--deblock -1:-1
@echo %time% @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] @echo input-size = %1x%2 @echo fps = %3/%4 @echo output = %5 @echo crf = %6 @echo matrix = %7 exit 1 |
2. ffmpeg PCM audio | CODE | @echo off
::** CONFIGURATION SECTION ** set ffmpeg="C:\Program Files\ffmpeg\bin\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% @echo on %ffmpeg% -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] @echo channels = %1 @echo bitwidth = %2 @echo samplingrate = %3 @echo output = %4 @echo output-samplingrate = %5 exit 1 |
3. ffmpeg muxer | CODE | @echo off
::** CONFIGURATION SECTION ** set ffmpeg="C:\Program Files\ffmpeg\bin\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
@echo %time% @echo on %ffmpeg% -i %1 -i %2 -c:v copy -c:a copy -f mp4 -movflags faststart %3 @echo off @echo %time% if ERRORLEVEL 1 goto DUMPARGS 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 @echo video-src = %1 @echo audio-src = %2 @echo output = %3 exit 1
|
Edit: Fix typo @ "if ERRORLEVEL"
This post has been edited by raffriff42 on Jul 24 2014, 01:29 PM |
 |
| DarrellS |
| Posted: Oct 11 2013, 04:11 AM |
 |
|
Advanced Member
  
Group: Members
Posts: 567
Member No.: 1061
Joined: 28-November 02

|
I don't have a problem creating the 5.1 ac3 file but when I mux the video and audio file with ffmpeg into an avi container, it screws up audio file by changing the fourcc. It does the same thing with a stereo ac3 file.
I found a copy of divxmux.exe in my backup drive but it fails...
[i] Mux: Menu Construction
[i] Mux: -x, --xml <filename>
[i] Mux: Specifies the configuration file which details the menu structure.
[i] Mux: The -x option must be accompanied by the -t option
[i] Mux: -t, --temp <directory path>
[i] Mux: Specifies a directory to be used for temporary file storage.
[E] Error: CLI: The multiplexing process failed with error code -1 (ffffffff). Check the log for possible error messages.
Ending operation.
Doesn't seem to be a command line avi muxer anywhere.
|
 |
| raffriff42 |
| Posted: Oct 11 2013, 08:50 AM |
 |
|

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

|
Ah I see - sorry, misread your post.
But it started me thinking - what about using vdub.exe as a muxer, in direct stream copy mode with audio from other file? After some hacking, it seems this will work. Hope this helps...
EDIT The following is more complicated than it needs to be. Sorry! At the time of this post, I didn't know about VirtualDub.params.
First you need a special script template file: "M-vdub-avi.vcf" | CODE | VirtualDub.Open("~~1","",0); VirtualDub.audio.SetSource("~~2", ""); VirtualDub.audio.SetMode(0); VirtualDub.audio.SetInterleave(1,500,1,0,0); VirtualDub.audio.SetClipMode(1,1); VirtualDub.audio.SetEditMode(1); VirtualDub.audio.SetConversion(0,0,0,0,0); VirtualDub.audio.SetVolume(); VirtualDub.audio.SetCompression(); VirtualDub.audio.EnableFilterGraph(0); VirtualDub.video.SetInputFormat(0); VirtualDub.video.SetOutputFormat(7); VirtualDub.video.SetMode(0); VirtualDub.video.SetSmartRendering(0); VirtualDub.video.SetPreserveEmptyFrames(0); VirtualDub.video.SetFrameRate2(0,0,1); VirtualDub.video.SetIVTC(0, 0, 0, 0); VirtualDub.video.SetCompression(0x803fef15,0,10000,0); VirtualDub.video.filters.Clear(); VirtualDub.audio.filters.Clear(); VirtualDub.project.ClearTextInfo(); VirtualDub.SaveAVI("~~3"); VirtualDub.Close(); |
Now the BAT file, which does some search-and-replace work on the script template before calling vdub.exe. Requires FART.exe (Find And Replace Text) "M-vdub-avi.bat" | CODE | @echo off
:: ** mux with vdub.exe ** :: USAGE: video-src-path audio-src-path output-path :: NOTE: no unusual characters eg "," allowed in output-path
:: requires "fart.exe" (Find And Replace Text) :: https://sourceforge.net/projects/fart-it/
::** CONFIGURATION SECTION ** set vdubexpath=C:\VirtualDub_1,10,04\vdub.exe set scriptpath=C:\VirtualDub_1,10,04\excoders\M-vdub-avi.vcf set fartpath=C:\VirtualDub_1,10,04\excoders\fart.exe ::** END CONFIGURATION SECTION **
@echo **** MUXING: vdub ***********
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 (.avi) goto BADEXT
%~d3 cd "%~dp3" copy /y "%scriptpath%" "%~n3.vcf" "%fartpath%" -V "%~n3.vcf" ~~1 "%~dpnx1" "%fartpath%" "%~n3.vcf" ~~2 "%~dpnx2" "%fartpath%" "%~n3.vcf" ~~3 "%~dpnx3" "%fartpath%" "%~n3.vcf" \ \\
@echo %time% @echo on "%vdubexpath%" /x /s "%~n3.vcf" @echo off @echo %time% if ERRORLEVEL 1 goto DUMPARGS del /q "%~n3.vcf" exit 0
:BADARG @echo MUXER ERROR: BAD OR MISSING ARGUMENT goto DUMPARGS
:BADEXT @echo MUXER ERROR: OUTPUT FILE EXTENSION NOT .AVI goto DUMPARGS
:DUMPARGS @echo USAGE video-src-path audio-src-path output-path @echo video-src = %1 @echo audio-src = %2 @echo output = %3 exit 1 |
Here's an example encoder set: "vdub-mux-example.vdprof" | CODE | { "description": "VirtualDub external encoder profile collection", "externalEncoders": { "sets": { "avi ff MJPEG (M vdub)": { "videoEncoder": "V ff MJPEG q1 avi", "audioEncoder": "A bat ff pcm", "multiplexer": "M bat vdub avi", "description": "avi", "extension": "avi", "processPartial": true, "useOutputAsTemp": false } }, "profiles": { "A bat ff pcm": { "name": "A bat ff pcm", "program": "C:\\VirtualDub_1,10,04\\excoders\\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": true }, "M bat vdub avi": { "name": "M bat vdub avi", "program": "C:\\VirtualDub_1,10,04\\excoders\\M-vdub-avi.bat", "commandArguments": "\"%(tempvideofile)\" \"%(tempaudiofile)\" \"%(outputname)\"", "outputFilename": "%(outputname).audio", "type": 2, "inputFormat": 0, "checkReturnCode": true, "logStdout": true, "logStderr": true, "bypassCompression": false, "predeleteOutputFile": true }, "V ff MJPEG q1 avi": { "name": "V ff MJPEG q1 avi", "program": "C:\\Program Files\\ffmpeg\\bin\\ffmpeg.exe", "commandArguments": "-f rawvideo -s %(width)x%(height) -r %(fps) -i - -c:v mjpeg -q:v 1 -qmin 1 -pix_fmt yuvj420p -vf \"format=yuv420p\" \"%(tempvideofile)\"", "outputFilename": "%(outputname).avi", "type": 0, "inputFormat": 0, "checkReturnCode": true, "logStdout": true, "logStderr": true, "bypassCompression": false, "predeleteOutputFile": true } } } } | Edit: Fix typo @ "if ERRORLEVEL"
This post has been edited by raffriff42 on Jul 24 2014, 01:31 PM |
 |
|