Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 26th January 2013, 18:25   #1  |  Link
Rain_1
Registered User
 
Join Date: Aug 2004
Posts: 25
Audiotrack with changing audio formats and avisynth

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.

Last edited by Rain_1; 26th January 2013 at 18:43.
Rain_1 is offline   Reply With Quote
Old 26th January 2013, 19:46   #2  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Quote:
Originally Posted by Rain_1 View Post
... 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.

Quote:
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.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 26th January 2013, 19:51   #3  |  Link
Rain_1
Registered User
 
Join Date: Aug 2004
Posts: 25
Quote:
Originally Posted by tebasuna51 View Post
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?


Quote:
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?

Last edited by Rain_1; 26th January 2013 at 20:37.
Rain_1 is offline   Reply With Quote
Old 27th January 2013, 11:57   #4  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Quote:
Originally Posted by Rain_1 View Post
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.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 27th January 2013, 13:28   #5  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
@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
manolito is offline   Reply With Quote
Old 27th January 2013, 15:50   #6  |  Link
Rain_1
Registered User
 
Join Date: Aug 2004
Posts: 25
Quote:
Originally Posted by tebasuna51 View Post
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.

Quote:
Originally Posted by manolito View Post
@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.

Last edited by Rain_1; 27th January 2013 at 16:18.
Rain_1 is offline   Reply With Quote
Old 27th January 2013, 16:26   #7  |  Link
Rain_1
Registered User
 
Join Date: Aug 2004
Posts: 25
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.

Last edited by Rain_1; 27th January 2013 at 17:12.
Rain_1 is offline   Reply With Quote
Old 27th January 2013, 22:48   #8  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
Quote:
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:



This option must be unchecked.


Cheers
manolito
manolito is offline   Reply With Quote
Old 6th February 2013, 16:22   #9  |  Link
Rain_1
Registered User
 
Join Date: Aug 2004
Posts: 25
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!

Once again, thanks for all the help.
Rain_1 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 15:15.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.