Jump to content

Adjust bitrate for transcoded audio such as Dolby AC-3


Charlie117

Recommended Posts

Charlie117

Ok, I'm the sole person

 

Who else in this thread is supporting your controversial opinion then? Please do quote them.

 

It's great that you were able to help certain users on this forum with issues that were resolved by forcing a transcode to AC-3 384 kbps. But that doesn't mean 640 kbps isn't generally supported.

 

Calling this suggestion a bad idea just because you were proven wrong is seriously petty though.

Edited by Charlie117
Link to comment
Share on other sites

Guest asrequested

I'm not wrong. Less and less devices have an optical port. It's an antiquated standard. Just because at the pinnacle, it's possible, how many manufacturers will actually invest in the later standards when HDMI is ubiquitous? Very few. So what that means is that most optical solutions provided in the real world, will be crap. Which translates to more emby users having playback issues. You really think going backwards in tech is the way forward? I don't even have single device that now has an optical port. Nvidia Shield dumped it long ago. Some of the crap Chinese stuff has it. TVs have an optical output, but again how many have the newer standard. Not very many. And even if they did, the OS would need to recognize it and take a gamble that what's on the other end, also supports it. This spells nothing but problems.

Link to comment
Share on other sites

Jdiesel

Optical out from a TV to a soundbar is still extremely common especially for low end market.

Link to comment
Share on other sites

Guest asrequested

Optical out from a TV to a soundbar is still extremely common especially for low end market.

Yes it is, and how many times have we seen on here people reporting audio problems because they are using optical? It's not like HDMI where it reports it capabilities. It's spin the wheel and see if it works. And if it doesn't, there's loss of audio, either a few channels or the whole thing.

Link to comment
Share on other sites

Charlie117

 It's an antiquated standard.

 

Well, at least we agree on that.

 

My original request was for an option to select 640 kbps instead of the default 384 kbps. That really shouldn't be an issue for anyone, because again 640 kbps is completely supported by the standard, but for those rare cases that it does cause problems, people can just revert to the default low bitrate 384 kbps. Win-win for everybody.

 

Interestingly enough, these people with the aforementioned issues with 640 kbps should not be able to watch DVDs, Blu-rays, Netflix, Amazon Prime, Disney+ etc. because they all use either a DD+ 5.1 at even higher bitrates that get automatically converted to DD 5.1 640 kbps or they get a DD 5.1 640 kbps natively. By your reasoning, DTS 5.1 core 1509 shouldn't be supported at all. I wonder why I am not reading a ton of issues with all this... probably because it isn't an issue :)

Edited by Charlie117
  • Like 1
Link to comment
Share on other sites

  • 3 months later...
zeroprobe

I echo the request. Custom bitrate would be a great feature. Or a convert to dd+

Edited by zeroprobe
  • Like 3
Link to comment
Share on other sites

FrostByte

+1 for custom bitrate and choosing which audio format.  I like DD+ for TV.

 

This should apply to music also though.  The Shield seems to convert lossless WMA to 128bit AAC.  I would prefer mp3 and something a little higher than 128 bits

  • Like 1
Link to comment
Share on other sites

zeroprobe

I've managed to mod the lib where the audio bitrate is. It won't be ideal to do every update.

So now my movies with DTS get transcoded to 640K AC3.

 

The file in question.

Emby.Server.MediaEncoding.dll

 

TranscodingCommandBuilder

TranscodingCommandBuilderLegacy

 

I've done it for the Synology version.

 

 

>>>>> Legacy Command

 

/var/packages/EmbyServer/target/ffmpeg/bin/ffmpeg -ss 00:07:48.000 -f matroska -i "http://127.0.0.1:8096/Items/File?Id=smb%3A%2F%2F192.168.1.100%2Fmedia_external.mkv"-threads 0 -map 0:0 -map 0:1 -c:v:0 copy -copyts -vsync -1 -codec:a:0 ac3 -metadata:s:a:0 language=eng -disposition:a:0 default -ac:a:0 6 -ab:a:0 640000 -ar:a:0 48000 -f segment -max_delay 5000000 -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 -start_at_zero -segment_time 6 -segment_time_delta -468 -individual_header_trailer 0 -segment_format mpegts -segment_write_temp 1 -segment_list_type m3u8 -segment_start_number 78 -segment_list "/var/packages/EmbyServer/target/var/transcoding-temp/6E62D8.m3u8" -y "/var/packages/EmbyServer/target/var/transcoding-temp/6E62D8_%d.ts"

