Log in

View Full Version : Howto repair AC3 5.1 Audio


may24
9th February 2011, 22:29
Hi all,

I've got a .mkv file with AVC video and AC3 5.1 Audio (sat recording) - at least this is what Mediainfo tells me.

Now I wanted to mux this into a .ts to watch it on my Playstation.
So far no problems with the video part, but Tsmuxer complains: "some tracks could not be recognized" and the audio stream doesn't show up.

When you playback the mkv with MPC, it'll claim: you've ac3 stereo (probably due to DirectShow decoding) but VLC lists it again as 5.1

So probably the audio stream is damaged.
I finally decided to extract the audio stream and to re-encode it with megui into AAC. But unfortunately the encoding process stops after a few seconds and fails.

Is there a tool to check/repair ac3 multichannel tracks ?
My Sony Soundforge only recognizes AAC.
It would be ok to stay ac3 - I consider the AAC re-encoding just a workaround ...

sneaker_ger
9th February 2011, 22:39
Try AC3Fix (http://www.videohelp.com/tools/AC3Fix).

setarip_old
9th February 2011, 22:41
Hi!

You might try using EAC3to to simply re-save the 5.1 AC3 as 5.1 AC3 - and see what errors, if any, are displayed...

may24
9th February 2011, 23:03
Hi!

You might try using EAC3to to simply re-save the 5.1 AC3 as 5.1 AC - and see what errors, if any, are displayed...

Ah, how to "re-save" ?

kypec
10th February 2011, 06:55
Ah, how to "re-save" ?
eac3to.exe inputfile.mkv outputfile.ac3

yetanotherid
10th February 2011, 09:28
I don't have a fix as such, but I'll be watching this thread with interest as I occasionally run into the same sort of problem.

I assume broadcast audio often switches between 2ch and 5.1ch and this seems to drive some conversion software nuts, or causes some players to tell you it's 2ch while other tell you it's 5.1ch. An example of this might be a TV program where the "what happened last episode" recap contains 2ch audio while the episode itself contains 5.1ch audio. Without knowing how the information is stored in AC3 audio (whether it's contained in tags or headers etc) I've solved the problem before simply by splitting the MKV to remove the previous episode recap, leaving me with just the episode itself containing 5.1ch audio.

I often use foobar2000 for converting audio (it's an audio player which will open MKV and MP4 files directly or you can use it to play the raw audio stream) and playing the audio with it, it's easy to see where the audio switches between 2ch and 5.1ch by the number of bars (channels) jumping up and down in the output meter (assuming it's not decoding via directshow where the audio is being mixed to stereo first). I've often used foobar2000 to re-encode problem audio such as yours. It will sometimes fail where the switch between 2ch and 5.1ch takes place (I assume because the audio stream is damaged) but by using the "convert 5.1 to stereo" plugin you can usually get it to keep re-encoding the whole stream, as long as you're happy to end up with a stereo track.

Just some observations which might help you solve your problem.....

tebasuna51
10th February 2011, 12:47
Try split the ac3 in 2ch and 5.1ch content:
http://forum.doom9.org/showthread.php?p=1447695#post1447695

Ghitulescu
10th February 2011, 13:24
Is it only the audio part that is damaged? Have you checked the stream for errors? There are tools that can correct some errors ....

may24
10th February 2011, 15:11
Is it only the audio part that is damaged? Have you checked the stream for errors? There are tools that can correct some errors ....

As far As I can say: yes.
Are you talking about mkclean ?

@all: Isn't there an application that can utilize AC3 streams like Soundforge does with AAC multichannel ?

sneaker_ger
10th February 2011, 15:22
@all: Isn't there an application that can utilize AC3 streams like Soundforge does with AAC multichannel ?

You've been provided three different software recommendations. How about you post your results before asking for even more?

may24
11th February 2011, 10:24
You've been provided three different software recommendations. How about you post your results before asking for even more?
You didn't get the point ... but maybe I wasn't quite clear about it. I wanted a GUI (Soundforge alike) tool to (literally) see
if the track is Stereo or 5.1.

But to answer your query:
The AC3fix didn't detect any errors - and to me it seems to be capable of only stereo anyway ... It detects the stream to be stereo and parses it ok.
Same here for eac3to. Also detects the stream to be stereo without any errors.

But they are all wrong :p

yetanotherid and tebasuna51 are right. The audio stream indeed had 2.0 and 5.1 part, and ac3split separate them nicely.

So my question is: what to do next ?
The AC3 stereo part is just 21 kb (while the 5.1 is 162 MB) - that looks like one or two frames.
Surely I could just cut 'em off. But then lip-sync is lost ...

Since the resulting .ts file is ment to play on a PS3 (or another consumer device) will an audio delay be honored ?
In .mp4 it usually will not.

Ghitulescu
11th February 2011, 10:39
You should have expected that the audio stream was changed, lucky you only between 2.0 and 5.1, because there are providers that change between MP2 and AC-3 (for SDTV). That's common knowledge for (hopefully) all involved in SAT recording.
Now the topic has reached its goal: the audio stream is Ok (corrected).
It's now the time to move on.

Search for cutting SAT streams in the associated sub-fora, or even better for an authoring tool for PS3. You'll definitely find at least one SW that can do this.

may24
11th February 2011, 11:10
Ya, the mp2/ac3 issue is known to me.

But I haven't finished yet and so there's no reason to start another thread.

Because: when you examine the logfile of ac3split:
FileSize : 159403008 bytes
---------- First valid Header
Time eq. : 3320896 ms.
SamplCod : 0 (0:48, 1:44.1, 2:32 KHz.)
BitRate : 384 Kb/s
ChanMode : 2 (1:1/0, 2:2/0, 3:3/0, 4:2/1, 5:3/1, 6:2/2, 7:3/2)
FrameSize: 1536 bytes
---------- Process ( 25.000000 fps is used for Trim)
Time: 0 ms. Written: 2 frames 2.0 ( 64 ms.)
Time: 64 ms. Written: 28276 frames 5.1 ( 904832 ms.) Trim(2, 22622)
Time: 904896 ms. Written: 3 frames 2.0 ( 96 ms.)
Time: 904992 ms. Written: 8970 frames 5.1 ( 287040 ms.) Trim(22625, 29800)
Time: 1192032 ms. Written: 2 frames 2.0 ( 64 ms.)
Time: 1192096 ms. Written: 11700 frames 5.1 ( 374400 ms.) Trim(29802, 39161)
Time: 1566496 ms. Written: 3 frames 2.0 ( 96 ms.)
Time: 1566592 ms. Written: 3542 frames 5.1 ( 113344 ms.) Trim(39165, 41998)
Time: 1679936 ms. Written: 3 frames 2.0 ( 96 ms.)
Time: 1680032 ms. Written: 10758 frames 5.1 ( 344256 ms.) Trim(42001, 50606)
Time: 2024288 ms. Written: 3 frames 2.0 ( 96 ms.)
Time: 2024384 ms. Written: 28702 frames 5.1 ( 918464 ms.) Trim(50610, 73571)
Time: 2942848 ms. Written: 2 frames 2.0 ( 64 ms.)
Time: 2942912 ms. Written: 5425 frames 5.1 ( 173600 ms.) Trim(73573, 77912)
Time: 3116512 ms. Written: 3 frames 2.0 ( 96 ms.)
Time: 3116608 ms. Written: 6384 frames 5.1 ( 204288 ms.) Trim(77915, 83021)
---------- End of File
Total time: 3320896 ms. at EOF
T. written: 103757 frames 5.1.
T. written: 21 frames 2.0.

...you'll notice gaps ... well these gaps are stereo frames where there should be 5.1 frames.
Ac3split extracts them and concaternate all 5.1 parts. But these gaps must be filled (IMAO 5.1 "silent" frames would be easiest) in order to regain lip-sync.

So I'm looking for a way to create silent 5.1 frames, insert 'em at the gaps and cat the other 5.1 frames -> in other words without reencoding.

sneaker_ger
11th February 2011, 12:37
If you know the exact spots you can try to use delaycut (http://download.videohelp.com/jsoto/audiotools.htm) in two steps:
1.) cut them at the points
2.) delay them, which will insert silent frames
But it could be a little tedious.

At the the end you would merge them with mkvmerge again.

I think audacity is able to edit AC3 files with the help of ffmpeg/a plug-in.

Ghitulescu
11th February 2011, 12:56
The best way of cutting still remains the one that uses a TS cutter. There are several tools, from free to payware, from easy to complicated.

tebasuna51
11th February 2011, 13:12
...
Ac3split extracts them and concaternate all 5.1 parts. But these gaps must be filled (IMAO 5.1 "silent" frames would be easiest) in order to regain lip-sync.

So I'm looking for a way to create silent 5.1 frames, insert 'em at the gaps and cat the other 5.1 frames -> in other words without reencoding.

There are many gaps but if your 5.1 output is "X_51.ac3" you can use eac3to to add silence frames with:

eac3to "X_51.ac3" "X_51_0.ac3" +64ms
eac3to "X_51_0.ac3" "X_51_1.ac3" -edit=0:15:04.896,96ms -silence
eac3to "X_51_1.ac3" "X_51_2.ac3" -edit=0:19:52.032,64ms -silence
eac3to "X_51_2.ac3" "X_51_3.ac3" -edit=0:26:06.496,96ms -silence
eac3to "X_51_3.ac3" "X_51_4.ac3" -edit=0:27:59.936,96ms -silence
eac3to "X_51_4.ac3" "X_51_5.ac3" -edit=0:33:44.288,96ms -silence
eac3to "X_51_5.ac3" "X_51_6.ac3" -edit=0:49:02.848,64ms -silence
eac3to "X_51_6.ac3" "X_51_7.ac3" -edit=0:51:56.512,96ms -silence

sneaker_ger
11th February 2011, 13:29
Ok, that's less tedious than delaycut.

Ghitulescu
14th February 2011, 10:25
As far As I can say: yes.
Are you talking about mkclean ?
...you'll notice gaps ... well these gaps are stereo frames where there should be 5.1 frames.
Ac3split extracts them and concaternate all 5.1 parts. But these gaps must be filled (IMAO 5.1 "silent" frames would be easiest) in order to regain lip-sync.
The best way of cutting still remains the one that uses a TS cutter. There are several tools, from free to payware, from easy to complicated.

So I repeat, get a TS file "cleaner", this way most if not all your problems will be gone. If your SAT receiver plays the file perfectly, then such tools can recover the info 100%. Once the file has been converted or repacked, it's no use to use such tools and the timing info would be lost.

Unfortunately ProjectX cannot do AVC, but if you discard the video and demux the things you may end with a corrected audio track. You can instruct PjX to cut the stream at AC-3 changes.

yetanotherid
14th February 2011, 13:44
What am I missing??


I've got a .mkv file with AVC video and AC3 5.1 Audio (sat recording) - at least this is what Mediainfo tells me.

Now I wanted to mux this into a .ts to watch it on my Playstation.
So far no problems with the video part, but Tsmuxer complains: "some tracks could not be recognized" and the audio stream doesn't show up.


So I repeat, get a TS file "cleaner", this way most if not all your problems will be gone. If your SAT receiver plays the file perfectly, then such tools can recover the info 100%. Once the file has been converted or repacked, it's no use to use such tools and the timing info would be lost.

It seems to me the file has already been converted or repacked and the OP wants to fix it. Maybe the next time it can be done with the benefit of hindsight?

Ghitulescu
14th February 2011, 13:53
What am I missing??
This : if you don't know what you are talking about, please at least do not confuse the things. Or induce others into the same confusion.
It seems to me the file has already been converted or repacked and the OP wants to fix it. Maybe the next time it can be done with the benefit of hindsight?
This is exactly what he shouldn't do, first he must clean the TS file then convert it. Unless the file is damaged beyond repair, most if not all problems will disappear. If he doesn't have the original file, well ;)

yetanotherid
14th February 2011, 14:21
This : if you don't know what you are talking about, please at least do not confuse the things. Or induce others into the same confusion.

Have you considered using a monitor with a less reflective surface, or maybe adjusting the room lighting to reduce reflective light?
I think you'll find things will become much clearer if you're not looking into a mirror as you type.

This is exactly what he shouldn't do, first he must clean the TS file then convert it. Unless the file is damaged beyond repair, most if not all problems will disappear.

That's the hindsight thing I referred to. Apparently it's what he did. I went with the assumption he didn't have the original TS file because then he wouldn't need to remux the MKV back into a TS file in the first place, which is what he's trying to do. I also assumed that if he still had the original TS file he'd have tried working with it when remuxing the MKV failed, but maybe that's a fault of mine, being willing to assume the OP isn't silly.

If he doesn't have the original file, well ;)

Now you're getting it.

Ghitulescu
14th February 2011, 15:13
Since I fail to see why people convert a TS file into an MKV one just to remux back into a TS (the very same way ripping a DVD/BD into an MKV then reconverting back to DVD/BD) I gave the OP the presumption of non-guilty. Otherwise it's Rule 6.

yetanotherid
14th February 2011, 16:56
Since I fail to see why people convert a TS file into an MKV one just to remux back into a TS (the very same way ripping a DVD/BD into an MKV then reconverting back to DVD/BD) I gave the OP the presumption of non-guilty. Otherwise it's Rule 6.

So your failure to understand led you to believe you needed to answer a question the OP didn't ask?
Of course it's not likely the OP would convert a TS file into a MKV one just to remux it back into a TS file again, but it doesn't mean they stole it either. Have you considered the possibility it may have been remuxed into a different format a long time ago, but now because of the hindsight thing not tending to be pre-emptive, the need to remux it into another format has arisen, even though that format is unfortunately the same as the original one?
Did you consider the fact that the OP isn't an idiot and would use the original ts file if they still had it, or has some naive rule 6 related assumption really led you to conclude the OP asked the wrong question?

I've probably only remuxed a couple of transport streams in my entire life, but could the fact a transport stream can carry multiple program streams be at least one reason for doing so?

Does rule 6 say once you've muxed a ts file into an MKV file you must not ever delete the original ts file?

may24
14th February 2011, 18:41
Guys calm down.

First of all: This is a Sat rip done by a friend of mine with his Sat-Capture card and ad's cuted out (I don't know which app he's using). I suspect the Stereo fragments are from cutting at IDR Frames. The video stream hasn't finished the GOP while the audio has already switched to stereo of the following ad's.
(Just an idea ...)

However, the simple reason for muxing it into a .mkv is its (way) less overhead compared to .ts.
The PS3 (still) won't play .mkv, hence I re-mux it back to .ts and voila -> it works :)

I've tested tebasuna51 sollution with eac3to and it worked perfectly. The only drawback is that eac3to only accept timestamps instead of frames ... so you'll have to calculate 'em.
But I definitely going to test ProjectX as soon a possible.

b66pak
14th February 2011, 19:36
there is a much simpler solution (http://forum.doom9.org/showthread.php?p=1384742#post1384742)...PS3 don't have any problem in playing ac3 streams with 2.0 & 5.1 combination...

eac3to myaudio.ac3 temp.ac3 -352ms
eac3to temp.ac3 myfinalaudio.ac3 352ms

this is a general solution for tsMuxer problem as it checks only the first 11 ac3 frames (352ms)...in your case only the first 64ms are the problem...
_

sneaker_ger
14th February 2011, 19:46
Wouldn't myaudio.ac3 and myfinalaudio.ac3 be identical then?

I think it should be
1.) eac3to myaudio.ac3 myfinalaudio.ac3 352ms
2.) then set a delay of "-352 ms" in tsMuxer
:confused:

/edit: no, you're correct. Both ways should work, though you shouldn't lose the first 352ms with my solution.

b66pak
14th February 2011, 20:01
setting a delay with tsMuxer is like inviting trouble...i don't recommend it...
_

sneaker_ger
14th February 2011, 20:03
I see.

may24
14th February 2011, 22:49
@b66pak thanks, that's a realy good idea/solution !
Do you know how to crop 2 frames (=64ms) from the ac3 stream using eac3to ?

Ghitulescu
15th February 2011, 06:34
So, provided:
- you don't have the original source
- the source was converted and cut with a less-than-ideal tool
- at the cut points there are left AC-3 2.0 frames (from commercials)
then the only "portable" solution would be to remove these frames, a PS3 won't last forever and some other players would strike.
Actually the best solution would be to rip the DVD/BD with that movie (not only a better image/audio, but also subtitles and no logo).

may24
15th February 2011, 07:25
It's a Sat rip, no DVD/BR ! so no re-rip possible.
However I agree that the PS3 will be forever and other consumer devices might have some problems. So at the moment I favor tebasuna51 to be the best sollution.

Ghitulescu
15th February 2011, 10:11
It's a Sat rip, no DVD/BR ! so no re-rip possible.
However I agree that the PS3 will be forever and other consumer devices might have some problems. So at the moment I favour tebasuna51 to be the best solution.

DD 5.1 are for movies only. Some concerts, too. These are already or will be soon on DVD/BD.

I know it won't solve your problem now, but it's the best advice I can give you.

may24
15th February 2011, 13:49
DD 5.1 are for movies only. Some concerts, too. These are already or will be soon on DVD/BD.

I know it won't solve your problem now, but it's the best advice I can give you.

Ah ... sorry I don't get your point. There are already a lot of series on public TV that get broadcasted in 5.1 (like in my case).
I just wanted to point out that I'm fiddling with a sat rip and not a DVD/BR rip ... otherwise everybody gonna yell: rule 6 !!! ;-)

I figured out the eac3to issue of cutting the first two ac3 frames and "replacing" them with silence (to maintain lipsync)
eac3to.exe eact30_demuxed.ac3" eact30_fixed.ac3 -edit=0:00:00,-64ms
eac3to.exe eact30_fixed.ac3 eact30_fixed2.ac3 +64ms