mdhiggins / sickbeard_mp4_automator

Automatically convert video files to a standardized format with metadata tagging to create a beautiful and uniform media library
MIT License
1.51k stars 201 forks source link

Bug? Audio channel bitrate not respected for MKV output #1195

Closed RandomNinjaAtk closed 4 years ago

RandomNinjaAtk commented 4 years ago

So using the same exact settings for MP4 seems to work fine, but when running the same encode again, with MKV as the output, the result does not match.

Ie: In the log, it will say bitrate set at 384 (64 per channel) but after encoding, the result is 640, which matches bitrate of the original file

Settings:

[Audio]
codec = libfdk_aac, aac, mp3, opus
languages = eng
default-language = eng
first-stream-of-language = True
allow-language-relax = True
channel-bitrate = 64
max-bitrate = 0
max-channels = 0

Input file audio: EAC3 at 640k Encoded file: AAC at 640k The log actually says:

Original File:

"audio": [
        {
            "index": 1,
            "codec": "eac3",
            "channels": 6,
            "samplerate": 48000,
            "language": "eng",
            "disposition": "+default"
        }
    ],

Reported Encoding settings:
audio": [
        {
            "map": 1,
            "codec": "libfdk_aac",
            "channels": 6,
            "bitrate": 384,
            "filter": null,
            "samplerate": null,
            "language": "eng",
            "disposition": "+default",
            "bsf": null,
            "title": "5.1 Channel",
            "debug": "audio"
        },
mdhiggins commented 4 years ago

Could you post the full log?

RandomNinjaAtk commented 4 years ago

Everything looks fine in the log, it just doesn't seem to actually encode at the bitrate it says:

Force-convert is true, so convert-mp4 is being overridden to true as well
No-tagging enabled
Processing file /storage/downloads/sabnzbd/complete/sonarr/folder/90438763c96e46c4a3d9fcb99e295a54.mkv
Input Data
{
    "format": "matroska,webm",
    "format-fullname": "unknown",
    "video": {
        "index": 0,
        "codec": "h264",
        "pix_fmt": "yuv420p",
        "profile": "100",
        "fps": 23.976023976023978,
        "level": 4.0,
        "field_order": "progressive"
    },
    "audio": [
        {
            "index": 1,
            "codec": "eac3",
            "channels": 6,
            "samplerate": 48000,
            "language": "eng",
            "disposition": "+default"
        }
    ],
    "subtitle": [
        {
            "index": 2,
            "codec": "subrip",
            "disposition": null,
            "language": "eng"
        }
    ],
    "attachment": []
}
Reading video stream.
Video codec detected: h264.
Pix Fmt: yuv420p.
Profile: 100.
Reading audio streams.
Audio detected for stream 1 - eac3 eng 6 channel.
Creating libfdk_aac audio stream from source stream 1.
Copying audio stream from source stream 1 format eac3 [audio-copy-original].
Default audio stream set to eng libfdk_aac 6 channel stream [default-more-channels: True].
Reading subtitle streams.
Text-based subtitle detected for stream 2 - subrip eng.
Creating srt subtitle stream from source stream 2.
Scanned for external subtitles and found 0 results in your approved languages.
Output Data
{
    "source": [
        "/storage/downloads/sabnzbd/complete/sonarr/folder/90438763c96e46c4a3d9fcb99e295a54.mkv"
    ],
    "format": "mkv",
    "video": {
        "codec": "copy",
        "map": 0,
        "bitrate": 12000,
        "crf": -1,
        "maxrate": null,
        "bufsize": null,
        "level": 4.1,
        "profile": null,
        "pix_fmt": null,
        "field_order": "progressive",
        "width": null,
        "debug": "video"
    },
    "audio": [
        {
            "map": 1,
            "codec": "libfdk_aac",
            "channels": 6,
            "bitrate": 384,
            "filter": null,
            "samplerate": null,
            "language": "eng",
            "disposition": "+default",
            "bsf": null,
            "title": "5.1 Channel",
            "debug": "audio"
        },
        {
            "map": 1,
            "codec": "copy",
            "channels": 6,
            "language": "eng",
            "disposition": null,
            "debug": "audio-copy-original"
        }
    ],
    "subtitle": [
        {
            "map": 2,
            "codec": "srt",
            "language": "eng",
            "encoding": "",
            "disposition": "+default",
            "debug": "subtitle.embed-subs"
        }
    ],
    "attachment": []
}
Preopts
[
    "-fix_sub_duration"
]
Postopts
[
    "-threads",
    "0",
    "-metadata:g",
    "encoding_tool=SMA",
    "-level",
    "41",
    "-maxrate",
    "12000k"
]
Input and output extensions match and every codec is copy, this file probably doesn't need conversion, but conversion being forced [force-convert: True].
Starting conversion.