>>>>> Actual Command

/var/packages/EmbyServer/target/ffmpeg/bin/ffmpeg -loglevel +timing -y -print_graphs_file /var/packages/EmbyServer/target/var/logs/ffmpeg-remux-483e1018-f98a-4d2e-8a2b-d0f63c61bafc_1graph.txt -copyts -start_at_zero -f matroska,webm -ss 00:07:48.000 -c:v:0 hevc -i "http://127.0.0.1:8096/Items/File?Id=smb%3A%2F%2F192.168.1.100%2Fmedia_external%2F.mkv"-map 0:0 -map 0:1 -sn -c:v:0 copy -c:a:0 ac3 -ab:a:0 640000 -ar:a:0 48000 -ac:a:0 6 -metadata:s:a:0 language=eng -disposition:a:0 default -max_delay 5000000 -avoid_negative_ts disabled -f segment -map_metadata -1 -map_chapters -1 -segment_format mpegts -segment_list /var/packages/EmbyServer/target/var/transcoding-temp/6E62D8.m3u8 -segment_list_type m3u8 -segment_time 6 -segment_time_delta -00:07:48.000 -segment_start_number 78 -individual_header_trailer 0 -write_header_trailer 0 -segment_write_temp 1 "/var/packages/EmbyServer/target/var/transcoding-temp/6E62D8_%d.ts"

Edited by zeroprobe
  • Like 1
Link to comment
Share on other sites

zeroprobe

If anyone wants to try this mod until something official comes. Patch seems to find ok for x86/x64 variants Windows / Synology tested, if the below search is found it should be fine.

 

Just find a Hex editor that supports a wildcard search for example Hex Workshop or Winhex.

 

Find and open Emby.Server.MediaEncoding.dll

On Synology, you need to copy to your NAS share location to edit it and put back after editing.

 

In Synology this is located below, your volume name may be different.

/volume1/@appstore/EmbyServer/releases/4.5.0.5-beta/

Telnet / SSH into Synology

sudo su

ls -l /

Find volume name

cd /volume1/@appstore/EmbyServer/4*/

cp Emby.Server.MediaEncoding.dll /volume1/MyNASShare (Your share name will be what you called it)

Open in Hex Workshop / Winhex.

 

Hex Workshop: using as a wildcard ??

Search  - 120A28??01000A2000EE020028??02000A289000000A2B18120A120A28??01000A2000DC050028??02000A
Replace - 000000000000002000C409000000000000289000000A2B18120A000000000000002000C409000000000000

WinHex : using as a wildcard 58

Search  - 120A285801000A2000EE0200285802000A289000000A2B18120A120A285801000A2000DC0500285802000A
Replace - 000000000000002000C409000000000000289000000A2B18120A000000000000002000C409000000000000

Copy Emby.Server.MediaEncoding.dll back to original location

 

e.g Synology

cd /volume1/MyNASShare (Your share name will be what you called it)

cp -i Emby.Server.MediaEncoding.dll /volume1/@appstore/EmbyServer/4*/

Should be prompted y to overwrite.

Restart the Emby Server, in Synology - Package Center > Installed > Stop | Start

 

The remux log should now say, I've copied a transcoded TS and checked verified also.

09:45:13.064 Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1, fltp (24 bit), 640 kb/s (default)

 

Have fun

Edited by zeroprobe
  • Like 2
Link to comment
Share on other sites

cybergrimes

Me too for this as a configurable option.

Edited by cybergrimes
Link to comment
Share on other sites

  • 4 months later...
Charlie117
On 12/04/2020 at 14:52, zeroprobe said:

I echo the request. Custom bitrate would be a great feature. Or a convert to dd+

Dolby Digital Plus would be even better, especially now that ffmpeg supports it. DD+ is also backwards compatible with DD only devices:

