Log in

View Full Version : Demuxing AC3 correctly from .ts


bcsizemo
17th February 2013, 05:44
This is kind of long and drawn out, but I'll state my basic problem first and then follow with the back story.

I'm having an issue demuxing audio from ATSC HD .ts files that I'm recording. I tried using DGIndex (since I'm using it anyway to get a d2v file for avisynth to use it made sense at the time), and it worked-ish for ABC, but when doing CBS it throws up an issue with the delay being absurdly long. I moved on to EAC3to, which seemed to do what I wanted all in one step 5.1 AC3 .ts -> 2.0 wav. However on several recordings it is not coming out with the correct length. The error seems to crop up with the audio stream switches between 5.1 to 2.0 during a commercial. This is making editing/syncing audio impossible. I've kept playing with EAC3to and I have found it can extract the AC3 file as it is, while Azid can decode it to the correct length.

So right now it goes something like this:
.ts -> EAC3to -> 5.1 AC3 -> Azid -> 2.0 wav

I'm looking for a command line solution because I am basically trying to take a .ts run comskip on it, build an avisynth script, encode it to H.264 minus the commercials, and mux in the cut audio. (Actually I hammered out the entire thing and it works well, except when this audio issue pops up). I assume this has something to do with blank frames or the change over from 5.1 to 2.0 during recording, can EAC3to handle this or am I stuck doing a two (actually 3) step solution here?

(Not 100% if this isn't better in the audio forum, but since it is directly related to ATSC recording I thought here would be better.

setarip_old
17th February 2013, 20:17
Hi!

Have you looked into using tsMuxeR?

bcsizemo
17th February 2013, 21:59
tsMuxeR can demux to AC3, but that still leaves me with a two step situation. .ts -> AC3 -> WAV.

That and using tsMuxeR via command line is a royal PITA (at least in terms of batch files usage.)

Actually what I'm finding is that most programs, DGIndex (when it's not complaining about delay times), EAC3to, FFmpeg, tsMuxeR, and even comskip demux the audio to a length of 59m 51s. I can take anyone of those as an input into azid and get a wav file out of 61 minutes.

FFmpeg seems to be about to go straight from the .ts -> wav, but I'm not sure if it is applying the appropriate delay in there (like eac3to would do), but it does come out with a 61 minute wav file. EAC3to doing the same thing, .ts -> wav (-down16 -down2 -16 -2 settings) yields a 59m 51s wav file. Not all the time, but on this particular recording it does.

Darksoul71
25th February 2013, 12:10
Just my two cents on your process:
1) tsMuxer via CLI is a PITA but under Windows you can easily control the GUI via AutoIt. I can provide you with example source code. I wrote a small AutoIt script which merges the M2TS segments of my STB into one file per recording.

2) Cutting TS and M2TS under CLI can be a mayor PITA as well.

Since you plan to re-encode the video based on AVISynth scripts anyway I would choose a different approach:
Convert the cutmarks provided by comskip to Avisynth trim commands (I did similar things back then with VCF2AVS). Then use x264 for encoding the video part. Afterwards use ffmpeg to transcode audio as well. Of course re-encoding a lossy audio format will result in a drop of quality but given you use a decent bitrate for AC3, IMO this will be hardly noticable. After this you could remux to the container of your choice (e.g. MKV with mkvmerge). I could provide examples as well.

Drop me a note if you need further help !

HTH,
D$

bcsizemo
18th March 2013, 02:25
Convert the cutmarks provided by comskip to Avisynth trim commands (I did similar things back then with VCF2AVS). Then use x264 for encoding the video part. Afterwards use ffmpeg to transcode audio as well. Of course re-encoding a lossy audio format will result in a drop of quality but given you use a decent bitrate for AC3, IMO this will be hardly noticable. After this you could remux to the container of your choice (e.g. MKV with mkvmerge). I could provide examples as well.

HTH,
D$

More or less this is what I did. Still needing the two step ac3 -> wav -> mp3 in there. I've ended up dropping comskip mostly because CBS loves to throw in 30 second funny bits at the end of their comedies and it will eat those most of the time.

The only other issue I've really ran into at the moment is a commercial by Time Warner Cable no less. For the last week while recording General Hospital the commercial comes on during a break about half way through the show. At first I thought it was something with my setup borking, but I looked into it and found that about 10 seconds into the commercial they change resolutions from 720p to 480p... It's almost like someone spliced two commercials together with the first HD one getting cut off. I can play the .ts file and it works fine, even DGIndex doesn't complain about it. The issue arises between the video and audio. The audio drops to about 15 seconds out of sync. I can manually resync it during playback, but it's a PITA. Anyone ever seen such a thing?

Darksoul71
18th March 2013, 17:54
You could also try what happens when you do lossless cutting (I-frames) with AVIDemux. If this works, you could re-compress the video based on the lossless cutted stream with a tool of your choice.