Play external audio files in sync with video

Hi Everyone! I have been looking into this for a while and I was searching around on and off, but I came across a file
a few days ago that sparked a few things in my head and there is a way to get external audio files to work on plex!

The thing is I haven’t figured out all the details but I can tell you what I do know. The AC3 File format for the external audio does not get seen by plex indeed BUT I do have a movie with an external audio file that is seen by plex that is M4A Format and I am able to extract the info from the file that tells me the codec used and such on the file. I am testing converting an AC3 file in the attempt to get the right formula that makes the audio work like that other one I mentioned (which I did not make or encode or such btw). Here is the information from the working file:

General
Complete name : Movie Name.m4a
Format : MPEG-4
Format profile : Base Media / Version 2
Codec ID : mp42 (M4A /mp42/isom)
File size : 191 MiB
Duration : 2 h 4 min
Overall bit rate mode : Variable
Overall bit rate : 214 kb/s

Audio
ID : 1
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : HE-AAC / LC
Codec ID : 40
Duration : 2 h 4 min
Bit rate mode : Variable
Bit rate : 213 kb/s
Maximum bit rate : 268 kb/s
Channel(s) : 6 channels
Channel positions : Front: L C R, Side: L R, LFE
Sampling rate : 48.0 kHz / 24.0 kHz
Frame rate : 23.438 FPS (1024 spf)
Compression mode : Lossy
Stream size : 190 MiB (100%)
Writing library : Nero AAC codec 1.5.4.0
Encoding settings : -q 0.30

Please let me know if this helps or if you figure something out that works by using this information. Thanks! :slight_smile:

I think, with some fiddling, you can use MKVMerge (part of MKVToolNix) to add an external audio stream to an existing video file. Timing is everything I would imagine, but with MKVToolNix you can alter the delay, so if a sub-program called MKVMerge didn’t have that ‘feature’ it would be seriously lacking.

https://mkvtoolnix.download/
I’ve always found it’s pretty easy to figure this stuff out in this program, but there is some rather descriptive documentation.

@cayars may have an ffmpeg script or method already invented to do this very thing. Perhaps he’ll show up and enlighten us all.

ffmpeg could be used to merge in an external audio track as well as a few other tools. I can help with this part if it makes sense. I just briefly read the thread to try and catch up but I’m fuzzy on what you want to do and WHY? I do know there would be a delay factor we would have to figure out in order to merge it properly.

But first, give me a quick education on the usefulness of this and maybe an example or two.
Carlo

Briefly - I think the initial request was to simply play a separate audio file and have it (though some type of VooDoo Magic) sync with and replace the existing audio track.

As you’re probably about to say - that’s crazy and ain’t gonna happen.

Here’s where any number of methods to actually embed a new or additional audio track into the video file come in - a much more reasonable solution, IMO. This will have to be done outside of Plex. Expecting Plex to do that would, again, fall into the Voodoo Magic or Wishful Thinking area.

:slight_smile:

Read my comment

No one is asking for voodoo magic. Specifying an external file is a pretty common feature in video players. No one [sane] expects you to sync the audio “magically” any more than one expects Plex to sync an external subtle file.

Best you can do at present is remux the file back into main file after calculating the delay of either the external file or every other track in the main program. You have to do one or the other depending on which starts first. This is essentially a negative to positive delay for the external file.

Anyone know of any streaming server platforms that does anything like this?

I’m sure I could help with the remux part but does anyone know of any desktop program that shows how much delay is needed to keep the new audio in sync with the video? We will need that info.

Carlo

Maybe the source code for mpv can provide some insight, https://github.com/mpv-player/mpv/blob/master/player/external_files.c

@babylinux said:
Hi Everyone! I have been looking into this for a while and I was searching around on and off, but I came across a file
a few days ago that sparked a few things in my head and there is a way to get external audio files to work on plex!

The thing is I haven’t figured out all the details but I can tell you what I do know. The AC3 File format for the external audio does not get seen by plex indeed BUT I do have a movie with an external audio file that is seen by plex that is M4A Format and I am able to extract the info from the file that tells me the codec used and such on the file. I am testing converting an AC3 file in the attempt to get the right formula that makes the audio work like that other one I mentioned (which I did not make or encode or such btw). Here is the information from the working file:

General
Complete name : Movie Name.m4a
Format : MPEG-4
Format profile : Base Media / Version 2
Codec ID : mp42 (M4A /mp42/isom)
File size : 191 MiB
Duration : 2 h 4 min
Overall bit rate mode : Variable
Overall bit rate : 214 kb/s

Audio
ID : 1
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : HE-AAC / LC
Codec ID : 40
Duration : 2 h 4 min
Bit rate mode : Variable
Bit rate : 213 kb/s
Maximum bit rate : 268 kb/s
Channel(s) : 6 channels
Channel positions : Front: L C R, Side: L R, LFE
Sampling rate : 48.0 kHz / 24.0 kHz
Frame rate : 23.438 FPS (1024 spf)
Compression mode : Lossy
Stream size : 190 MiB (100%)
Writing library : Nero AAC codec 1.5.4.0
Encoding settings : -q 0.30

Please let me know if this helps or if you figure something out that works by using this information. Thanks! :slight_smile:

I did post this last night or this morning but here is a screenshot of the working file I mentioned.

Hi! I mentioned before I have a file that has an external audio file that works and shows up on plex,
It is a possible thing and it does work it just doesn’t do it with every type of external audio format
from what I can tell. Here is a screenshot of the mentioned working file and a link to my previous
comment
.

@babylinux said:
Hi! I mentioned before I have a file that has an external audio file that works and shows up on plex,

I have trouble believing this. It is more likely that the mp4 file simply contains 2 audio streams.
Please post the Plex XML info of this movie.

@OttoKerner said:

@babylinux said:
Hi! I mentioned before I have a file that has an external audio file that works and shows up on plex,

I have trouble believing this. It is more likely that the mp4 file simply contains 2 audio streams.
Please post the Plex XML info of this movie.

I have attached a txt file with the requested XML.

@OttoKerner said:

@babylinux said:
Hi! I mentioned before I have a file that has an external audio file that works and shows up on plex,

I have trouble believing this. It is more likely that the mp4 file simply contains 2 audio streams.
Please post the Plex XML info of this movie.

Well, I figured 2 things out. You were correct and I was mistaken, there are indeed 2 audio streams on the video file and the external audio file labeled as 5.1 does not show up on plex so it was a very big misunderstanding on my part. But, I believe I did find a certain way to do the external audio file thing but it’s not very convenient because plex shows it as if you have ‘more than 1 file’ rather than the 1 file and just listing the external audio. It’s easier if I just show it. I converted the .ac3 file to mp4 accidentally on one of my attempts to get the m4a file right thinking that other one had worked and plex did see it but it’s as if I had 2 movie files merged a #2 would show up on the movie list rather than just showing up as a normal single file but it did list the audio. Sorry for rambling and the misunderstanding on my part.

@babylinux said:
I converted the .ac3 file to mp4 accidentally on one of my attempts to get the m4a file right thinking that other one had worked and plex did see it but it’s as if I had 2 movie files merged a #2 would show up on the movie list rather than just showing up as a normal single file but it did list the audio.

But even then you won’t be able to play the video from the first ‘version’ together with the audio from the second ‘version’
Most likely you’ll get either a playback error or at least a black picture.

To the best of my knowledge the video and audio codecs (tracks) all need to be in the master media file. Which brings us back to the need to remux the file outside of Plex to achieve this. That’s not hard but we need to know what the “delay” is of the additional audio track so it can be synced correctly.

Figure out a reliable way to do that and we have something to work with.

@cayars said:
That’s not hard but we need to know what the “delay” is of the additional audio track so it can be synced correctly.
Figure out a reliable way to do that and we have something to work with.

Whenever I have to do such a thing, I load the video and the audio file into MPC-HC.
Then play it. By default the - and + keys are mapped to the audio delay. You can adjust it until it fits.

Then I throw the two files into MKVtoolnixGUI.
Each track accepts an individual ‘delay’ parameter.
Mux → new MKV file with all the different audio and subtitle tracks I desire,
properly marked for language
and the tracks sorted after always the same schema, so I can workaround the fact that Plex doesn’t show track titles.

I have files with up to 4 audio tracks and several more subtitle tracks.
(english, german, commentaries & other bonus stuff + subtitles in forced, full and CC and again commentaries)

Sounds like you just gave them the solution Otto!

Are my comments not being seen here, or am I just being ignored? This is in no way the solution, @cayars @OttoKerner. We keep asking for external track support, and people keep repeating “oh, the answer is to mux the tracks together!” That is explicitly NOT the solution, and it’s frustrating to repeatedly have the nature of our problem fundamentally misunderstood.

I’m also mildly confused about why we keep talking about “delay”. I don’t think we need to calculate delay. The external track will be what it is. If there is a delay, then the track is bad and would need to be fixed by the user- delays would need to be hardcoded into the track.

Please let me know if something described here is unclear: https://forums.plex.tv/discussion/comment/1280211/#Comment_1280211

5 Likes

It’s the only solution you have right now to get things to work. I doubt you would find any kind of real demand for this feature outside a few people here with special needs.

Just to give you an idea, just look at the problems something like subtitles can cause and this is easy compared to merging in additional audio tracks. Heck with subtitles they can sometimes go off sync a bit and it really doesn’t hurt anything. You don’t have that option with audio. You need to hear the words exactly when someone’s mouth moves for example. Timing is critical.

By all means DO put in a formal request for this feature it in the proper section of the website (request forum) and see if you can get support for it from the users. That’s the proper way to request features and to see how important features are to users so Plex knows where to spend it resources on new features.

Until such time as it’s included the only thing you can do is the work-around OttoKerner gave you.

BTW, does anyone know of any streaming software similar to Plex that does anything like this?

1 Like

@cayars said:
BTW, does anyone know of any streaming software similar to Plex that does anything like this?

No, but if it’s something Plex can spend an unusually long amount of time and extraordinary effort on and never have it work right while messing up a dozen other things in the process…

Coming Soon!

My Android mobile Plex App continues to report ‘Unfortunately Plex Has Stopped’, but don’t let that old bug get in the way of something new and shiny.

1 Like