Is Dolby Digital Plus content backward-compatible?
Because Dolby Digital Plus is built on core Dolby Digital technologies, content that is encoded with Dolby Digital Plus is fully compatible with the millions of existing home theaters and playback systems worldwide equipped for Dolby Digital playback. Dolby Digital Plus soundtracks are easily converted to a 640 kbps Dolby Digital signal without decoding and reencoding, for output via S/PDIF. The 640 kbps bit rate, which is higher than the standard 448 kbps used on DVDs, is fully compatible with all existing Dolby Digital decoding products such as A/V receivers, and can provide higher-than-DVD quality from Dolby Digital Plus soundtracks when played back through existing systems.
https://www.dolby.com/uploadedFiles/Assets/US/Doc/Professional/dolby-digital-plus-faq.pdf

  • Like 1
Link to comment
Share on other sites

  • 2 months later...
staticmotion

I'll add my vote to this feature - both configurable bitrate and format would be appreciated. I am using a couple of Samsung TVs which don't support DTS; I'd prefer Emby server to transcode to PCM rather than relatively low bitrate AC3 - especially for the 7.1 soundtracks!

thanks

 

 

 

Edited by staticmotion
typo
Link to comment
Share on other sites

FrostByte
On 11/30/2020 at 2:32 PM, staticmotion said:

I'll add my vote to this feature - both configurable bitrate and format would be appreciated. I am using a couple of Samsung TVs which don't support DTS; I'd prefer Emby server to transcode to PCM rather than relatively low bitrate AC3 - especially for the 7.1 soundtracks!

thanks

 

 

 

Samsung TVs (and most others) only support PCM 2.0 though.  I would much rather have DD 5.1 at 640 kbps or DD+ 5.1 at 1536 kbps

Link to comment
Share on other sites

  • 3 months later...
alphanet
On 4/12/2020 at 5:07 PM, zeroprobe said:

I've managed to mod the lib where the audio bitrate is. It won't be ideal to do every update.

So now my movies with DTS get transcoded to 640K AC3.

 

The file in question.

Emby.Server.MediaEncoding.dll

 

TranscodingCommandBuilder

TranscodingCommandBuilderLegacy

 

I've done it for the Synology version.

 

 

>>>>> Legacy Command

 

/var/packages/EmbyServer/target/ffmpeg/bin/ffmpeg -ss 00:07:48.000 -f matroska -i "http://127.0.0.1:8096/Items/File?Id=smb%3A%2F%2F192.168.1.100%2Fmedia_external.mkv"-threads 0 -map 0:0 -map 0:1 -c:v:0 copy -copyts -vsync -1 -codec:a:0 ac3 -metadata:s:a:0 language=eng -disposition:a:0 default -ac:a:0 6 -ab:a:0 640000 -ar:a:0 48000 -f segment -max_delay 5000000 -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 -start_at_zero -segment_time 6 -segment_time_delta -468 -individual_header_trailer 0 -segment_format mpegts -segment_write_temp 1 -segment_list_type m3u8 -segment_start_number 78 -segment_list "/var/packages/EmbyServer/target/var/transcoding-temp/6E62D8.m3u8" -y "/var/packages/EmbyServer/target/var/transcoding-temp/6E62D8_%d.ts"

>>>>> Actual Command

/var/packages/EmbyServer/target/ffmpeg/bin/ffmpeg -loglevel +timing -y -print_graphs_file /var/packages/EmbyServer/target/var/logs/ffmpeg-remux-483e1018-f98a-4d2e-8a2b-d0f63c61bafc_1graph.txt -copyts -start_at_zero -f matroska,webm -ss 00:07:48.000 -c:v:0 hevc -i "http://127.0.0.1:8096/Items/File?Id=smb%3A%2F%2F192.168.1.100%2Fmedia_external%2F.mkv"-map 0:0 -map 0:1 -sn -c:v:0 copy -c:a:0 ac3 -ab:a:0 640000 -ar:a:0 48000 -ac:a:0 6 -metadata:s:a:0 language=eng -disposition:a:0 default -max_delay 5000000 -avoid_negative_ts disabled -f segment -map_metadata -1 -map_chapters -1 -segment_format mpegts -segment_list /var/packages/EmbyServer/target/var/transcoding-temp/6E62D8.m3u8 -segment_list_type m3u8 -segment_time 6 -segment_time_delta -00:07:48.000 -segment_start_number 78 -individual_header_trailer 0 -write_header_trailer 0 -segment_write_temp 1 "/var/packages/EmbyServer/target/var/transcoding-temp/6E62D8_%d.ts"

I've tried to do this, but I don't know exactly how to do it, I'm using DnSpy to edit the Emby.Server.MediaEncoding.dll file. Please need help

