Log in

View Full Version : Audiotrack with changing audio formats and avisynth


Rain_1
26th January 2013, 18:25
Hey there.

I've been doing some .TS captures from my Cable Box while I'm out so I can watch later and I'm running into a weird problem that I'm sure can easily be solved.

Long story short, after I captured the .TS, I guess because the change between the actual Show I'm capturing and the commercials, the audio proprieties change during the stream (let's say, it goes from Mono to Stereo, or it changes sample rate).

After I capture those Streams (they're MPEG2 video streams), I run them through dgmpegdec, which spits out a usable d2v (which I load on avisynth with mpeg2source) and a .mp2 audio file (which I load with bassAudioSource), and I've been really successful in editing this video with this technique. Here's an .AVS sample:

http://pastebin.com/BdxgWu2z

As you can see, I do all the trimming on the .avs file itself (with AvsP help). It usually works, but sometimes, and I can't explain why, I'll lose audio between trims. If it's an exceptional day, I won't have audio for the entirety of the Stream.

I think it's important to notice that, when I don't have any audio issues, the Delay informed by dgmpegdec on the audio filename syncs the audio perfectly.

Since my only issue is audio, I tried using NicMPG123Source as the audio plugin. With Nic plugin, I get audio. However, the audio timing is all messed up - the original audio delay reported by dgmpegdec no longer works and I have to manually fix the audio delay. Since I have no basis of the sync issues, it becomes a very tiresome proccess of manually changing the audio on the .AVS script, re-encoding the audio, muxing it with the already encoded video and trying to figure out the best option.

I also tried extracting the .mp2 audio directly from the .TS with ffmpeg too and using that instead, and that usually works perfectly with BassAudio, but then again the sync is off and using the sync provided by dgmpegdec doesn't work and i'm back at manually syncing audio and video.

Here's FFMPEG Output when converting the file (this one is not pretty to look at, but the information is there if you squint real hard):

http://pastebin.com/sXLTPK22

I've tried doing most of the cutting on dgmpegdec, but I noticed I keep getting more issues if I cut the file before. So I just load the entire .TS on avisynth and I get less audio missing problems, but they still exist.

I also tried loading the secondary audio track from the .TS, but the problems are there as well. I've tried running the .TS through some other .TS demuxing programs, but this is the best stup i've came up with, that gives me less issues, but it's still not perfect.

So, what I'm really asking is: Is there any audio plugin that won't freak out when the audio format it's reading changes and can work accordingly?

Or, maybe, is there some other proccess that I can extract this audio from the .TS and keep it synced, while I trim excess video off inside the .AVS file itself?

I know this is a big one, and I can provide samples of the .TS file if required - except I don't know which parts you would need? I can provide the .mp2s as well.

Any help is appreciated.

tebasuna51
26th January 2013, 19:46
... Is there any audio plugin that won't freak out when the audio format it's reading changes and can work accordingly?
Don't exist. Inside AviSynth the audio must have always the same num_channels and samplerate.

Maybe you can try DirectShowSource configuring ffdshow to output the same num_channels and samplerate, but the sync problems may remain.

Or, maybe, is there some other proccess that I can extract this audio from the .TS and keep it synced, while I trim excess video off inside the .AVS file itself?.

If ffmpeg can't do the job (because many errors in audio stream) I don't know other method than adjust manually the audio.

Rain_1
26th January 2013, 19:51
Don't exist. Inside AviSynth the audio must have always the same num_channels and samplerate.

Maybe you can try DirectShowSource configuring ffdshow to output the same num_channels and samplerate, but the sync problems may remain.

Then why, sometimes, I don't run into problems at all? I'm just lucky that the parts I'm trimming don't have any errors/channel changes?


If ffmpeg can't do the job (because many errors in audio stream) I don't know other method than adjust manually the audio.

Well, ffmpeg does do the job, it's just that it's desynched with the video. Is there any way that I can extract a synced audio stream (or at least a new delay value) with FFMPEG, or, because the audio stream is such a mess, there's no way to do that?

tebasuna51
27th January 2013, 11:57
I'm just lucky that the parts I'm trimming don't have any errors/channel changes?

Exact.

The TV source, or your capture card, can supply errors or not.
Sometimes only a manual edit is the solution.

manolito
27th January 2013, 13:28
@Rain_1

Is your video SD or HD? If it is SD then you definitely should run it through ProjectX or PVAStrumento before processing it any further.

I know that the current DGIndex versions can process .TS files just fine, but to make sure that you won't get sync errors, it is mandatory to convert the transport streams to program streams first. (My favorite is ProjectX, I find it more reliable than PVAStrumento. The Womble MPEG-VCR software also has a stream converter which can convert TS to PS, but it does not work for me, I always get sync errors.)

Using ProjectX or PVAStrumento will solve your audio problems, too. Both programs have an option (active by default) to split the output whenever an audio format change occurs. Makes it very easy to get rid of commercials...


Cheers
manolito

Rain_1
27th January 2013, 15:50
Exact.

The TV source, or your capture card, can supply errors or not.
Sometimes only a manual edit is the solution.

I'm lucky to have a TV Decoder that spit out unencrypted .TS files on a USB Storage device, so there isn't much "capturing" going on with this setup. However, it does mean that whatever is piped through the cables end up on a file, even if it's audio streaming changing quality or a signal drop.

@Rain_1

Is your video SD or HD? If it is SD then you definitely should run it through ProjectX or PVAStrumento before processing it any further.

It most certainly is SD content and I've never heard about these applications before. I'll make sure to check them out and report accordingly, which I can't do right away because I don't have any material to work with right now - I already manually fixed everything I had to fix.

Rain_1
27th January 2013, 16:26
I found some working files and I'm doing some preliminary work with Project X and it's spitting a .m2v file and two .mp2 files (as there are two audio streams on this TS).

I ran the .m2v file through DGindex (which according to http://forum.doom9.org/archive/index.php/t-102761.html I should) and I loaded both the video and the audio on Avisynth (without setting any delay) and they appear to be perfectly synced.

However, this work file I found is one of those that didn't give me any problems. I'll start using this setup from now on and see how it behaves. I'll be sure to post here if I need any more help. Project-X did report me it found multiple audio formats and the .MP2 that it spit out appears to be a single format all the way through, according to every audio editing software that I throw that file into - usually, it would only decode it partially and complain about being corrupted. With that in mind, it seems I'm on the right path.

So, the Transport Stream has some messed up settings (like varying audio quality) and it's better to convert it to a Program Stream before doing any work in it? I never worked with true Transport Stream content, I usually encoded all my video once it went through a Hauppauge PVR-1212, which means all the material I've ever worked with was always smooth and organized.

I always leave a thread in these Forums knowing more than I did when I came in. Thanks a lot to both of you for the suggestions.

manolito
27th January 2013, 22:48
So, the Transport Stream has some messed up settings (like varying audio quality) and it's better to convert it to a Program Stream before doing any work in it?

Yes, absolutely.

To make sure that ProjectX will split your output if it detects a change in the audio format, make sure your special settings look like this:

http://i46.tinypic.com/wtiq2c.jpg

This option must be unchecked.


Cheers
manolito

Rain_1
6th February 2013, 16:22
So, after a week of nothing but good results, I've stumbled upon a recording that still gives me the problem.

This particular capture, the audio cuts halfway through the show.

Here's a log from ProjectX

http://pastebin.com/yqpaV2AC

Anyway, I messed with ProjectX options and, on the Audio tab, I found an option to convert the audio while demultiplexing to MPEG1. I did that and, apparently, it fixed my issue: On the next audio pass, the audio was there entirely.

I hope that fixes it for good! :D

Once again, thanks for all the help.