Help with Script issue is Audio is dropping bitrate

Discussion of the HandBrake command line interface (CLI)
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
Drudge8303
Posts: 3
Joined: Wed Apr 26, 2023 4:59 pm

Help with Script issue is Audio is dropping bitrate

Post by Drudge8303 »

Description of problem or question:
I have a script that loops through ISO files and extracts the videos before passing to Handbrake to convert.
I am using a custom profile based on the 480P profile but set to X265 format in the Automatic Audio Selections I have set Auto Passthrough to AAC and AC3 and selected Language to English.
Under the encoder section I have it set to AC3 Passthrough and Bitrate of 192 kbps Stereo Auto 0 0

However when it converts using the CLI JSON file the file the audio is downgraded to 129 kbps
Using the GUI and the same profile it converts to 192 kbps

I am not sure what the cause is or how to get the audio passed through automatically without it changing the audio at all

Any ideas?


Steps to reproduce the problem (If Applicable):
Convert a video file using custom profile

Script used

Code: Select all

# loop through each file in the extracted directory and convert using Handbrake
    foreach ($file in Get-ChildItem -Path $extractedDir -Recurse -Include *.mkv) {
        # set the output filename based on the input filename
        $outFile = Join-Path -Path $convertedDir -ChildPath ($file.Name.Replace(".mkv", ".mp4"))
        
        # run Handbrake using the custom profile and output to the converted directory
        & $handbrake -i $file.FullName -o $outFile --preset-import-file "D:\customprofile.json"
    }
HandBrake version (e.g., 1.0.0):

1.6.1 (2023012300)


Operating system and version (e.g., Ubuntu 16.04 LTS, macOS 10.13 High Sierra, Windows 10 Creators Update):

Windows 11 Pro


HandBrake Activity Log ***required*** (see How-to get an activity log)

Code: Select all