Link to comment
Share on other sites

  • 2 months later...
  • 3 months later...

I'd like this too. I would like all my transcoding to ac3 to be 640 kbps. I opened a separate thread just to figure out what was going on.

 

Link to comment
Share on other sites

I came up with my own solution today that will force all Dolby Digital (ac3) transcoding to 640 kbps. I tried converting it to Dolby Digital Plus (eac3) but quickly found out that ffmpeg unfortunately doesn't have a very good DD+ encoder. It's something like 500$ a year per machine for Dolby's official encoder I think. Ergh gross.

My solution involves replacing ffmpeg with a C program that modifies the arguments and then runs ffmpeg. I've built it on top of the Docker image so that I don't have to replace my host's ffmpeg binary or anything.

  • If using docker-compose.yml
    • Make a folder named build and place the two attached files below into it
    • Replace image: emby/embyserver:latest with build: ./build
    • When running docker-compose up -d, it will automatically build and start
    • To force a build (for new Emby versions) run docker-compose build and up -d
       
  • If you're not using Docker (not recommended unless its in a VM or on an individual machine)
    • Find ffmpeg (which ffmpeg) and rename to _ffmpeg. It might be in /usr/bin or /bin
    • Download ffmpeg.c and update line 42 with your ffmpeg path
    • Run  gcc -static -O3 -o ffmpeg ffmpeg.c
    • Move newly compiled ffmpeg binary to original ffmpeg path

Just to explain what the C program does, it looks for arguments -c:a:? ac3 then replaces -ab:a:? ?????? with -ab:a:? 640000

I hope this helps someone! I'm super happy with my solution.

Dockerfile ffmpeg.c

Edited by MakiXx
Link to comment
Share on other sites

On 5/14/2021 at 6:34 AM, alphanet said:

Please, we need the option for choose the bitrate for DTS transcoding 

For the people above who'd like to transcode to DTS instead, I could modify the C file to replace DD with DTS and a forced bitrate. Then the "Convert Unsupported Audio to Dolby Digital" settings would convert to DTS instead haha. My sound system only supports Dolby and PCM.

Link to comment
Share on other sites

staticmotion
On 8/23/2021 at 7:00 PM, MakiXx said:

For the people above who'd like to transcode to DTS instead, I could modify the C file to replace DD with DTS and a forced bitrate. Then the "Convert Unsupported Audio to Dolby Digital" settings would convert to DTS instead haha. My sound system only supports Dolby and PCM.

To be honest a Windows version would be more useful! Encoding to DTS isn't a good idea as most of the people are having to re-encode because their TV doesn't accept DTS.

 

Link to comment
Share on other sites

6 hours ago, staticmotion said:

To be honest a Windows version would be more useful! Encoding to DTS isn't a good idea as most of the people are having to re-encode because their TV doesn't accept DTS.

 

I've made a GitHub repo with instructions and Windows/Linux builds of my wrapper through GitHub actions so that it's verifiably legit. Let me know if you need help.

https://github.com/makitsune/emby-custom-ac3-bitrate

  • Thanks 1
Link to comment
Share on other sites

  • 7 months later...
cwills75
On 8/24/2021 at 7:51 PM, MakiXx said:

I've made a GitHub repo with instructions and Windows/Linux builds of my wrapper through GitHub actions so that it's verifiably legit. Let me know if you need help.

https://github.com/makitsune/emby-custom-ac3-bitrate

Any idea how to make this work with Unraid docker version of Emby?  I tried editing the hex values from a post above, but it seems some of them have changed since that post as I can't find the same string.  I'm hoping your method will work, but have no idea what to do with the github files.

Edited by cwills75
Link to comment
Share on other sites

cwills75
On 1/7/2020 at 10:25 AM, Luke said:

Thanks for the feedback. More options are possible for the future.

Any update on allowing a custom/higher bitrate for transcoded audio.  I wasn't even aware this was an issue until recently, but I have a few clients on Apple TV with receivers that are stuck playing AC3 384kb/s with any DTS files.  I was aware the Apple TV doesn't bitstream DTS/DTS-HD MA/DTS-X, but was never aware of the low bitrate until seeing this post and looking in the log files.  Even the streaming info when the file is being played doesn't show audio transcoding going on.  It says direct streaming, which isn't really accurate.

Screenshot_4.png

adam1.txt

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...