[                    ] 0%
[                    ] 1%
[                    ] 2%
[#                   ] 3%
[#                   ] 4%
[#                   ] 5%
[#                   ] 5%
[#                   ] 6%
[#                   ] 7%
[##                  ] 8%
[##                  ] 9%
[##                  ] 10%
[##                  ] 10%
[##                  ] 11%
[##                  ] 12%
[###                 ] 13%
[###                 ] 14%
[###                 ] 15%
[###                 ] 16%
[###                 ] 16%
[###                 ] 17%
[####                ] 18%
[####                ] 19%
[####                ] 20%
[####                ] 21%
[####                ] 21%
[####                ] 22%
[#####               ] 23%
[#####               ] 24%
[#####               ] 25%
[#####               ] 26%
[#####               ] 27%
[#####               ] 27%
[######              ] 28%
[######              ] 29%
[######              ] 30%
[######              ] 31%
[######              ] 32%
[######              ] 32%
[#######             ] 33%
[#######             ] 34%
[#######             ] 35%
[#######             ] 36%
[#######             ] 37%
[########            ] 38%
[########            ] 39%
[########            ] 39%
[########            ] 40%
[########            ] 41%
[########            ] 42%
[#########           ] 43%
[#########           ] 44%
[#########           ] 45%
[#########           ] 45%
[#########           ] 46%
[#########           ] 47%
[##########          ] 48%
[##########          ] 49%
[##########          ] 50%
[##########          ] 51%
[##########          ] 51%
[##########          ] 52%
[###########         ] 53%
[###########         ] 54%
[###########         ] 55%
[###########         ] 56%
[###########         ] 56%
[###########         ] 57%
[############        ] 58%
[############        ] 59%
[############        ] 60%
[############        ] 61%
[############        ] 62%
[#############       ] 63%
[#############       ] 63%
[#############       ] 64%
[#############       ] 65%
[#############       ] 66%
[#############       ] 67%
[##############      ] 68%
[##############      ] 69%
[##############      ] 70%
[##############      ] 70%
[##############      ] 71%
[##############      ] 72%
[###############     ] 73%
[###############     ] 74%
[###############     ] 75%
[###############     ] 76%
[###############     ] 76%
[###############     ] 77%
[################    ] 78%
[################    ] 79%
[################    ] 80%
[################    ] 81%
[################    ] 81%
[################    ] 82%
[#################   ] 83%
[#################   ] 84%
[#################   ] 85%
[#################   ] 86%
[#################   ] 86%
[#################   ] 87%
[##################  ] 88%
[##################  ] 89%
[##################  ] 90%
[##################  ] 91%
[##################  ] 92%
[##################  ] 92%
[################### ] 93%
[################### ] 94%
[################### ] 95%
[################### ] 96%
[################### ] 97%
[####################] 98%
[####################] 98%
[####################] 100%
/storage/downloads/sabnzbd/complete/sonarr/folder/90438763c96e46c4a3d9fcb99e295a54.mkv created.
mdhiggins commented 4 years ago

Is it maybe an FFMPEG problem, if you try to do the encode manually does it respect the bitrates?

mdhiggins commented 4 years ago

This might actually be FFMPEG not tagging the correct bitrate. I'm seeing similar inaccurate bitrate tags reported by MediaInfo but during playback in MPC you can see the bitrate is correct

RandomNinjaAtk commented 4 years ago

Plex reports the bitrate as 640 also

mdhiggins commented 4 years ago

Plex is just reading the tags too Looks like this is a tagging issue specific to MKVs reporting bitrate using a tag that's not being written

mdhiggins commented 4 years ago

15acef6a21be4980c1cdb8b93417da94a3ed77dd a876d3cad6efbdddb5a506b60aca6ed28f443924

Issue with FFMPEG not writing tags for MKVs and just copying them from source stream. Now should adjust bitrate tag when bitrate is present in the encoder options

MP4 files not impacted