VideoHelp Forum
+ Reply to Thread
Results 1 to 6 of 6
Thread
  1. Member
    Join Date
    Apr 2007
    Location
    United States
    Search Comp PM
    I have a folder of 81 HEVC videos with AAC 5.1 audio. I want the audio to be downmixed to stereo, keeping the bitrate and other parameters for the audio.

    I know VidCoder can do it easily, but I've not been impressed with its audio handling. I keep getting a 'swishy' sound from it so I've just been doing passthrough then using AVIdemux to downmix one. at. a. time. But that adds even more work because I have to use MKVtoolnix to mux the subtitles and chapters back in that AVIdemux cannot be set to leave in, after using gMKVextract to extract then ASSTOSRT to convert the subtitles back to SRT because VidCoder cannot be set to NOT convert subtitles to ASS format.

    Anyway...

    Command line batch command for AVIdemux to just downmix audio to stereo? I'll just have to put up with having to mux the subtitles back in.
    Quote Quote  
  2. I would do this with ffmpeg and HRTF filter - works for me better than simple downmixing. You will need ffmpeg with sofalizer enabled and sofa file "dodeca_and_7channel_3DSL_HRTF.sofa" available in VLC pack for example (no need to install just search inside portable VLC)
    Code:
    @setlocal
    @set FF=C:\FF
    @set PATH=%FF%;%PATH%
    
    @set faudio=%~1
    
    @set aproc="aformat=channel_layouts=7.1,aresample=resampler=soxr:osr=48000:cutoff=0.99:dither_method=0,sofalizer=sofa=dodeca_and_7channel_3DSL_HRTF.sofa:gain=11:lfegain=9"
    
    @ffmpeg.exe -hide_banner -v 32 -stats -y -i "%faudio%" -c:v? copy -c:s? copy -c:d? copy -c:a libfdk_aac -b:a 128k -af %aproc% -f matroska "%~n1_.mkv"
    
    @endlocal
    Quote Quote  
  3. Member
    Join Date
    Apr 2007
    Location
    United States
    Search Comp PM
    Don't have to use @ on every line. Just use @ECHO OFF at the start.

    I do NOT want to resample, I want to just downmix to stereo, with AVIdemux, with a batch file. That works well enough for me because it doesn't muck up the sound quality. If I asked how to do the job with FFMPEG I wouldn't expect answers on how to do it with AVIdemux. :P

    Originally Posted by pandy View Post
    I would do this with ffmpeg and HRTF filter - works for me better than simple downmixing. You will need ffmpeg with sofalizer enabled and sofa file "dodeca_and_7channel_3DSL_HRTF.sofa" available in VLC pack for example (no need to install just search inside portable VLC)
    Code:
    @setlocal
    @set FF=C:\FF
    @set PATH=%FF%;%PATH%
    
    @set faudio=%~1
    
    @set aproc="aformat=channel_layouts=7.1,aresample=resampler=soxr:osr=48000:cutoff=0.99:dither_method=0,sofalizer=sofa=dodeca_and_7channel_3DSL_HRTF.sofa:gain=11:lfegain=9"
    
    @ffmpeg.exe -hide_banner -v 32 -stats -y -i "%faudio%" -c:v? copy -c:s? copy -c:d? copy -c:a libfdk_aac -b:a 128k -af %aproc% -f matroska "%~n1_.mkv"
    
    @endlocal
    Quote Quote  
  4. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    I expect you'd do it with the audio-process and filters arguments. Have a look here and here.
    Quote Quote  
  5. Member
    Join Date
    Apr 2007
    Location
    United States
    Search Comp PM
    Originally Posted by JVRaines View Post
    I expect you'd do it with the audio-process and filters arguments. Have a look here and here.
    This is the project output I get from loading one video, setting the audio to LavAAC, filter to downmix to stereo. Can this be modified to load and process all videos in a folder one after the other? What if I replace the file name Video 01x01.mkv with *.mkv ? Will it load all of them and append them all together?

    If not, what's the batch file equivalent? I see nothing in the command list on that page about audio mixing.

    Code:
    #PY  <- Needed to identify #
    #--automatically built--
    
    adm = Avidemux()
    adm.loadVideo("G:/TV Shows/Show1/Video 01x01.mkv")
    adm.clearSegments()
    adm.addSegment(0, 0, 3637822708)
    adm.markerA = 0
    adm.markerB = 3637822708
    adm.videoCodec("Copy")
    adm.audioClearTracks()
    adm.setSourceTrackLanguage(0,"und")
    adm.audioAddTrack(0)
    adm.audioCodec(0, "LavAAC");
    adm.audioSetMixer(0, "STEREO");
    adm.audioSetDrc(0, 0)
    adm.audioSetShift(0, 0,0)
    adm.setContainer("MKV", "forceDisplayWidth=False", "displayWidth=1280", "displayAspectRatio=0")
    Quote Quote  
  6. Member
    Join Date
    Apr 2007
    Location
    United States
    Search Comp PM
    Finally found how to batch the job with this py file

    Code:
    #PY  <- Needed to identify #
    #--automatically built--
    
    adm = Avidemux()
    adm.videoCodec("Copy")
    adm.audioClearTracks()
    adm.setSourceTrackLanguage(0,"Eng")
    adm.audioAddTrack(0)
    adm.audioCodec(0, "LavAAC");
    adm.audioSetMixer(0, "STEREO");
    adm.audioSetDrc(0, 0)
    adm.audioSetShift(0, 0,0)
    adm.setContainer("MKV", "forceDisplayWidth=False", "displayWidth=1280")
    run by this batch file
    Code:
    set avidemux="C:\Program Files\Avidemux 2.7 - 64 bits\avidemux_cli.exe"
    for %%f in (*.mkv) do %avidemux% --load "%%f" --run fbx.py --save "%%f.mkv" --quit
    But alas, AVIdemux make utter hash out of the audio, lowers the pitch and throws in a syncopated pulsing. I tried it just doing one file with the GUI, changing only the codec to AAC (LAV) and checking the box to downmix to stereo. Same garbage out. Also tried AAC (FDK) and Opus. All three have exactly the same garbage output from these videos. The space savings will be quite a bit IF there's a way to make it do the downmix properly.

    Audio info from MediaInfo
    Code:
    ID : 2 
    Format : AAC LC SBR 
    Format/Info : Advanced Audio Codec Low Complexity with Spectral Band Replication 
    Commercial name : HE-AAC 
    Format settings : NBC 
    Codec ID : A_AAC-5 
    Duration : 43 min 15 s 
    Channel(s) : 6 channels 
    Channel layout : C L R Ls Rs LFE 
    Sampling rate : 48.0 kHz 
    Frame rate : 23.438 FPS (2048 SPF) 
    Compression mode : Lossy 
    Delay relative to video : -105 ms 
    Title : Surround 
    Language : English 
    Default : Yes 
    Forced : No
    video info

    Code:
    ID : 1 
    Format : HEVC 
    Format/Info : High Efficiency Video Coding 
    Format profile : Main@L4@Main 
    Codec ID : V_MPEGH/ISO/HEVC 
    Duration : 43 min 15 s 
    Width : 1 280 pixels 
    Height : 718 pixels 
    Display aspect ratio : 16:9 
    Frame rate mode : Constant 
    Frame rate : 23.976 (24000/1001) FPS 
    Color space : YUV 
    Chroma subsampling : 4:2:0 
    Bit depth : 8 bits 
    Writing library : x265 1.8:[Windows][GCC 4.9.0][64 bit] 8bit 
    Encoding settings : wpp / ctu=64 / min-cu-size=8 / max-tu-size=32 / tu-intra-depth=3 / tu-inter-depth=3 / me=3 / subme=4 / merange=57 / no-rect / no-amp / max-merge=4 / temporal-mvp / no-early-skip / rdpenalty=0 / no-tskip / no-tskip-fast / strong-intra-smoothing / no-lossless / no-cu-lossless / no-constrained-intra / no-fast-intra / open-gop / no-temporal-layers / interlace=0 / keyint=240 / min-keyint=24 / scenecut=40 / rc-lookahead=40 / lookahead-slices=0 / bframes=8 / bframe-bias=0 / b-adapt=2 / ref=5 / limit-refs=0 / weightp / weightb / aq-mode=1 / qg-size=32 / aq-strength=1.00 / cbqpoffs=0 / crqpoffs=0 / rd=6 / psy-rd=0.30 / rdoq-level=2 / psy-rdoq=1.00 / signhide / deblock / sao / no-sao-non-deblock / b-pyramid / cutree / rc=crf / crf=24.0 / qcomp=0.60 / qpmin=0 / qpmax=51 / qpstep=4 / ipratio=1.40 / pbratio=1.30 
    Default : Yes 
    Forced : No 
    Color range : Limited 
    Color primaries : BT.709 
    Transfer characteristics : BT.709 
    Matrix coefficients : BT.709
    Last edited by bizzybody; 30th Jan 2019 at 03:44.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!