HandBrakeCLI.exe : [17:32:15] Compile-time hardening features are enabled
At line:36 char:9
+         & $handbrake -i $file.FullName -o $outFile --preset-import-fi ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: ([17:32:15] Comp...res are enabled:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
[17:32:16] qsv: is available on this system
[17:32:16] vcn: not available on this system
[17:32:16] nvenc: version 12.1 is available
[17:32:16] nvdec: is available
[17:32:16] hb_init: starting libhb thread
[17:32:16] thread 1 started ("libhb")
HandBrake 1.6.1 (2023012300) - MinGW x86_64 - https://handbrake.fr
12 CPUs detected
Opening D:\Temp\ISO\Test\V1D1 - My First Adventure.ISO-extracted\B1_t00.mkv...
[17:32:16] CPU: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
[17:32:16]  - Intel microarchitecture Kaby Lake
[17:32:16]  - logical processor count: 12
[17:32:16] Intel Quick Sync Video support: yes, gpu list: 0
[17:32:16] Intel Quick Sync Video integrated adapter with index 0
[17:32:16] Impl mfxhw64 library path: C:\WINDOWS\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_362cfac2b6e1097f\libmfxhw64.dll
[17:32:16]  - Intel Media SDK hardware: API 1.35 (minimum: 1.3)
[17:32:16]  - Decode support:  h264 hevc (8bit: yes, 10bit: yes)
[17:32:16]  - H.264 encoder: yes
[17:32:16]     - preferred implementation: hardware (1) via D3D11
[17:32:16]     - capabilities (hardware):  breftype icq+la+i+downs vsinfo chromalocinfo opt1 opt2+mbbrc+extbrc+trellis+repeatpps+ib_adapt+nmpslice
[17:32:16]  - H.265 encoder: yes (8bit: yes, 10bit: yes)
[17:32:16]     - preferred implementation: hardware (1) via D3D11
[17:32:16]     - capabilities (hardware):  bpyramid icq vsinfo masteringinfo cllinfo opt1
[17:32:16]  - AV1 encoder: no
[17:32:16] hb_scan: path=D:\Temp\ISO\Test\V1D1 - My First Adventure.ISO-extracted\B1_t00.mkv, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
src/libbluray/disc/disc.c:333: failed opening UDF image D:\Temp\ISO\Test\V1D1 - My First Adventure.ISO-extracted\B1_t00.mkv
src/libbluray/disc/disc.c:437: error opening file BDMV\index.bdmv
src/libbluray/disc/disc.c:437: error opening file BDMV\BACKUP\index.bdmv
[17:32:16] bd: not a bd - trying as a stream/file instead
libdvdread: DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: vm: failed to read VIDEO_TS.IFO
[17:32:16] dvd: not a dvd - trying as a stream/file instead
Input #0, matroska,webm, from 'D:\Temp\ISO\Test\V1D1 - My First Adventure.ISO-extracted\B1_t00.mkv':
  Metadata:
    encoder         : libmakemkv v1.17.3 (1.3.10/1.5.2) win(x64-release)
    creation_time   : 2023-04-26T16:24:51.000000Z
  Duration: 01:25:52.15, start: 0.000000, bitrate: 3407 kb/s
  Chapters:
    Chapter #0:0: start 0.000000, end 625.291333
      Metadata:
        title           : Chapter 01
    Chapter #0:1: start 625.291333, end 1233.398833
      Metadata:
        title           : Chapter 02
    Chapter #0:2: start 1233.398833, end 1807.806000
      Metadata:
        title           : Chapter 03
    Chapter #0:3: start 1807.806000, end 2439.270167
      Metadata:
        title           : Chapter 04
    Chapter #0:4: start 2439.270167, end 3014.177833
      Metadata:
        title           : Chapter 05
    Chapter #0:5: start 3014.177833, end 3580.577000
      Metadata:
        title           : Chapter 06
    Chapter #0:6: start 3580.577000, end 4213.375833
      Metadata:
        title           : Chapter 07
    Chapter #0:7: start 4213.375833, end 4877.906367
      Metadata:
        title           : Chapter 08
    Chapter #0:8: start 4877.906367, end 5085.580500
      Metadata:
        title           : Chapter 09
    Chapter #0:9: start 5085.580500, end 5152.147000
      Metadata:
        title           : Chapter 10
  Stream #0:0(eng): Video: mpeg2video (Main), yuv420p(tv, smpte170m, progressive), 720x480 [SAR 8:9 DAR 4:3], 29.97 fps, 29.97 tbr, 1k tbn
    Metadata:
      BPS-eng         : 3207988
      DURATION-eng    : 01:25:52.147000000
      NUMBER_OF_FRAMES-eng: 123528
      NUMBER_OF_BYTES-eng: 2066003249
      SOURCE_ID-eng   : 0100E0
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.17.3 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2023-04-26 16:24:51
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Side data:
      cpb: bitrate max/min/avg: 9800000/0/0 buffer size: 1835008 vbv_delay: N/A
  Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
    Metadata:
      title           : Stereo
      BPS-eng         : 192000
      DURATION-eng    : 01:25:52.160000000
      NUMBER_OF_FRAMES-eng: 161005
      NUMBER_OF_BYTES-eng: 123651840
      SOURCE_ID-eng   : 0180BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.17.3 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2023-04-26 16:24:51
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
  Stream #0:2(eng): Subtitle: dvd_subtitle, 720x480 (default)
    Metadata:
      BPS-eng         : 3247
      DURATION-eng    : 01:24:32.100088888
      NUMBER_OF_FRAMES-eng: 972
      NUMBER_OF_BYTES-eng: 2058704
      SOURCE_ID-eng   : 0120BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.17.3 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2023-04-26 16:24:51
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
[17:32:16] scan: decoding previews for title 1
[17:32:16] scan: audio 0x1: ac3, rate=48000Hz, bitrate=192000 English (AC3) (2.0 ch) (192 kbps)
[17:32:16] scan: 10 previews, 720x480, 23.976 fps, autocrop = 0/2/6/4, aspect 4:3, PAR 8:9, color profile: 6-6-6, chroma location: left
[17:32:16] scan: supported video decoders: avcodec nvdec
[17:32:16] libhb: scan thread found 1 valid title(s)
+ Using preset: CLI Default
+ title 1:
  + stream: D:\Temp\ISO\Test\V1D1 - My First Adventure.ISO-extracted\B1_t00.mkv
  + duration: 01:25:52
  + size: 720x480, pixel aspect: 8/9, display aspect: 1.33, 23.976 fps
  + autocrop: 0/2/6/4
  + chapters:
    + 1: duration 00:10:25
    + 2: duration 00:10:08
    + 3: duration 00:09:34
    + 4: duration 00:10:31
    + 5: duration 00:09:35
    + 6: duration 00:09:26
    + 7: duration 00:10:33
    + 8: duration 00:11:05
    + 9: duration 00:03:28
    + 10: duration 00:01:07
  + audio tracks:
    + 1, English (AC3) (2.0 ch) (192 kbps) (iso639-2: eng), 48000Hz, 192000bps
  + subtitle tracks:
    + 1, English [VOBSUB]
[17:32:16] Starting work at: Wed Apr 26 17:32:16 2023
[17:32:16] 1 job(s) to process
[17:32:16] json job:
{
    "Audio": {
        "AudioList": [
            {
                "Bitrate": 128,
                "CompressionLevel": -1.0,
                "DRC": 0.0,
                "DitherMethod": "auto",
                "Encoder": "av_aac",
                "Gain": 0.0,
                "Mixdown": "stereo",
                "Name": "Stereo",
                "NormalizeMixLevel": false,
                "PresetEncoder": "av_aac",
                "Quality": -3.0,
                "Samplerate": 0,
                "Track": 0
            }
        ],
        "CopyMask": [
            "copy:aac",
            "copy:ac3",
            "copy:eac3",
            "copy:dtshd",
            "copy:dts",
            "copy:mp3",
            "copy:truehd",
            "copy:flac"
        ],
        "FallbackEncoder": "av_aac"
    },
    "Destination": {
        "AlignAVStart": false,
        "ChapterList": [
            {
                "Duration": {
                    "Hours": 0,
                    "Minutes": 10,
                    "Seconds": 25,
                    "Ticks": 56276219
                },
                "Name": "Chapter 1"
            },
            {
                "Duration": {
                    "Hours": 0,
                    "Minutes": 10,
                    "Seconds": 8,
                    "Ticks": 54729675
                },
                "Name": "Chapter 2"
            },
            {
                "Duration": {
                    "Hours": 0,
                    "Minutes": 9,
                    "Seconds": 34,
                    "Ticks": 51696646
                },
                "Name": "Chapter 3"
            },
            {
                "Duration": {
                    "Hours": 0,
                    "Minutes": 10,
                    "Seconds": 31,
                    "Ticks": 56831774
                },
                "Name": "Chapter 4"
            },
            {
                "Duration": {
                    "Hours": 0,
                    "Minutes": 9,
                    "Seconds": 35,
                    "Ticks": 51741690
                },
                "Name": "Chapter 5"
            },
            {
                "Duration": {
                    "Hours": 0,
                    "Minutes": 9,
                    "Seconds": 26,
                    "Ticks": 50975926
                },
                "Name": "Chapter 6"
            },
            {
                "Duration": {
                    "Hours": 0,
                    "Minutes": 10,
                    "Seconds": 33,
                    "Ticks": 56951894
                },
                "Name": "Chapter 7"
            },
            {
                "Duration": {
                    "Hours": 0,
                    "Minutes": 11,
                    "Seconds": 5,
                    "Ticks": 59807748
                },
                "Name": "Chapter 8"
            },
            {
                "Duration": {
                    "Hours": 0,
                    "Minutes": 3,
                    "Seconds": 28,
                    "Ticks": 18690673
                },
                "Name": "Chapter 9"
            },
            {
                "Duration": {
                    "Hours": 0,
                    "Minutes": 1,
                    "Seconds": 7,
                    "Ticks": 5990985
                },
                "Name": "Chapter 10"
            }
        ],
        "ChapterMarkers": true,
        "File": "D:\\Temp\\ISO\\Test\\V1D1 - My First Adventure.ISO-converted\\B1_t00.mp4",
        "InlineParameterSets": false,
        "Mp4Options": {
            "IpodAtom": false,
            "Mp4Optimize": false
        },
        "Mux": "m4v"
    },
    "Filters": {
        "FilterList": [
            {
                "ID": 7,
                "Settings": {
                    "mode": 0
                }
            },
            {
                "ID": 14,
                "Settings": {
                    "crop-bottom": 2,
                    "crop-left": 6,
                    "crop-right": 4,
                    "crop-top": 0,
                    "height": 478,
                    "width": 710
                }
            }
        ]
    },
    "Metadata": {},
    "PAR": {
        "Den": 9,
        "Num": 8
    },
    "SequenceID": 0,
    "Source": {
        "Angle": 0,
        "Path": "D:\\Temp\\ISO\\Test\\V1D1 - My First Adventure.ISO-extracted\\B1_t00.mkv",
        "Range": {
            "End": 10,
            "Start": 1,
            "Type": "chapter"
        },
        "Title": 1
    },
    "Subtitle": {
        "Search": {
            "Burn": true,
            "Default": false,
            "Enable": false,
            "Forced": false
        },
        "SubtitleList": []
    },
    "Video": {
        "ChromaLocation": 1,
        "ColorInputFormat": 0,
        "ColorMatrix": 6,
        "ColorOutputFormat": 0,
        "ColorPrimaries": 6,
        "ColorRange": 1,
        "ColorTransfer": 6,
        "Encoder": "x264",
        "HardwareDecode": 0,
        "Level": "auto",
        "Options": "",
        "Preset": "medium",
        "Profile": "auto",
        "QSV": {
            "AdapterIndex": 0,
            "AsyncDepth": 0,
            "Decode": false
        },
        "Quality": 22.0,
        "Tune": "",
        "Turbo": false,
        "TwoPass": false
    }
}
[17:32:16] qsv: integrated qsv adapter with index 0 has been selected
[17:32:16] Starting Task: Encoding Pass
[17:32:16] Skipping vfr filter
[17:32:16] job configuration:
[17:32:16]  * source
[17:32:16]    + D:\Temp\ISO\Test\V1D1 - My First Adventure.ISO-extracted\B1_t00.mkv
[17:32:16]    + title 1, chapter(s) 1 to 10
[17:32:16]    + container: matroska,webm
[17:32:16]    + data rate: 3407 kbps
[17:32:16]  * destination
[17:32:16]    + D:\Temp\ISO\Test\V1D1 - My First Adventure.ISO-converted\B1_t00.mp4
[17:32:16]    + container: MPEG-4 (libavformat)
[17:32:16]      + chapter markers
[17:32:16]  * video track
[17:32:16]    + decoder: mpeg2video 8-bit (yuv420p)
[17:32:16]    + filters
[17:32:16]      + Crop and Scale (width=710:height=478:crop-top=0:crop-bottom=2:crop-left=6:crop-right=4)

[17:32:16]        + source: 720 * 480, crop (0/2/6/4): 710 * 478, scale: 710 * 478
[17:32:16]    + Output geometry
[17:32:16]      + storage dimensions: 710 x 478
[17:32:16]      + pixel aspect ratio: 8 : 9
[17:32:16]      + display dimensions: 631 x 478
[17:32:16]    + encoder: H.264 (libx264)
[17:32:16]      + preset:  medium
[17:32:16]      + profile: auto
[17:32:16]      + level:   auto
[17:32:16]      + quality: 22.00 (RF)
[17:32:16]      + color profile: 6-6-6
[17:32:16]      + chroma location: left
[17:32:16]  * audio track 1
[17:32:16]    + name: Stereo
[17:32:16]    + decoder: English (AC3) (2.0 ch) (192 kbps) (track 1, id 0x1)
[17:32:16]      + bitrate: 192 kbps, samplerate: 48000 Hz
[17:32:16]    + mixdown: Stereo
[17:32:16]    + encoder: AAC (libavcodec)
[17:32:16]      + bitrate: 128 kbps, samplerate: 48000 Hz
[17:32:16] sync: expecting 123528 video frames
[17:32:16] encx264: min-keyint: 24, keyint: 240
[17:32:16] encx264: encoding at constant RF 22.000000
x264 [info]: using SAR=8/9
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 UnalignedStack
x264 [info]: profile High, level 3.0, 4:2:0, 8-bit
[17:32:16] sync: first pts video is 0
[17:32:16] sync: "Chapter 1" (1) at frame 1 time 0
[17:32:16] sync: first pts audio 0x1 is 0
User avatar
Ritsuka
HandBrake Team
Posts: 1650
Joined: Fri Jan 12, 2007 11:29 am

Re: Help with Script issue is Audio is dropping bitrate

Post by Ritsuka »

You have to use --preset <your-preset-name> to select the preset you are importing.
Drudge8303
Posts: 3
Joined: Wed Apr 26, 2023 4:59 pm

Re: Help with Script issue is Audio is dropping bitrate

Post by Drudge8303 »

Ah so it's not

--preset-import-file "D:\customprofile.json"

But

--preset "D:\customprofile.json"

I use? Or --preset customprofile

Thanks
User avatar
Ritsuka
HandBrake Team
Posts: 1650
Joined: Fri Jan 12, 2007 11:29 am

Re: Help with Script issue is Audio is dropping bitrate

Post by Ritsuka »

No, it's both. First you load it with --preset-import-file, and then you select it with --preset, passing the name of the preset to it.
Deleted User 11865

Re: Help with Script issue is Audio is dropping bitrate

Post by Deleted User 11865 »

A JSON preset file may contain an infinite number of presets. So you still need to tell HandBrake which preset to use.
Drudge8303
Posts: 3
Joined: Wed Apr 26, 2023 4:59 pm

Re: Help with Script issue is Audio is dropping bitrate

Post by Drudge8303 »

ah thanks, got it working interestingly the convert time has tripled but the file sizes stayed the same once I added the profile name in.
Deleted User 11865

Re: Help with Script issue is Audio is dropping bitrate

Post by Deleted User 11865 »

That would be the x264 preset used (default: medium, HQ 480p: slow) as well as the interlace detection and decomb filters (to detect and remove interlacing, respectively) which are enabled in said preset you used as a base for your own.
Post Reply