View Full Version : HowTo Edit H264/AVC TS Streams


DreckSoft
5th August 2006, 11:51
Recently I tried to add a second language track to a TS file containing H264/AVC Video and AC3 audio. It proved more difficult than I thought. I came up with the following solution. Most parts are collected from some thread in this forum, so credits go to the original posters.

1. Demuxing TS:
Extract the video to RAW H264 and AC3 audio. I used mencoder for this. I used the version from 31.07.2006 from here: http://tirnanog.fate.jp/mirror/mplayer/
The latest official release didn't work
To demux video use the following command:
mencoder.exe "Z:\Infile.ts" -of rawvideo -ovc copy -oac copy -noskip -o Y:\Outfile.264
Demux audio using ProjectX (http://www.lucike.info/page_projectx.htm). This has the advantage that you see stream errors in the log. ProjectX will complain a lot about GOP size and won't extract the video track. It will extract all audio tracks and fix errors. I recommend recapping if you'll get errors as watching a file with errors is not much fun and synching the audio will be a pain in the ass. If you don't like ProjectX, you can still use
mencoder.exe "Z:\Infile.ts" -of rawaudio -ovc copy -oac copy -noskip -o Y:\Outfile.ac3
but you'll only get one audio track and no error report.

2. Put H264 into AVI:
AVC2AVI: (link see post from crypto)
avc2avi -i Y:\Outfile.264 -o Z:\Avifile.avi -c H264 -s 2000
Note: AVC2AVI doesn't like streams from BBCHD. Those are in 1440x1088 but AVC2AVI says 1440x1084 and will create one large avi which will require the fixing mentioned in Step 4 (look in section Obsolete). The original AVC2AVI reports 1440x540...

3./4. Removed

5. Add Audio:
You will most likely have to use a delay since the AV delay is not fixed when demuxing. The best thing is to add the audio multiple times with different delays and then see which is the best. You can also add more audio tracks here or cut unwanted parts. Save to a new AVI. Btw: I use VirtualDubMod for this.

6. (Optional) Convert to MKV:
AVI and H264/AVC isn't the best combination, so you may want to use MKV instead of AVI. Use MKVToolnix to create the MKV. You'll have to add the option "--engage allow_avc_in_vfw_mode". The resulting file may already work, it did half the time here. Better also do the following: Open the MKV in AVIMux GUI and save to a new MKV.

Obsolete (were necesary if you use original AVC2AVI from http://forum.doom9.org/showthread.php?t=89979):
3. Change the resolution:
The AVI will have a resolution of 1920x544 instead of 1920x1088. Use a hex editor to change the third occurence of 2002 to 4004.

4. Fix AVI File:
Open the AVI in VirtualDubMod, choose "Ask for extended options after this dialog", then choose "Re-derive keyframe flags".
It will take a looooong time till it's finished. Save the file with direct stream copy to a new avi, so you won't have to do the rekeying again if something goes wrong later. Note that VirtualDub most likely will display a lot of garbage when seeking but the resulting file will play fine

Obsolete (alternate demux commands, didn't work properly once, so I'm using the ones mentioned above):
1. Demuxing TS:
mplayer -dumpvideo -dumpfile Y:\Outfile.264 Z:\Infile.ts
mplayer -dumpaudio -dumpfile Y:\Outfile.ac3 Z:\Infile.ts

DreckSoft
5th August 2006, 11:55
Btw, the following did not work:
1. Put everything into a MP4 container using MP4Box: AC3 not supported
2. Mux H264 RAW directly to MKV using MKVToolnix: Consumes all memory than crashes
3. Mux H264 RAW directly to AVI/MKV using GraphEdit: Stops after 1/2-2/3 of the file
4. Mux TS directly to AVI/MKV using GraphEdit: Stops after 1/2-2/3 of the file

bond
5th August 2006, 14:30
remuxing avc from avi to mkv is not recommended

remux the raw avc stream to mp4 and then remux the mp4 to mkv for getting native avc in mkv

DreckSoft
5th August 2006, 15:53
Doesn't work, same as (2): Consumes all memory than crashes

I'll try another stream soon and post the results.

Eeknay
6th August 2006, 02:24
You can get h264 TS into MKV using GraphEdit. I seem to remember doing it successfully before, but I just tried again now and got weird results (input file was 2 minutes, new file was 5 hours). YMMV.

Alternatively you can rename your desired audio track to the same filename as the TS and do it that way rather than remuxing... a much easier solution until better software appears.

DreckSoft
6th August 2006, 10:15
GraphEdit never muxed the complete file.

I tried a second stream and this time TS => RAW => MP4 => MKV worked but the file was unplayable (stuttering video, async audio). The AVI I created plays fine (is skipped step 6). AVI + AVC may not be a recommended solution but currently it's the only one working properly here.

bond
6th August 2006, 10:22
does the mp4 play fine?

what player are you using?

Schmendrick
6th August 2006, 19:22
From an Astra-Pro7 HD transmission I have recorded a transmission with an AVC/H.264-video and an AC3-audio stream. Using DVBstreamexplorer I can demux the recorded ts-file into a raw H.264- and a raw AC3-file. From the the raw H.264-file I have to cut out everything from the beginning of the raw H.264-file until the first SPS within the file like bond has explained:
http://forum.doom9.org/showthread.php?p=664470#post664470
The AC3-file has to be beautified using AC3fix.
Then the H.264-file is muxed into a MP4-file using Yamb (which uses MP4Box). The MP4-file then can be used as video source (it does not work directly with the corrected H.264-file) with the MKV-editor which also accepts the AC3-file as audio source (which Yamb and MP4Box refuses to accept) so that now after muxing you have a MKV-file which plays fine within Media-Player-classic using the Cyberlink AVC/H.264-decoder from PowerDVD6 and AC3Filter.
The only problem which remains is the synchronization of the video and the audio streams. So far you still have to find an offset value by trial and error and hope that you don't have frame drops within your recording. The offset can be used with "AC3 delay corrector" to adjust the audio stream prior to muxing.
As the botom line we still need an extension to AVC/H.264-containing video files for programs like ProjectX or PVAstrumento to demux TS-files with automatic compensation of offset values and frame drops.

DreckSoft
6th August 2006, 19:48
does the mp4 play fine?

Hm, forgot to try this and already deleted the source file

what player are you using?
ZoomPlayer

crypto
14th August 2006, 09:54
I followed the avi road and the results are playing ok. That's good. But there are several issues:

Step 2. Put H264 into AVI: That should be done by the demuxer.

Step 3. Change the resolution: That's a bug in AVC2AVI. Does not respects the interlaced flag.

Step 4. Fix AVI File: Is a joke. It takes hours and doesn't do the right thing. After that step every frame is a key frame.

Is there a better tool to (re)index an avi file? Or does someone know how to do that programmatically? The key frames can be detected by the frame size.

I am thinking about adding steps 1-4 into TSConverter, but I need some info about step 4.

DreckSoft
14th August 2006, 10:27
But there are several issues:

Yup, but it was the only way that worked.


Step 4. Fix AVI File: Is a joke. It takes hours and doesn't do the right thing. After that step every frame is a key frame.

I remeber a tool called DivFix, but haven't tried it.


I am thinking about adding steps 1-4 into TSConverter, but I need some info about step 4.

It may be easier to add the ability to mux additional audio tracks. Cutting H264 TS would also be nice.

crypto
14th August 2006, 15:22
Yup, but it was the only way that worked.

I remeber a tool called DivFix, but haven't tried it.

Thanks for the info. It seems now to be called DivFix++. Tried it and it ends after writing 4 bytes without an error. I also read a thread on doom9 mentioning that it does not tag key frames.


It may be easier to add the ability to mux additional audio tracks. Cutting H264 TS would also be nice.
Cutting H264 TS and demuxing is already supported when you use the latest HDTVPump Test Version 1.0.10 (http://forum.doom9.org/showthread.php?t=114357).

DreckSoft
14th August 2006, 16:47
Cutting H264 TS and demuxing is already supported when you use the latest HDTVPump Test Version 1.0.10 (http://forum.doom9.org/showthread.php?t=114357).

Great, will try this next time, thanks.

crypto
21st August 2006, 21:56
I did a little research to find out why the avi needs to be fixed in vdub after avc2avi, which is apparently the longest step.

AVC2AVI does write an index and even marks key frames correctly. But it uses the old 2GB limited avi format and that's why VirtualDub does not recognize the index. While recreating the index, the key frame flags are destroyed.

The fix is simple. I have modified AVC2AVI to write a segmented avi, which can be read by VirtualDub including the index and key frames. During mux the file can then be written in the new OML AVI format resulting in a perfectly playable stream.

Edit:

BBC HD Streams are now fully supported by AVC2AVI mod. The latest version of AVC2AVI mod can be found here (http://sourceforge.net/projects/avc2avi).

bond
21st August 2006, 21:57
fix is easy: dont use avi

crypto
21st August 2006, 22:14
> fix is easy: dont use avi
LOL, why? I see nothing which speaks against avi.

As pointed out in this thread, there is currently no other way. MP4 and MKV rely on mp4box, which is complaining about the streams not being compliant. Which is obviously not the case as the streams are from the Tandberg realtime encoder. MP4 also can't hold the AC3 audio.

bond
22nd August 2006, 18:50
mkv doesnt rely on mp4box. mkvmerge relies on mp4 input. you can also create mp4 files without using mp4box, eg by using mp4creator from mpeg4ip

apart from that i doubt your .264 is correct. there is surely garbage at the beginning

crypto
23rd August 2006, 10:48
Thanks, I will check on mp4creator.

> apart from that i doubt your .264 is correct. there is surely garbage at the beginning

The stream starts with the TS packet containing the SPS with all headers (TS, PES, ES) removed. That's what I call a raw stream. Mp4box doesn't seem to like the nal type 9, type 7 sequence header combination. I have no idea why the tandberg encoder adds the type 9 unit but I am sure, it is compliant.

Anyway, we need easy to use tools. The average user surely doesn't want to cut a stream prior to having a tool to accept it.

bond
23rd August 2006, 17:52
you need the sps and pps at the beginning of the stream to get a correct raw stream

DreckSoft
26th August 2006, 15:01
The fix is simple. I have modified AVC2AVI to write a segmented avi, which can be read by VirtualDub including the index and key frames. During mux the file can then be written in the new OML AVI format resulting in a perfectly playable stream.

http://dvbportal.dyn1.de/download.php?file=avc2avi_mod.zip

The generated AVIs are sometimes to big (using only -s). Using -s 2000 fixed the problem.

Btw: I couldn't figure out how to cut H264 TS with TSConverter. The file plays but no time slider. Maybe I'm missing some filter. The program also crashes if the file starts with some garbage at the beginning (which happens quite often).

crypto
26th August 2006, 15:38
The generated AVIs are sometimes to big (using only -s). Using -s 2000 fixed the problem.

The default is max 2048 MB per segment. The program checks if all nal units up to the next sps fit in the current segment, if not it switches to the next segment. How could you tell that the segment is to large. (symptoms?)

Did the rest work as expected? Are the index and keyframe flags intact?


Btw: I couldn't figure out how to cut H264 TS with TSConverter. The file plays but no time slider. Maybe I'm missing some filter. The program also crashes if the file starts with some garbage at the beginning (which happens quite often).

The time slider is on the mark in/mark out dialog. Set the marks, choose MPV+MPA output and then convert. The resulting elementary streams need to be renamed of course.

BTW. the current version has time overflow issues with very large recordings (whole day recordings). Edits also don't start always with a sps unit. I have fixed all that meanwhile. I am also planning to add the DD-Wave header to the demuxed audio and maybe avi output for the demuxed video.

DreckSoft
30th August 2006, 23:12
The default is max 2048 MB per segment. The program checks if all nal units up to the next sps fit in the current segment, if not it switches to the next segment. How could you tell that the segment is to large. (symptoms?)


Virtualdub started to reconstruct the index block. I stopped it and regenerated the avis with -s 2000 so I don't know if the rest was correct.

The time slider is on the mark in/mark out dialog. Set the marks, choose MPV+MPA output and then convert. The resulting elementary streams need to be renamed of course.

BTW. the current version has time overflow issues with very large recordings (whole day recordings). Edits also don't start always with a sps unit. I have fixed all that meanwhile. I am also planning to add the DD-Wave header to the demuxed audio and maybe avi output for the demuxed video.

I still used 2.02. I've upgraded to 2.0b4 now. First nothing worked, didn't even got a picture. After uninstalling Haali Media Splitter at least playback worked (with wrong colors) - but only if I choose MPEG-2 Demultiplexer as Preferred Demultiplexer. Any Push Demux and NVidia HDTV Demux won't work. But I never could convert the Stream, it says: Could not build graph to render source file. Please check the DirectX requirements for this application. (HRESULT = 8004154, Checkpoint = 0004, VideoAnalyser).

Maybe I don't have all necessary filters installed. HDTVPump, Nvidia Pure Video, ffdshow, CoreAVC are installed.

crypto
31st August 2006, 06:49
Virtualdub started to reconstruct the index block. I stopped it and regenerated the avis with -s 2000 so I don't know if the rest was correct.


You are right, then the segments are to large. I will reduce the default size.


Any Push Demux and NVidia HDTV Demux won't work. But I never could convert the Stream, it says: Could not build graph to render source file. Please check the DirectX requirements for this application. (HRESULT = 8004154, Checkpoint = 0004, VideoAnalyser).


I will remove that obsolete demuxer option, because all the other demuxers can't work with H.264 streams.

It seems that the VideoAnalyser is not a stock filter. I'll will add an apropriate custom filter. It is used to synch A/V

DreckSoft
31st August 2006, 11:25
Found the problem:
MPEG-2 Video Stream Analyzer,0x00200000,0,0,sbe.dll,

sbe.dll isn't part of Windows 2000.
get the dll from XP SP2, run regsvr32 sbe.dll and it works.

I'm currently testing if it really works, at least the error message is gone.

xlazom00
31st August 2006, 14:15
I always prefer YAMB & mp4box for muxing raw h264 to MP4
http://ffdshow.faireal.org//mirror/gpac/
I dont have any problem with right resolution(1920x1088) in leatest version.

ts->raw->mp4(no ac3 support)->mkv

it takes very long time with 9GB files :)

eggtimer
3rd September 2006, 23:30
Thanks DreckSoft and others, this is a very useful thread.

I have been trying unsuccessfully to get the BBCHD h.264 video into MP4 and so to a .mkv. Most MPEG2 demuxers produce a raw h.264 stream with junk at the front as you'd expect, but mencoder gives a clean-looking h.264 stream, certainly it starts correctly with the SPS (I think XMuxer Pro also gives a clean raw stream). That raw h.264 stream must be reasonably compliant as it is playable using the Cyberlink codec. But both MP4Box and MP4Creator reject it. I sent a sample to the author of YAMB but I'm not sure he was able to do much with it (probably not high on his list of priorities anyhow - no reason why it should be).

xlazom00, thanks for the suggestion of GPAC, I'll give it a try.

Otherwise it looks like DreckSoft's avi route is the only option for BBC sourced material?

drmih
5th September 2006, 11:26
I use mencoder to convert the BBC HD satellite broadcasts to XVID in one simple step and there doesn't seem to be much of an issue. It occassionally gives poor results but on the whole a useable solution. Takes several hours to convert a 1 hour (9Gb) file to approx 4GB, but atleast it's a solution. It'd be nice to have something as friendly as AGK, but you can't have it all.

CHP
7th September 2006, 17:48
4. Fix AVI File:
Open the AVI in VirtualDubMod, choose "Ask for extended options after this dialog", then choose "Re-derive keyframe flags".
It will take a looooong time till it's finished. Save the file with direct stream copy to a new avi, so you won't have to do the rekeying again if something goes wrong later. Note that VirtualDub most likely will display a lot of garbage when seeking but the resulting file will play fine

[/QUOTE]

Excuse me.
Can you tell me detailed place about that dialog?with a step4.. thanks!

crypto
7th September 2006, 18:47
Can you tell me detailed place about that dialog?with a step4.. thanks!

1. In VirtualDub choose Open Video File... from the file menu
2. Check the box "Ask for extended options after this dialog". It is located in the lower left corner of the file open dialog.

This step is currently only necessary for BBC HD streams. Streams from other H.264 HD stations are correctly indexed with key frames with the modded version of avc2avi.

CHP
8th September 2006, 05:45
1. In VirtualDub choose Open Video File... from the file menu
2. Check the box "Ask for extended options after this dialog". It is located in the lower left corner of the file open dialog.

This step is currently only necessary for BBC HD streams. Streams from other H.264 HD stations are correctly indexed with key frames with the modded version of avc2avi.

oh~!!!,i'm try is next time,thanks very much crypto!

_ck_
27th October 2006, 15:15
Just wanted to check back in this thread after a month and see if there are any more tools to make this process faster.

I've successfully followed the directions to demux the ac3 and raw h264 stream from BBC HD transport streams.

Beyond storing the video in a more useable format than .ts (which does play fine in media player classic) I'd like to be able to do screenshots of individual frames via virtualdub so I convert to the raw h264 to avi but when I load into vdub I must re-derive keyframes which takes a very long time (otherwise I just get completely black frames)

Is there a bug in avc2avi that could be improved to avoid the re-deviving of keyframes? Or possibly a better tool out there for conversion.

ps. I've never gotten tsconverter to work properly on my win2k system, even v2 gives me "failed to build graph" and the log just says "Graph build failed at check point: AddPump"

Pookie
27th October 2006, 18:19
I haven't tested it, I have no idea if it'll work, but perhaps AVImaster (commandline) can do it. :D

http://www.thozie.de/dnn/LinkClick.aspx?link=AVIMaster.zip&tabid=36&mid=388

crypto
27th October 2006, 18:28
Pookie:

the link doesn't seem to work. "Unable to determine IP address from host name for www.thozie.de"

Pookie
27th October 2006, 19:44
Maybe this?

http://www.thozie.de/dnn/Default.aspx

crypto
27th October 2006, 19:53
Thanks, got it now.

DrNein
28th October 2006, 05:33
What's the best method for demuxing AVC/AC3 from M2TS, then remuxing a different AC3 into M2TS or MKV?

ProjectX craps out on loading (buffer error) and MPEG Streamclip seems to hang (unless it intends to take an hour to load the 10GB file). :confused:

crypto
28th October 2006, 07:54
AVCHD uses a different packet size on which most programs choke.

drmpeg has found a way to demux. See the thread New HD Format - AVCHD (By Sony and Panasonic) (http://forum.doom9.org/showthread.php?p=891337#post891337). Having the raw streams, you can remux to avi as described here or to mp4 using a newer mp4box build.

bond
28th October 2006, 12:12
muxing avc streams with the same encoder options used will work with mp4box

DreckSoft
28th October 2006, 13:27
Beyond storing the video in a more useable format than .ts (which does play fine in media player classic) I'd like to be able to do screenshots of individual frames via virtualdub so I convert to the raw h264 to avi but when I load into vdub I must re-derive keyframes which takes a very long time (otherwise I just get completely black frames)

Is there a bug in avc2avi that could be improved to avoid the re-deviving of keyframes? Or possibly a better tool out there for conversion.

AVC2AVI doesn't work properly on BBC streams. It only creates one big file. I have no idea why the split option doesn't work with BBCHD.

JK1974
29th October 2006, 02:13
@crypto:
The Readme of xporthdmv says:n = demux all audio, don't try to cut the start of audio to match the start of video.

Doesn´t this mean in other words that audio is not being synced? So it still would not be an alternative to an hopefully updated ProjectX in the future...

crypto
29th October 2006, 10:05
Exactly, xporthdmv does not attempt to resync. However, the constant lag can be corrected when muxing.

tauka
9th November 2006, 13:33
hi, i need a little help :)
i have a ts with h264 and ac3.. i wanna demux the ac3 in any way, i tried it with mencoder, but it says mpthreadgc2.dll is missing, i got it from the net, tried to register, but no succes. With projectx i get an ac3 file, which has the same length as the movie, but it has 31.25fps !??!?! actually the movie is pal, 25fps..with dvbportal TSConverter i got 31.25fps ac3 audio again.. :( vdubmod of course cant open it, only with directshowsource, but then in the stream list the audio can be demuxed only as uncompressed. can somebody help me? Is it possible at all to get it right out from it with 25fps?
thanks

crypto
9th November 2006, 17:07
How can an AC3 file have a fps? (frames per second?)

tauka
9th November 2006, 17:57
How can an AC3 file have a fps? (frames per second?)

well, eek, your right :)

i tried to synch it to an encode i just made, but i didnt succed.. it looked like how the time passed, the sound was more and more out of sync.. then i took a look at the delaycut info:

====== INPUT FILE INFO ========================
File is ac3
Bitrate (kbit/s) 448
Act rate (kbit/s) 448.000
File size (bytes) 314854400
Channels mode 3/2: L+C+R+SL+SR
Sampling Frec 48000
Low Frec Effects LFE: Present
Duration 01:33:42.400
Frame length (ms) 32.000000
Frames/second 31.250000
Num of frames 175700
Bytes per Frame 1792.0000
Size % Framesize 0
CRC present: YES
=============================================
====== TARGET FILE INFO ======================
Start Frame 0
End Frame 175699
Num of Frames 175700
Duration 01:33:42.400
NotFixedDelay 0.0000


You can see there.. i dont know how it is counted at all, but correctly it should have 25"fps", and 40ms frame duration... :confused:
i have no idea really how it can be, i could encode the movie well with 25fps..

crypto
9th November 2006, 18:34
OK, I see it :)

AC3 frames and picture frames don't have to be in a 1:1 relation. So 31.25 "fps" for the AC3 file is perfectly OK.

Just an idea, does the original file contain commercial breaks? If so, there are changes in video from HD to SD and audio from 5.1 to 2.0 which explain the bad synch.

tauka
9th November 2006, 21:22
OK, I see it :)

AC3 frames and picture frames don't have to be in a 1:1 relation. So 31.25 "fps" for the AC3 file is perfectly OK.

Just an idea, does the original file contain commercial breaks? If so, there are changes in video from HD to SD and audio from 5.1 to 2.0 which explain the bad synch.

hm, this stuff about the 1:1 relation is interesting :)
well i dont know, cause my comp cant play 1080p avc :) but as i said, i wouldnt explain the longer and longer outofsync :sly: it looks like somehow its wrong or i dont know :s

popper
10th November 2006, 13:02
I use mencoder to convert the BBC HD satellite broadcasts to XVID in one simple step and there doesn't seem to be much of an issue. It occassionally gives poor results but on the whole a useable solution. Takes several hours to convert a 1 hour (9Gb) file to approx 4GB, but atleast it's a solution. It'd be nice to have something as friendly as AGK, but you can't have it all.

your converting a part 10(AVC) into a part 2(ASP) mpeg4. that seems like a backward step doesnt it, plus only part 10 can use lossless encode cant it?, so you would be loosing even more quality there wouldnt you?.

regarding MP4Box , is it known if the author has/is fixing/adding the needed options to make life easyer for the gui front end writer etc, surely thats a better option in the long term than having to use the old avi step?.

Oxygen
14th November 2006, 10:34
As i understand, there isn't much of a solution to transcode h264.ts files except memcoder via cli ?

I'll need to look deeper into the x264 cli to transcode the files with the same flexibility/quality as MeGUI manage to produce.

---

Well, seems like mencoder is trashing me out:
the -dumpaudio works fine, creates a nice ac3 file, but the mplayer -dumpvideo (or mencoder -ovc copy -of rawvideo) doesn't do much at all except creating an empty file and using 100% cpu, but not filling content.

to be exact, dumpvideo closes down the mplayer with a
TS_PARSE: COULDN'T SYNC
Core dumped ;)

Exiting... (End of file)
and mencoder via -ovc copy -of rawvideo loops on a 100% cpu task with nothing filling the output file.

oddball
14th November 2006, 18:37
If you want to dump the video you are better off using TSConverter or xportdev. The pain of it is avc2avi_mod creates an AVI file with no index or keyframe info so when you load it into VDub you have to reindex and reykeyframe which can take ages. But it's the only way I have found I can edit out adverts and corrupt portions.

Oxygen
14th November 2006, 19:30
Also, i don't want to process the file via vdub ;)

Anyway i managed to get a graphedit filter working, but at .8 to .4fps ! (i suppose MBAFF deinterlace don't help the decoding)

It's, wow.

Pookie
16th November 2006, 03:51
You can try rebuilding the index with AVImaster


http://www.thozie.de/dnn/Home/tabid/36/EntryID/31/Default.aspx


Avimaster download link is on the right side of that page

Procedure: After AVC2AVI_mod creates your output.avi file, you would then run:

AVImaster.exe output.avi index.avi


Index.avi would then (theoretically) be your fixed up file. You can test if it works by loading up the resulting file in VirtualDub.

Would someone mind trying this? I'm not sure if it works or not. My access to h264 TS is limited on this side of the pond.

crypto
16th November 2006, 08:05
The lastest version of avi2avc_mod (http://forum.doom9.org/showthread.php?t=118267) handles BBC HD streams and builds key frame flags and an index. The resulting segmented avi loads perfectly into vdub.

blubberbirne
16th November 2006, 15:55
The resulting segmented avi loads perfectly into vdub.

What did you installed to open the avi in virtual dub? VD gives me an error that no H264 vfw codc is installed ??!

crypto
16th November 2006, 18:32
What did you installed to open the avi in virtual dub? VD gives me an error that no H264 vfw codc is installed ??!

ffdshow latest build. During setup select vdub support. (Links are in the avc2avi mod (http://forum.doom9.org/showthread.php?p=900451#post900451) thread)

blubberbirne
16th November 2006, 18:54
thx, will test it ;)

Oxygen
17th November 2006, 14:28
Well, seems i found a nearly working way.

Transmuxing the ts file into an mkv file via a dshow filter based on haali filters works fine.

Only one draw back of this solution, a desynch between audio & video seems to occur. Nothing unfixable though :)

VincentNguyen
7th December 2006, 16:54
Oxygen,

Could you describe your procedure to transcode directly to MKV using your dshow filter ? Did you fix the sync issue ?

Selur
4th January 2007, 10:09
btw. only way that worked for me to get multiple .ts files (of one movie) into a synch playing mkv:

1. cut the files with TSPE and create for each cut a new .ts file
2. remux each of these files with graphedit and Haalis muxer into new .mkv files
3. join these .mkv files with avi-mux gui

Cu Selur

Ps.: Could you describe your procedure to transcode directly to MKV using your dshow filter ?
probably like I do it:
1. start graphedit
2. throw the ts in it
3. remove all the filters except the one that's opening the file
4. insert Haalis muxer
5. connect the two filters
6. hit the play button

Oxygen
4th January 2007, 10:53
Ps.:
probably like I do it:
1. start graphedit
2. throw the ts in it
3. remove all the filters except the one that's opening the file
4. insert Haalis muxer
5. connect the two filters
6. hit the play button

Exact :)

JK1974
4th January 2007, 11:10
Sorry for this basic question, but I can´t remember the full name of TSPE or missed this tool in the previous threads - or is it just a typo? I just remember DVBViewer´s TS Player and TSConvert as tools for cutting H.264-TS files.
Second, I thought there is currently no way to demux H.264 video and audio streams in sync and that you have to sync them by cutting the audio streams manually. Are there really no sync problems with the graphedit procedure you just described or does it just work for your files? Or does it work because you cut the stream in the first step?

Oxygen
4th January 2007, 11:14
Transport Stream Packet Editor (TS Packet Editor)

As for the synch issues, i said from the start i have some.

I didn't check yet with a clean ts file as an input, but TSPE could do the trick, as i think the desynch is due to a badly cut ts file from the start.

JK1974
4th January 2007, 11:51
@Oxygen:
Thanks for your info. I also found more discussion in a German language web board - maybe because in Europe H.264-HDTV is in the first place and not MPEG-2-HDTV.

Oxygen
4th January 2007, 12:07
Please, don't be afraid to share your findings with us here, my german is way too underused to be good enough for such researchs :/

JK1974
4th January 2007, 12:26
@Oxygen:
They don´t have any new findings :), but as the Germans (nearly) don´t have MPEG2 transmissions, they are focussed on editing H.264 recordings only which is IMHO some advantage compared to the discussions here. But Selur is also there, and because here visits doom9 more often than me and posts more I am sure that he will keep you/us always up-to-date on the latest experiments there :)

Selur
11th January 2007, 09:41
atm. we got three main ways:

I. (the way I do it ;))
1. cut the files with TSPE and create for each cut a new .ts file
2. remux each of these files with graphedit and Haalis muxer into new .mkv files
3. join these .mkv files with avi-mux gui

and

II. (bergi 's way)
- looking for TSPE for cut points (better scan clip and use 'test' to be sure'
- using TSCut to cut the stream (since it's about 2 times faster than TSPE)
- use GraphEdit to mux to mkv (if you only got one audio stream skip the rest; otherwise only mux the video)
- use xport with -n parameter to demux multiple audiostreams
- use PTScalc get the delay of the audio streams (seems like this only functions when -n in xport was used)
- feed avimux gui with the mkv file and the ac3 files and use the delay values from ptscalc

Haven't tried II, since I got some problems with some of the tools bergi uses, but I asked him for commandline parameters & Co. (he also wrote a little gui for tscut which he might share with the community)

the above comes from the german doom9/gleitz board, there's also a discussion on the german movie2digital board, with another approach by madshi & Schmendrick1 (which I don't use since I don't use the required ds filters:

III.
h264tsto v1.0, freeware by madshi.net

Usage: h264tsto srcFilename.ts destFilename.mkv|destFilename.h264

This tool can either demux the H.264 stream to a raw *.h264 file.
Or it can mux the H.264 stream into a Matroska (*.mkv) container.

Demuxing into a raw *.h264 file needs the following filters to be installed:
(1) Elecard or Cyberlink Demuxer (empgdmx.ax/CLDemuxer.ax)
(2) Dump (dump.ax, shipping with GraphEdit)

Muxing into a Matroska container needs the following filters to be installed:
(1) Haali Media Splitter
(2) Haali Matroska Muxer

http://madshi.net/h264tsto.zip
I am sure that he will keep you/us always up-to-date on the latest experiments there
I try to if I remember to do so. ;)

Can't tell you which way is the 'best'/'most elegant' one since I only use I. since it's easy and works fine for me with the german Pro7 and englisch SkyHD streams I tried. (got no DVB-S2 compatible hardware myself so I only use captures provided by some friends)

Cu Selur

Ps.: if anyone uses xport: bergi needs some additional infos about pts <-> audio delay (in ms) so that he can modify xport (if he finds the time ;))

drmpeg
11th January 2007, 12:28
Ps.: if anyone uses xport: bergi needs some additional infos about pts <-> audio delay (in ms) so that he can modify xport (if he finds the time ;))
Hi, I'm the author of xport. The current version at:

http://www.w6rz.net/xport.zip

has been updated to handle H.264 video streams. It will properly start the video elementary stream on the first I-frame/field encountered, and will cut the audio elementary stream to match that I-frame/field. That is, the audio delay will be zero (when NOT using the -n option).

Ron

bergi
11th January 2007, 13:43
has been updated to handle H.264 video streams. It will properly start the video elementary stream on the first I-frame/field encountered, and will cut the audio elementary stream to match that I-frame/field. That is, the audio delay will be zero (when NOT using the -n option).That didn't work for me. Perhaps I missed something, but with the -n option and the right delay in the mkv file (calculated with PTScalc) everything was ok. xport already outputs the difference, but not in milliseconds. Could you add this feature to xport? Also an option to demux multiple audiostreams at the same time (without hardcoded names) would be cool, but the difference in ms stuff is more important for me.

drmpeg
11th January 2007, 14:10
That didn't work for me. Perhaps I missed something, but with the -n option and the right delay in the mkv file (calculated with PTScalc) everything was ok. xport already outputs the difference, but not in milliseconds. Could you add this feature to xport? Also an option to demux multiple audiostreams at the same time (without hardcoded names) would be cool, but the difference in ms stuff is more important for me.
The difference that xport reports is in 90 kHz ticks. So the delay in milliseconds would be difference/90.

For example, here's a typical dump from xport:

First Video PTS = 0x00025c1f
First Audio PTS = 0x00026bae, 1103

So the audio delay would be 1103/90 or 12.25 milliseconds.

I've thought about adding the other features you mention. I guess that I consider xport to be more like sample code than an actual application (given that it's command line only). However, the tool does have some following, so maybe I should spend some time on it. ;)

Ron

Pookie
11th January 2007, 14:57
"However, the tool does have some following, so maybe I should spend some time on it"

Indeed...Easily the fastest demuxer out there. Mandatory for the toolkit. Whatever you do, please keep it scriptable.

xlazom00
11th January 2007, 18:25
my experience

F:\>xport.exe star.wars.episode.four.a.new.hope.1080p.h264.oar.dd51.ts 3 1 1
program = 3, video channel = 1, audio channel = 1
Program Number = 3 (0x0003), Program Map PID = 48 (0x0030)
program descriptor = 0x0c, 0x04, 0x80, 0xb4, 0x81, 0x68
program descriptor = 0x10, 0x06, 0xc1, 0x5a, 0x01, 0xc0, 0x08, 0x00
Video PID = 49 <0x0031>, type = 0x1b
Audio PID = 52 <0x0034>, type = 0x81
ES descriptor for stream type 0x81 = 0x6a, 0x04, 0x41, 0x43, 0x2d, 0x33
5 frames before first I-frame
Main Profile
Level = 4.0
First Video PTS = 0x519ccc73
First Audio PTS = 0xf6db7d03, -1522621104
Audio Bitrate = 384000, Audio Sampling Rate = 48000
Audio Mode = 2/0, bsid = 6, bsmod = 0

packets for pid 0 <0x0000> = 2057, first = 2350, last = 10103841
packets for pid 48 <0x0030> = 2057, first = 2351, last = 10103842
packets for pid 49 <0x0031> = 9844451, first = 1, last = 10106140
packets for pid 52 <0x0034> = 231542, first = 3, last = 10106103
packets for pid 8190 <0x1ffe> = 26033, first = 360, last = 10106097
mpeg frames = 0, video fields = 0


this is from mplayer while i'm playling ac3 track. same with h264. But it's only first coupe frames
Starting playback...
a52: CRC check failed!
a52: error at resampling
a52: CRC check failed!
a52: error at resampling
a52: CRC check failed!
a52: error at resampling
a52: CRC check failed! (14:44.5) ??,?% 25%
a52: error at resampling
a52: CRC check failed!
a52: error at resampling
a52: CRC check failed!
a52: error at resampling
a52: CRC check failed! (14:44.5) 1.3% 49%
a52: error at resampling
a52: CRC check failed!
a52: error at resampling

bergi
11th January 2007, 19:23
I think I have done something wrong last time using xport. xport sync works fine!

Here is my small howto ts->mkv:
- Find cutpoints with TSPE
- Cut with bergtscut
- Use GraphEdit to remux the videostream from the ts file to mkv file
- Demux audiostream(s) with xport (without -n!)
- Mux video mkv file and audiostream(s) with mkvmerge/AVI-Mux GUI (delay=0)

bergtscut (https://www.axolotlfarm.org/~bergi/projects/bergsat/bergtscut20070111.zip) is a small command line programm for cutting ts files. It's a very stupid program, it just cuts files 188byte aligned, but with a big buffer (~100mb).

Pookie
11th January 2007, 21:24
Right on, bergi. Your new app might be good for postprocessing Comskip as well.

--Note: bergtscut.exe is using the info from the "Byte" fields in TSPE.

bergtscut.exe 2317476 121971952 in.ts out.ts

The above example is saving the data between 2.3MB and 121.9MB (approximately)

Guide and download link for TSPE :

http://www.flaskmpeg.info/board/thread.php?postid=68161&sid=4bb930ec4ef749a2557276284d1451b5#post68161

wiak
12th January 2007, 00:51
checked a tool called ts packet editor?
http://www.techpowerup.com/downloads/435
:D

apk
12th January 2007, 01:27
I followed the instructions but only got this:


D:\>1\mencoder.exe "D:\1\testcap.ts" -of rawvideo -ovc copy -oac copy -noskip -o
D:\1\test.264
MEncoder dev-SVN-r19260-4.0.3 (C) 2000-2006 MPlayer Team
CPU: AMD Athlon(tm) 64 Processor 3500+ (Family: 15, Model: 47, Stepping: 0)
CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE SSE2

93 audio & 210 video codecs
success: format: 0 data: 0x0 - 0x3437a50
TS file format detected.
VIDEO MPEG2(pid=1502) AUDIO A52(pid=1505) NO SUBS (yet)! PROGRAM N. 0
TS_PARSE: COULDN'T SYNC
MPEG: FATAL: EOF while searching for sequence header.
Video: Cannot read properties.

Hans Ohlo
27th January 2007, 11:51
i got the following output from xport:

D:\__encode\test>.\..\__tools\xport\xport -n test.1080p.h264.dd51.part1.ts 3 1 1
program = 3, video channel = 1, audio channel = 1
Program Number = 3 (0x0003), Program Map PID = 48 (0x0030)
program descriptor = 0x0c, 0x04, 0x80, 0xb4, 0x81, 0x68
program descriptor = 0x10, 0x06, 0xc1, 0x5a, 0x01, 0xc0, 0x08, 0x00
Video PID = 49 <0x0031>, type = 0x1b
Audio PID = 52 <0x0034>, type = 0x81
ES descriptor for stream type 0x81 = 0x6a, 0x04, 0x41, 0x43, 0x2d, 0x33
First Audio PTS = 0xfe935f8d, -23899059
Audio Bitrate = 384000, Audio Sampling Rate = 48000
Audio Mode = 2/0, bsid = 6, bsmod = 0
2 frames before first I-frame
Main Profile
Level = 4.0
First Video PTS = 0xfe94c24a

packets for pid 0 <0x0000> = 1931, first = 1, last = 9760750
packets for pid 48 <0x0030> = 1931, first = 2, last = 9760751
packets for pid 49 <0x0031> = 9518357, first = 3, last = 9761084
packets for pid 52 <0x0034> = 214722, first = 19, last = 9761071
packets for pid 8190 <0x1ffe> = 24143, first = 107, last = 9761002
mpeg frames = 0, video fields = 0

what should i make of this? when i mux the output streams to a mkv container without any delays added the audio is slightly out of sync (i would say max +500ms). but how can i get the exact delay from this output?

drmpeg
27th January 2007, 14:09
i got the following output from xport:

D:\__encode\test>.\..\__tools\xport\xport -n test.1080p.h264.dd51.part1.ts 3 1 1
program = 3, video channel = 1, audio channel = 1
Program Number = 3 (0x0003), Program Map PID = 48 (0x0030)
program descriptor = 0x0c, 0x04, 0x80, 0xb4, 0x81, 0x68
program descriptor = 0x10, 0x06, 0xc1, 0x5a, 0x01, 0xc0, 0x08, 0x00
Video PID = 49 <0x0031>, type = 0x1b
Audio PID = 52 <0x0034>, type = 0x81
ES descriptor for stream type 0x81 = 0x6a, 0x04, 0x41, 0x43, 0x2d, 0x33
First Audio PTS = 0xfe935f8d, -23899059
Audio Bitrate = 384000, Audio Sampling Rate = 48000
Audio Mode = 2/0, bsid = 6, bsmod = 0
2 frames before first I-frame
Main Profile
Level = 4.0
First Video PTS = 0xfe94c24a

packets for pid 0 <0x0000> = 1931, first = 1, last = 9760750
packets for pid 48 <0x0030> = 1931, first = 2, last = 9760751
packets for pid 49 <0x0031> = 9518357, first = 3, last = 9761084
packets for pid 52 <0x0034> = 214722, first = 19, last = 9761071
packets for pid 8190 <0x1ffe> = 24143, first = 107, last = 9761002
mpeg frames = 0, video fields = 0

what should i make of this? when i mux the output streams to a mkv container without any delays added the audio is slightly out of sync (i would say max +500ms). but how can i get the exact delay from this output?

Hi. I think I know what's going on. Will investigate.

Ron

bergi
29th January 2007, 10:36
D:\__encode\test>.\..\__tools\xport\xport -n test.1080p.h264.dd51.part1.ts 3 1 1
Just call xport without the -n parameter and everything should be ok.

drmpeg
29th January 2007, 12:20
Just call xport without the -n parameter and everything should be ok.

Good eye, I missed that.

Ron

lupus11
2nd February 2007, 12:05
PTSCalc ? The homepage is no longer working. Is there any alternative download link ?

Thank You
lupus

enantiomer
2nd February 2007, 18:27
Ron,
This is slightly off topic, but I was attempting to demux a VC-1 BDMV transport stream, and found that xport could not recognize the video stream. I was wondering if you could augment your xport program to handle VC-1? Or is there an option to force the demuxing of a particular PID?

Regardless, your evob_demux and xport tools have been very helpful. Thanks.

Pookie
2nd February 2007, 19:04
lupus - http://technik.movie2digital.de/thread.php?threadid=38242

Demone
5th February 2007, 18:49
I noticed that during ts demux of h264 mencoder is at 250fps then at about 15% of ALL of my ts's it starts to slowdown and never ends, as of writing its at 30% and 68fps and still drops 1fps every 10 seconds.
Do you know if there's any problem with ntfs and big filesizes ?

Thanks

Pookie
6th February 2007, 02:13
Dunno, but you can troubleshoot by testing various builds of Mencoder. It might be time consuming to do so, however

http://oss.netfarm.it/mplayer-win32.php

http://tirnanog.fate.jp/mirror/mplayer/

Additional things to try:

demux with h264tsto

demux with xport

Increase your page file size in windows

Run a defrag on your drive

Demux to a different physical drive (this speeds things up a lot)

protovision
6th February 2007, 16:56
I noticed that during ts demux of h264 mencoder is at 250fps then at about 15% of ALL of my ts's it starts to slowdown and never ends, as of writing its at 30% and 68fps and still drops 1fps every 10 seconds.
Do you know if there's any problem with ntfs and big filesizes ?
Thanks

As pookie mentioned, use separate source/destination drives, and defrag your drive with a good defragger. I ran into the same issue when joining many .ts streams into one. HDTV2MPEG started at 40 MB/s, then about 50% done, it slowed to 15MB/s. My drive was fragmented, so it was jumping all over the drive when joining the pieces, and then jumping looking for somewhere to save to. Defragged with PerfectDisk8, all better now.

p.

Pookie
6th February 2007, 22:41
Jkdefrag . Free and good.

http://www.kessels.com/JkDefrag/index.html

Demone
7th February 2007, 12:58
Hi guys,
thank you very much for your help the problem is that I'm just using two different hd and I tried to invert source/destination
and tried only one hd too that is very fast, but no way.
The strangeness here is that mencoder starts very fast as I said like 250fps then slowdown at 2%/3%... for a complete movie that is 15gb it took 45 minutes to demux too much !!! :scared:
I'll try mplayer and see if its different

Kurtnoise
7th February 2007, 19:04
You can try also MP4Box to extract raw avc from TS files...

Demone
7th February 2007, 20:18
Oh thanks,
I just remember now I had problems creating mp4 from big h264 files with it so I switched to mp4creator cause it has a flag for big file support.

Demone
7th February 2007, 21:47
@protovision
I doubt its a fragmentation problem, when the hd is fragmented heads spin like mad while my hd is not used at all.
With 22096 build of mplayer I reached the 9gb at full speed and I was about to joy when it started to slow down again.:confused:
It reached 9gb in 10 minutes and after 30 minutes its still at 14gb.
The cpu max level is 20% during all the time there are no swap hd movements as the page file is fixed at 530mb/1.5GB so it should be some mplayer/mencoder problem.

albatross83
12th February 2007, 10:31
The download link on the PTSCalc site is broken. Page works, download link on the page doesn't. Anyone have an alternative source? Hardly any results from Google and I've explored them all without success.

Schmendrick
12th February 2007, 10:58
Hi albatross83,

following a link to the orginal german forum page where PTSCalc was presented:

http://technik.movie2digital.de/thread.php?threadid=38242

PTSCalc is available as attachement on the first post of the thread in this link and it is explained on the website of the author: http://rickman.ri.funpic.de/ which does not contain the programme itself.

Good luck

Schmendrick

albatross83
12th February 2007, 11:18
Not sure how I missed that attachment, but I did. Thanks!

Cryptum
16th March 2007, 20:17
Here is my little contribution :

Ok I have found a (even few) way to join parts files into one file (MKV file)
It's not a very clean method but that works well !

Beginning with the TSPE splitting method :

1) After the splitting operation, we need tu mux every ts part on an mkv container,
by doing this with h264tsto -> http://forum.doom9.org/showthread.php?t=117806

1.1) Then the simple way is to join all parts with AVI-Mux GUI into one MKV file.
This last step is very easy and the final resultat is an playable file.
There are no audio sync problem, no playback problem, I mean, we can passing through
the splitting points without stuttering or other problem, we can jump forward/backward
very well. But still, there are ONE problem.
The openning of this file take very long time (5-10 sec)
but after that, there are no more problem.
I don't know why this bug (maybe it's because AVI-Mux GUI makes a MKV V1 instead of V2)

2) Second method is a little similar. So we need to mux the parts with h264tsto.

2.1) We need to use MKVMerge to join all MKV parts.
Result does a playble file but the audio after the first part is unsync,
so we need to estimate this and remux another time but by adding the new sync parameter.
To do that -> Click on the second audio part -> Format specific options ->
And fill the "Delay" in with our estimation.
Same thing with the third audio part (but normaly with a higher sync value),
again with the fourth part, etc...
Check the result and correct if it needs to.

With this method (a little bit annoyning I know ..), with have an MKV file playable
and without problem (I haven't seen one until now !)

Splitting with TSsplitter :

3) It's easier because we have a GUI, we have 2 modes to split
(position in time value or Byte value).
We can use the same method at point 1.1, but we cannot use the method 2.1,
MKVMerge failed with a lot of "position" error. Can't find a solution at this time :(

4) I have not tested this but I think it will work.
So another alternative is to mux the entire TS movie with h264tsto.
4.1) Split the file with the help of MKVMerge -> Tab "Global" -> "splitting".
This is not very convenient, like TSPE, without a preview mode like on TSsplitter
but that can do it and furthermore it does that well (because joining step are doing well)
Now the last step is to join all parts with MKVMerge too and maybe we don't need
to resync audio stream (I'm not sure about that ..)

So now we have a "normal" playable file,
easy to sync subtitle whith it and more "appearence friendly" ;)

PS: Thx to Selur for the tip about AVI-Mux GUI

Da Cryptum

Selur
16th March 2007, 20:51
(maybe it's because AVI-Mux GUI makes a MKV V1 instead of V2)
this can be changed:
Avi-Mux Gui -> settings ->mkv structure->Matroska version ;)

Cryptum
16th March 2007, 21:09
Oh yes we need to uncheck the V1 before :P
Strange method lol

Thx

Da Cryptum

Edit : Hum so same problem than V1. Long long time to open the file :(

Selur
17th March 2007, 08:39
What filters do you use?
Doesn't take long here (Haali+CoreAVC+ffdshow for aac->ac3->spdif).

Cryptum
17th March 2007, 15:09
Sometimes CoreAVC+ffdshow and sometimes only CoreAVC.
And for audio, I use AC3Filter. That's it ;)

I don't think that comes from filters because my others MKV haven't this problem.

Da Cryptum

Atak_Snajpera
18th March 2007, 00:08
How to demux all audio streams with xport at once?

drmpeg
19th March 2007, 06:31
How to demux all audio streams with xport at once?
It's not possible with the current version. It was originally written for a hardware decoder many years ago, and targeted for one video and one audio stream output. Although it's certainly possible to demux all elementary streams, it won't be easy to implement with the current architecture of xport.

To speed things up, you can select a video track that's not in the multiplex for subsequent audio tracks. Like this:

xport clip.ts 1 1 1

This will demux the video and audio track 1. Then:

xport clip.ts 1 7 2

This will demux audio track 2 and create a zero byte file for bits0001.mpv (be sure to rename the first bits0001.mpv that has the demuxed video beforehand). The demux process will be much faster since there's no video to demux.

Ron

MarkRy
20th March 2007, 12:19
My first post! Excellent thread. Learned alot.

I have, thanks to this thread, converted an BBCHD DVB-S .ts to MP4 and AVI. As I did all the different bits, the video looked slow but I thought it was my system / codecs. Now its all complete I see I have a problem. The AVI file plays the audio at the correct speed and the video at half speed. Working backwards I go back to the ts file which in Mplayer plays the video half speed while repeating the audio bits twice.

At the start of the process, when I dump the video using mplayer, I imagine the half speed video problem is fixed into everything else I do.

I'm guessing its an interlace setting but would appreciate help. Thanks

Edit: I played the avi file in DVBViewer and it was a mirror image in the horizontal axis but it seems at the right speed! Any ideas what is going wrong?

The reason I am converting files is that I bought the Evesham iplayer to play HD / SD files. Prior a firmware update it could receive the BBC HD DVB-T broadcast. So I bought a card for my PC and recorded the satellite stream. It tries but cant play DVB-S ts off a USB Hard Drive. An analysis of the clip looks so similar to a recording of the DVB-T BBC-HD signal. But it wont play. I dont want to reencode the DVB-S stream (if I can help it) so MP4 and AVI seem a good 2nd best. I either need to find out why it wont play the DVB-s ts stream and tweak it, or create a solid MP4 or AVI stream it will. Is that asking too much!

Atak_Snajpera
23rd March 2007, 23:58
Does xport correct audio delay automatically?

drmpeg
24th March 2007, 01:36
Does xport correct audio delay automatically?
Yes. It discards all video up to the first I-frame. Then it saves the PTS of the first video frame (usually a B-frame). Based on that video PTS, the audio frames before that PTS are discarded.

So the audio delay should be near zero. Since the granularity of video and audio frames is different (33 ms for 30 fps video and 32 ms for AC-3 audio), there will still be a small residual audio delay.

C:\newmobcal>xport BBCHD1-DigiTV-2.ts 36932 1 1
xport Transport Stream Demuxer 0.94
program = 36932, video channel = 1, audio channel = 1
Program Number = 0 (0x0000), Program Map PID = 16 (0x0010)
Program Number = 36932 (0x9044), Program Map PID = 600 (0x0258)
Video PID = 1502 <0x05de>, type = 0x1b
ES descriptor for stream type 0x1b = 0x52, 0x01, 0x0b
Audio PID = 1505 <0x05e1>, type = 0x06
ES descriptor for stream type 0x06 = 0x0a, 0x04, 0x65, 0x6e, 0x67, 0x00
ES descriptor for stream type 0x06 = 0x6a, 0x01, 0x00
ES descriptor for stream type 0x06 = 0x52, 0x01, 0x08
Audio Bitrate = 384000, Audio Sampling Rate = 48000
Audio Mode = 3/2, bsid = 6, bsmod = 0
2 frames before first I-frame
High Profile
Level = 4.0
First Video PTS = 0x73b9d651
First Audio PTS = 0x73b9d4a5, -428
ts rate = 24128312
packets for pid 0 <0x0000> = 115, first = 924, last = 183815
packets for pid 16 <0x0010> = 1, first = 110209, last = 110209
packets for pid 17 <0x0011> = 8, first = 6940, last = 160954
packets for pid 20 <0x0014> = 2, first = 65063, last = 126381
packets for pid 600 <0x0258> = 115, first = 1533, last = 184424
packets for pid 1502 <0x05de> = 156419, first = 1, last = 184510
packets for pid 1505 <0x05e1> = 3235, first = 38, last = 184509
packets for pid 8191 <0x1fff> = 24616, first = 6, last = 184511
coded frames = 0, video fields = 0

C:\newmobcal>


So in the above sample, 2 video frames were discarded before the first I-frame. The first Video PTS was 0x73b9d651 and the audio was cut to the the audio frame that had PTS 0x73b9d4a5. The residual delay is -428, which is in 90 kHz ticks. To convert to milliseconds, divide by 90.

Ron

Atak_Snajpera
24th March 2007, 08:08
thanks!

Hironimo
13th April 2007, 16:12
Hi there.

I'm trying to process some of my captured h.264 .ts files.

First thing i noticed is that xport crashes.
drmpeg provided a fix (some unsual .ts stream, possibly normal for the Pro 7 and Sat.1 HD channels) - i will test that soon, dont know if that fix is public yet.

So I used mencoder temporarily and managed to convert the output to an avi.

What I noticed however is that when I re-derive the keyframes with virtualdub(mod) the resulting video is much less usable. I get far better results by opening the seperate output files (4 of them as there is about 7gb of video data) using the append segment function and save it to a single avi.

Please note however that VirtualDubMod seemes to have a bug that does not do the appending correctly (adds more data then there actually is), so I had to use the convential VirtualDub.

Once I had an avi I tried to work with it, but the ffdshow decoder does not decode it particularly well (even though the later versions do a better job). It decodes many frames incorrectly and even crashes, taking virtualdub with it.
See here (http://forum.doom9.org/showthread.php?t=124674) for details.

The other problem I have is the audio - it starts with a few seconds of stereo and then continues with 5.1 channels (except for the advertisements that are in stereo again).

This apparently causes VirtualDubMod to detect the bitrate and length of the audio incorrectly.

I just wanted to let you guys know of my experience, as some might find it helpful (see the info on the append segement and the re-derival of the keyframes).

Maybe someone even has info on how I can get rid of the problemlems described?

Kandor
13th April 2007, 19:32
Hi

I am reading through this thread as I find it intresting.

But what I can not understand is why are we not just using DGindex for demuxing the audiotrack?

The video demuxing and converting to avi I find very usefull, but what about the AC3 demuxing? would´t DGindex give the correct delay value and everything?

I can not try this by my self as I don´t have any .ts sources with h.264 and will most probebly not ever have because I will probebly not subscribe on any tv channels in the future.
But I find it allways interesting to figure out things.

Best regards
Kandor

Recently I tried to add a second language track to a TS file containing H264/AVC Video and AC3 audio. It proved more difficult than I thought. I came up with the following solution. Most parts are collected from some thread in this forum, so credits go to the original posters.

1. Demuxing TS:
Extract the video to RAW H264 and AC3 audio. I used mencoder for this. I used the version from 31.07.2006 from here: http://tirnanog.fate.jp/mirror/mplayer/
The latest official release didn't work
To demux video use the following command:
mencoder.exe "Z:\Infile.ts" -of rawvideo -ovc copy -oac copy -noskip -o Y:\Outfile.264
Demux audio using ProjectX (http://www.lucike.info/page_projectx.htm). This has the advantage that you see stream errors in the log. ProjectX will complain a lot about GOP size and won't extract the video track. It will extract all audio tracks and fix errors. I recommend recapping if you'll get errors as watching a file with errors is not much fun and synching the audio will be a pain in the ass. If you don't like ProjectX, you can still use
mencoder.exe "Z:\Infile.ts" -of rawaudio -ovc copy -oac copy -noskip -o Y:\Outfile.ac3
but you'll only get one audio track and no error report.

2. Put H264 into AVI:
AVC2AVI: (link see post from crypto)
avc2avi -i Y:\Outfile.264 -o Z:\Avifile.avi -c H264 -s 2000
Note: AVC2AVI doesn't like streams from BBCHD. Those are in 1440x1088 but AVC2AVI says 1440x1084 and will create one large avi which will require the fixing mentioned in Step 4 (look in section Obsolete). The original AVC2AVI reports 1440x540...

3./4. Removed

5. Add Audio:
You will most likely have to use a delay since the AV delay is not fixed when demuxing. The best thing is to add the audio multiple times with different delays and then see which is the best. You can also add more audio tracks here or cut unwanted parts. Save to a new AVI. Btw: I use VirtualDubMod for this.

6. (Optional) Convert to MKV:
AVI and H264/AVC isn't the best combination, so you may want to use MKV instead of AVI. Use MKVToolnix to create the MKV. You'll have to add the option "--engage allow_avc_in_vfw_mode". The resulting file may already work, it did half the time here. Better also do the following: Open the MKV in AVIMux GUI and save to a new MKV.

Obsolete (were necesary if you use original AVC2AVI from http://forum.doom9.org/showthread.php?t=89979):
3. Change the resolution:
The AVI will have a resolution of 1920x544 instead of 1920x1088. Use a hex editor to change the third occurence of 2002 to 4004.

4. Fix AVI File:
Open the AVI in VirtualDubMod, choose "Ask for extended options after this dialog", then choose "Re-derive keyframe flags".
It will take a looooong time till it's finished. Save the file with direct stream copy to a new avi, so you won't have to do the rekeying again if something goes wrong later. Note that VirtualDub most likely will display a lot of garbage when seeking but the resulting file will play fine

Obsolete (alternate demux commands, didn't work properly once, so I'm using the ones mentioned above):
1. Demuxing TS:
mplayer -dumpvideo -dumpfile Y:\Outfile.264 Z:\Infile.ts
mplayer -dumpaudio -dumpfile Y:\Outfile.ac3 Z:\Infile.ts

Hironimo
13th April 2007, 19:51
will probebly not subscribe on any tv channels in the future

Not subscribe? You mean pay-tv?
There are a few hdtv channels availably freely.
All you need is the appropriate reception and hardware, which you can get around 100 bucks.

D-Train
11th May 2007, 20:54
I've read this thread a few times and have had some success. I have a few questions too.

The video I'm trying to edit is a "raw" transport stream, 1440x1080i @29.97fps PAFF encoded, from Dish Network Universal HD.

So far I have been able to edit this video using the following steps:
1) Use TsRemux.exe to create a new transport stream with PMT and PAT packets
2) Identify cut points using TS_Packet_Editor.exe
3) Using cut points make part1.ts, part2.ts, etc.
4) Remux files into mkv using h264tsto.exe
5) Join part1.mkv, part2.mkv, etc. using AVIMux-GUI

The final file is great with the exception that the cut points are "dirty" and display artifacts. I'm sure it's that I'm not cutting on appropriate frames. I read that I want to identify and cut at IDR frames. How can I do this? Is this something I can identify from h264_parse output?

Originally, when cutting I used TSPE which cuts based on byte marks. I found that the audio and video PTS times drift at points and I wasn't getting clean cuts. Here's an xport output from a small section, notice the difference in PTS?

xport Transport Stream Demuxer 0.95
program = 1, video channel = 1, audio channel = 1
Program Number = 1 (0x0001), Program Map PID = 16 (0x0010)
Audio PID = 4387 <0x1123>, type = 0x81
Video PID = 4386 <0x1122>, type = 0x1b
Video PTS(P) = 0xf2adffcc
Video PTS(P) = 0xf2ae05a9, 1501
Video PTS(P) = 0xf2ae1742, 4505
Video PTS(P) = 0xf2ae1d1f, 1501
Video PTS(P) = 0xf2ae51e9, 13514
Video PTS(P) = 0xf2ae57c6, 1501
Video PTS(P) = 0xf2ae3a73, -7507
Video PTS(P) = 0xf2ae4050, 1501
Audio PTS = 0xf2abf433, -223611853
Video PTS(P) = 0xf2ae2eb8, -4504
Video PTS(P) = 0xf2ae3495, 1501
Audio Bitrate = 384000, Audio Sampling Rate = 48000
Audio Mode = 3/2, bsid = 8, bsmod = 0
Video PTS(P) = 0xf2ae462e, 4505
Video PTS(P) = 0xf2ae4c0b, 1501
Video PTS(P) = 0xf2ae80d5, 13514
Video PTS(P) = 0xf2ae86b2, 1501
Video PTS(P) = 0xf2ae695f, -7507
Video PTS(P) = 0xf2ae6f3c, 1501
Video PTS(P) = 0xf2ae5da4, -4504
Video PTS(P) = 0xf2ae6381, 1501
Audio PTS = 0xf2ac2c73, 14400
Video PTS(P) = 0xf2ae751a, 4505
Video PTS(P) = 0xf2ae7af7, 1501
Video PTS(P) = 0xf2aeafc1, 13514
Video PTS(P) = 0xf2aeb59e, 1501
Video PTS(P) = 0xf2ae984b, -7507
Video PTS(P) = 0xf2ae9e28, 1501
Video PTS(P) = 0xf2ae8c90, -4504
Video PTS(P) = 0xf2ae926d, 1501
Video PTS(P) = 0xf2aea406, 4505
Audio PTS = 0xf2ac64b3, 14400
Video PTS(P) = 0xf2aea9e3, 1501
Video PTS(P) = 0xf2aedead, 13514
Video PTS(P) = 0xf2aee48a, 1501
Video PTS(P) = 0xf2aec737, -7507
Video PTS(P) = 0xf2aecd14, 1501
Video PTS(P) = 0xf2aebb7c, -4504
Video PTS(P) = 0xf2aec159, 1501
Video PTS(P) = 0xf2aed2f2, 4505
Video PTS(P) = 0xf2aed8cf, 1501
Video PTS(P) = 0xf2af0d99, 13514
Audio PTS = 0xf2ac9cf3, 14400
Video PTS(P) = 0xf2af1376, 1501
Video PTS(P) = 0xf2aef623, -7507
Video PTS(P) = 0xf2aefc00, 1501
Video PTS(P) = 0xf2aeea68, -4504
Video PTS(P) = 0xf2aef045, 1501
Video PTS(P) = 0xf2af01de, 4505
Video PTS(P) = 0xf2af07bb, 1501
Video PTS(P) = 0xf2af3c85, 13514
44 frames before first I-frame
Main Profile
Level = 4.0
Audio PTS = 0xf2acd533, 14400
Video PTS(P) = 0xf2af4262, 1501
First Video PTS = 0xf2af3c85
Video PTS(P) = 0xf2af250f, -7507
Video PTS(P) = 0xf2af2aec, 1501
Video PTS(P) = 0xf2af1954, -4504
Video PTS(P) = 0xf2af1f31, 1501
Audio PTS = 0xf2ad0d73, 14400
Video PTS(P) = 0xf2af30ca, 4505
Video PTS(P) = 0xf2af36a7, 1501
Video PTS(P) = 0xf2af6b71, 13514
Video PTS(P) = 0xf2af714e, 1501
Audio PTS = 0xf2ad45b3, 14400
Video PTS(P) = 0xf2af53fb, -7507
Video PTS(P) = 0xf2af59d8, 1501
Video PTS(P) = 0xf2af4840, -4504
Video PTS(P) = 0xf2af4e1d, 1501
Video PTS(P) = 0xf2af5fb6, 4505
Video PTS(P) = 0xf2af6593, 1501
Audio PTS = 0xf2ad7df3, 14400
Video PTS(P) = 0xf2af9a5d, 13514
Video PTS(P) = 0xf2afa03a, 1501
Video PTS(P) = 0xf2af82e7, -7507
Video PTS(P) = 0xf2af88c4, 1501
Video PTS(P) = 0xf2af772c, -4504
Audio PTS = 0xf2adb633, 14400
Video PTS(P) = 0xf2af7d09, 1501
Video PTS(P) = 0xf2af8ea2, 4505
Video PTS(P) = 0xf2af947f, 1501
Video PTS(P) = 0xf2afc949, 13514
Video PTS(P) = 0xf2afcf26, 1501
Video PTS(P) = 0xf2afb1d3, -7507
Audio PTS = 0xf2adee73, 14400
Video PTS(P) = 0xf2afb7b0, 1501
Video PTS(P) = 0xf2afa618, -4504
Video PTS(P) = 0xf2afabf5, 1501
Video PTS(P) = 0xf2afbd8e, 4505
Video PTS(P) = 0xf2afc36b, 1501
Video PTS(P) = 0xf2aff835, 13514
Audio PTS = 0xf2ae26b3, 14400
Video PTS(P) = 0xf2affe12, 1501
Video PTS(P) = 0xf2afe0bf, -7507
Video PTS(P) = 0xf2afe69c, 1501
Video PTS(P) = 0xf2afd504, -4504
Video PTS(P) = 0xf2afdae1, 1501
Video PTS(P) = 0xf2afec7a, 4505
Video PTS(P) = 0xf2aff257, 1501
Video PTS(P) = 0xf2b02721, 13514
Audio PTS = 0xf2ae5ef3, 14400
Video PTS(P) = 0xf2b02cfe, 1501
Video PTS(P) = 0xf2b00fab, -7507
Audio PTS = 0xf2ae9733, 14400
Video PTS(P) = 0xf2b01588, 1501
Video PTS(P) = 0xf2b003f0, -4504
Video PTS(P) = 0xf2b009cd, 1501
Video PTS(P) = 0xf2b01b66, 4505
Audio PTS = 0xf2aecf73, 14400
Video PTS(P) = 0xf2b02143, 1501
Video PTS(P) = 0xf2b0560d, 13514
Video PTS(P) = 0xf2b05bea, 1501
Video PTS(P) = 0xf2b03e97, -7507
Audio PTS = 0xf2af07b3, 14400
Video PTS(P) = 0xf2b04474, 1501
Video PTS(P) = 0xf2b032dc, -4504
Video PTS(P) = 0xf2b038b9, 1501
Video PTS(P) = 0xf2b04a52, 4505
Video PTS(P) = 0xf2b0502f, 1501
Video PTS(P) = 0xf2b084f9, 13514
Video PTS(P) = 0xf2b08ad6, 1501
Audio PTS = 0xf2af3ff3, 14400
First Audio PTS = 0xf2af34b3, -2002
Video PTS(P) = 0xf2b06d83, -7507
Video PTS(P) = 0xf2b07360, 1501
Video PTS(P) = 0xf2b061c8, -4504
Video PTS(P) = 0xf2b067a5, 1501
Video PTS(P) = 0xf2b0793e, 4505
Video PTS(P) = 0xf2b07f1b, 1501
Video PTS(P) = 0xf2b0b3e5, 13514
Video PTS(P) = 0xf2b0b9c2, 1501
Video PTS(P) = 0xf2b09c6f, -7507
Video PTS(P) = 0xf2b0a24c, 1501
Video PTS(P) = 0xf2b090b4, -4504
Video PTS(P) = 0xf2b09691, 1501
Audio PTS = 0xf2af7833, 14400
Video PTS(P) = 0xf2b0a82a, 4505
Video PTS(P) = 0xf2b0ae07, 1501
Video PTS(P) = 0xf2b0e2d1, 13514
ts rate = 13237088
packets for pid 0 <0x0000> = 76, first = 294, last = 15820
packets for pid 16 <0x0010> = 76, first = 295, last = 15821
packets for pid 4386 <0x1122> = 15050, first = 1, last = 15926
packets for pid 4387 <0x1123> = 724, first = 23, last = 15909
coded frames = 0, video fields = 0

Are there any tools to cut based on PTS values? I experimented with modifying the xport code to do this and had some success.

Any pointers on how to edit this file? I feel like I'm so close to a perfect edit.

DreckSoft
18th June 2007, 19:17
@crypto: Is it possible that AVC2AVI has problems with newer PremiereHD Streams? There is no keyframe in the entire end credits when watching the avi. That's a bit strange, I don't think Premiere would transmit several minutes without a keyframe.

crypto
19th June 2007, 07:00
@DreckSoft
Yes, there might be changes in the bitsteam. They have (probably) switched to the new Tandberg EN8090 encoder. I will check that. No key frames over such a long period are not possible. There seems to be a problem with the detection.

DreckSoft
29th June 2007, 12:35
I did some more testing.

First I thought there might be a problem with the detection of high profile. So i changed line 632 to
h->b_key = (nal->i_type == NAL_SLICE_IDR || (nal->i_type == NAL_SLICE));
(below //fix: key flags in high profile)

Now I get a lot more keyframes (they seem to be correct) but now I encounter a different problem I recently observed with BBCHD (High School Musical).

The resulting avi has a lot of distorted frames in VDub and the Video length doesn't match. Meaning if I use the raw 264 and the audio and mux it directly into MKV audio is sync. When muxing into AVI it isn't.

Theory: There's a problem with handling the high profile.

dukey
5th July 2007, 20:52
I cant get this xport program to work
Got some h264 .ts streams

doing this

C:\AltDvb\Records>xport "20070624_2000 BBC HD.TS" 1 1 1
xport Transport Stream Demuxer 0.96
program = 1, video channel = 1, audio channel = 1
Program Number = 0 (0x0000), Program Map PID = 16 (0x0010)
Program Number = 6903 (0x1af7), Program Map PID = 256 (0x0100)
Program Number = 6904 (0x1af8), Program Map PID = 257 (0x0101)
Program Number = 6940 (0x1b1c), Program Map PID = 258 (0x0102)
Program Number = 6945 (0x1b21), Program Map PID = 259 (0x0103)

packets for pid 0 <0x0000> = 2607, first = 71, last = 2917509
packets for pid 258 <0x0102> = 5212, first = 632, last = 2917088
packets for pid 2318 <0x090e> = 2836596, first = 1, last = 2917719
packets for pid 2319 <0x090f> = 73304, first = 27, last = 2917705
coded frames = 0, video fields = 0

But i just get 2 empty files
one called
bits0001.mpa
bits0001.mpv

The audio in the file is AC3 though not mpa

Hunstad
6th July 2007, 19:58
Dukey, have you read the xport readme.txt

The output files are always named bits0001.mpv for video and bits0001.mpa for audio
(note that bits0001.mpa can be an AC-3 file).

and

Usage is:

xport <-pavtdszgh> <infile> <program number> <video stream number> <audio stream number>

Try
xport "20070624_2000 BBC HD.TS" 6940 1 1

dukey
7th July 2007, 03:58
many thanks

hms
20th July 2007, 00:04
I have tried using mencoder but could not solve video/audio sync problem:
Now I am trying xport and I got the video and audio demuxed:
But what do I do now?
I know what to do with the audio file but the video file is strange to me:
I would love to mux to a compliant mp4 file...


C:\xport>xport c:\test.ts 1 1 1
xport Transport Stream Demuxer 0.96
program = 1, video channel = 1, audio channel = 1
Program Number = 1 (0x0001), Program Map PID = 32 (0x0020)
Video PID = 5154 <0x1422>, type = 0x1b
Audio PID = 5155 <0x1423>, type = 0x81
1 frames before first I-frame
Main Profile
Level = 4.0
First Video PTS = 0xb6af099e
Audio Bitrate = 384000, Audio Sampling Rate = 48000
Audio Mode = 3/2, bsid = 8, bsmod = 0
First Audio PTS = 0xb6af09d5, 55
ts rate = 11083808
packets for pid 0 <0x0000> = 1, first = 1, last = 1
packets for pid 32 <0x0020> = 1, first = 2, last = 2
packets for pid 5154 <0x1422> = 131232, first = 3, last = 137400
packets for pid 5155 <0x1423> = 6166, first = 11, last = 137373
coded frames = 0, video fields = 0

DreckSoft
22nd July 2007, 16:15
I'm really out of options now. Currently nothing works with Premiere HD streams. I've created a new thread here:
http://forum.doom9.org/showthread.php?p=1026733

Hope someone has an idea.

georgekellerman
3rd August 2007, 00:55
I have a BBCHD problem with xport V0.96: When demuxing the BBCHD TS-file, the raw AVC video is fully there, but the audio file has 0kB. Other recordings, like Astra HD or Pro7, all work fine (video and audio). Is the BBCHD audio different? Why is that? Xport is such a great program, is there a solution to this?

drmpeg
3rd August 2007, 02:14
I have a BBCHD problem with xport V0.96: When demuxing the BBCHD TS-file, the raw AVC video is fully there, but the audio file has 0kB. Other recordings, like Astra HD or Pro7, all work fine (video and audio). Is the BBCHD audio different? Why is that? Xport is such a great program, is there a solution to this?
If you could upload a sample (10 megabytes or so) somewhere, I'd be happy to take a look at it.

Ron

georgekellerman
3rd August 2007, 03:57
Thanks so much for the offer. Please read my PM. :)

drmpeg
3rd August 2007, 05:41
Here's the fix:

http://www.w6rz.net/xport.zip

Make sure you clear your cache to get the latest file (files in the .zip should be dated 8/2/2007).

As it turns out, I had already looked at this problem. It has to do with the BBC putting AC-3 audio into MPEG-1 audio PES packets.

BTW, the correct command line for the sample is:

xport bbc_apr_2007.ts 6940 1 3

You have to chose audio track 3 to get to the correct audio PID.

Ron

georgekellerman
3rd August 2007, 10:56
Omg. I can't believe it. Thank you so much for this unbelievably fast fix. And also for the correct command line. :)

xport forever!

Atak_Snajpera
7th September 2007, 00:31
How to demux only audio with xport?

drmpeg
7th September 2007, 03:02
How to demux only audio with xport?
I've updated xport to version 0.98 for audio only demuxing.

http://www.w6rz.net/xport.zip

Audio only demuxing is accomplished by setting the video channel to zero. Like so:

xport clip.ts 1 0 1

Ron

Atak_Snajpera
7th September 2007, 22:37
It would be very useful if xport v1.00 could automatically demux first available video and audio stream or even everything at once.

Anyway thanks for update so quickly:)

mverta
19th September 2007, 04:31
I need to convert .ts to another format, too - actually eventually I need a progressive frame sequence, like .png's or .tga's...

But first, since I don't need it to play back, I don't need to edit it, and I don't need its audio... I just need the simplest, highest-quality transcoding from the .ts files to something I can work with, what's the best option for me? I want to stay as close to the source as possible...

Thanks,

_Mike

lcld
20th September 2007, 16:51
drmpeg, many thanks for xport! At last a tool that does properly what advertised.

I've spent hours to find a way to remux (possibly damaged) ts/avc/aac streams into matroska, and tried countless combinations involving vlc, mencoder, direct show and other free/proprietary tools.

Comments about a few tools :

I hate mplayer. This is just a big bugware. By the way, "mencoder.exe -of rawaudio -ovc copy -oac copy" doesn't work ("Too many audio packets in the buffer").

VLC is slightly better. If you want to create unreadable files, it is a perfect tool. I use it to extract the audio track, into a mp4 container :
vlc --sout "#std{access=file,mux=mp4,dst=audio.mp4}" --no-sout-video -I dummy input.ts

MP4Box. Ahem, how is it possible this tool is unable to mux a raw AVC stream properly ?? It marks all frames as key frames (it indexes them all) instead of I frames only :
Lot of waste space. Once remuxed into mkv, we get a huge cue section.
If you seek the video, the player displays anything until it encounters an I frame.
Difficult to cut the video at key frames after that.
If there an option, tell me. I didn't find one.

The Haali DS filters stops remuxing at 1000 frames. No idea why.

xport :

I use xport to extract elementary streams. mkvmerge accepts them :)

I have a feature request though : please add support for AAC.
In fact, I hope xport handles damaged streams properly and ensures extracted streams are kept synced.

It seems to work under Linux i386. I'll do more tests.

$ gcc -Wall xport.c
xport.c: In function ‘parse_mpeg2_video’:
xport.c:1095: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
xport.c:1096: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
xport.c:1175: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
xport.c:1372: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
xport.c: In function ‘parse_h264_video’:
xport.c:1506: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
xport.c:1506: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’
xport.c:1400: warning: unused variable ‘first’
xport.c: In function ‘parse_vc1_video’:
xport.c:1883: warning: format ‘%.3f’ expects type ‘double’, but argument 2 has type ‘long double’
xport.c:1931: warning: format ‘%.3f’ expects type ‘double’, but argument 2 has type ‘long double’
hmmm... It may bug on 64 bits arch.

bob0r
20th September 2007, 22:09
...

The Haali DS filters stops remuxing at 1000 frames. No idea why.

...

What version?

lcld
20th September 2007, 22:22
The last one: 1.7.189.11

The bug is the same with graphedit and gdsmux. A fraction of second after having started the process, it stops remuxing. It simply becomes idle and if I look at the destination directory, the output file doesn't exist. When I close the application, the file appears and is playable : 1000 frames / 40 seconds / ~ 6 MB.

I tried several input files.

drmpeg
21st September 2007, 01:48
drmpeg, many thanks for xport! At last a tool that does properly what advertised.

xport :

I use xport to extract elementary streams. mkvmerge accepts them :)

I have a feature request though : please add support for AAC.
In fact, I hope xport handles damaged streams properly and ensures extracted streams are kept synced.

It seems to work under Linux i386. I'll do more tests.

$ gcc -Wall xport.c
xport.c: In function ‘parse_mpeg2_video’:
xport.c:1095: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
xport.c:1096: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
xport.c:1175: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
xport.c:1372: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
xport.c: In function ‘parse_h264_video’:
xport.c:1506: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
xport.c:1506: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’
xport.c:1400: warning: unused variable ‘first’
xport.c: In function ‘parse_vc1_video’:
xport.c:1883: warning: format ‘%.3f’ expects type ‘double’, but argument 2 has type ‘long double’
xport.c:1931: warning: format ‘%.3f’ expects type ‘double’, but argument 2 has type ‘long double’
hmmm... It may bug on 64 bits arch.
The use of "long" is pretty superfluous in xport. You should be able to change all "unsigned long" variables to "unsigned int" and all "long double" variables to "double". However, "long long" variables are there for a reason (for 33-bit PTS values), so don't change them.

xport doesn't have a specific algorithm to keep the output files in sync (other than at the very beginning).

AAC is definitely doable. If you could post a short test stream somewhere, I can add AAC demuxing.

Ron

lcld
21st September 2007, 14:03
Here is an undamaged one: http://alainmuchembled.free.fr/Doom9/avc-aac.ts (100s / 20MB)

This is also testcase for other apps :
when remuxed to mp4 with vlc : the image is truncated (96px width) and the audio is garbage
too long for Haali : it stops at 40s
Haali doesn't see any audio track

Thunderbolt8
22nd September 2007, 10:14
The last one: 1.7.189.11

The bug is the same with graphedit and gdsmux. A fraction of second after having started the process, it stops remuxing. It simply becomes idle and if I look at the destination directory, the output file doesn't exist. When I close the application, the file appears and is playable : 1000 frames / 40 seconds / ~ 6 MB.

I tried several input files.
I recently had a similar problem. I had a hddvd with vc-1 codec remuxed into .ts and files were presplitted.
I wanted to change container to .mkv then, so I joined the .ts files together with tsremux, but gdsmux was unable to remux the vc-1 .ts into .mkv, it just went idle after 0,6%. cpu and hdd just stopped working, but the program didnt end or crash nor was any error message given. the output file was ~3-7mb of size and playback was possible with mpc.

drmpeg
24th September 2007, 05:40
Here is an undamaged one: http://alainmuchembled.free.fr/Doom9/avc-aac.ts (100s / 20MB)

This is also testcase for other apps :
when remuxed to mp4 with vlc : the image is truncated (96px width) and the audio is garbage
too long for Haali : it stops at 40s
Haali doesn't see any audio track
Just wanted to let you know that I downloaded the clip and I'm working on it. Unfortunately, I don't have the correct MPEG-4 specifications to completely decipher the AAC format contained in this bitstream.

The AAC bitstream appears to be SL-packetized since the PES header is 0x00, 0x00, 0x01, 0xfa, but the stream_id of 0x11 suggests ISO/IEC 14496-3 Audio with the LATM transport syntax as defined in ISO/IEC 14496-3 / AMD 1.

I need find a copy of both ISO/IEC 14496-1 and ISO/IEC 14496-3 and do some research, so stay tuned.

Ron

Lulle
21st October 2007, 08:46
Where can I find xport? I cant find it @ the webb.

I need to find the delay to my video/audio file so I can sync it right.

Can I do it with xport? or shod I use some other app?

drmpeg
21st October 2007, 12:01
Where can I find xport? I cant find it @ the web.

I need to find the delay to my video/audio file so I can sync it right.

Can I do it with xport? or should I use some other app?
It is here:

http://www.w6rz.net/xport.zip

It will cut the audio to match the first valid frame of video. That is, the delay will be near zero.

BTW, for lcld, the current version of xport (0.98a) will demux AAC audio. However, I'm not sure if the raw AAC will be useful for you.

Ron

Lulle
21st October 2007, 16:50
It is here:

http://www.w6rz.net/xport.zip

It will cut the audio to match the first valid frame of video. That is, the delay will be near zero.

BTW, for lcld, the current version of xport (0.98a) will demux AAC audio. However, I'm not sure if the raw AAC will be useful for you.

Ron

Okej nice, I live in .eu. So we got h.264 AVC hdtv here.

I just want the sync numbers to the audio.

I have converted it to .avi but I cant get the audio to sync without the delay numbers.

How do I type in xpot to just se the delay numbers?

lcld
21st October 2007, 17:47
How do I type in xpot to just se the delay numbers?Read post #68 (http://forum.doom9.org/showthread.php?p=931340#post931340).
BTW, for lcld, the current version of xport (0.98a) will demux AAC audio. However, I'm not sure if the raw AAC will be useful for you.Indeed :(
xport-0.98a does (almost) the same thing as 'mplayer -dumpaudio' and I don't know what to do with raw AAC.

Lulle
21st October 2007, 18:56
Read post #68 (http://forum.doom9.org/showthread.php?p=931340#post931340).
Indeed :(
xport-0.98a does (almost) the same thing as 'mplayer -dumpaudio' and I don't know what to do with raw AAC.


ok, but what do I write to get this up:

First Video PTS = 0x00025c1f
First Audio PTS = 0x00026bae, 1103

??

drmpeg
22nd October 2007, 01:26
Okay nice, I live in .eu. So we got h.264 AVC hdtv here.

I just want the sync numbers to the audio.

I have converted it to .avi but I cant get the audio to sync without the delay numbers.

How do I type in xport to just see the delay numbers?
I don't think xport will be useful for you. It doesn't report the delay, it removes it from the demuxed files. The numbers reported are just the residual delay left in the demuxed files.

When you convert to .avi, do you use a demuxer first, or does the conversion happen in one step?

Ron

Lulle
22nd October 2007, 07:44
I don't think xport will be useful for you. It doesn't report the delay, it removes it from the demuxed files. The numbers reported are just the residual delay left in the demuxed files.

When you convert to .avi, do you use a demuxer first, or does the conversion happen in one step?

Ron

I open the .ts file in ProjectX and take the audio file out.

Then I open the .ts file with my .avs file in vdub.
And then I convert it.

And then after that I sync the .avi file with the .ac3 file in nadube.

I dont mux it..

I have been using ptscalc2 before to get the dealy numbers, but now I get error message at all .ts files. dont know why. And I hav reinstalld it too. But still dosent work

drmpeg
23rd October 2007, 09:34
I open the .ts file in ProjectX and take the audio file out.

Then I open the .ts file with my .avs file in vdub.
And then I convert it.

And then after that I sync the .avi file with the .ac3 file in nadube.

I don't mux it..

I have been using ptscalc2 before to get the delay numbers, but now I get error message at all .ts files. don't know why. And I hav reinstalled it too. But still doesn't work
It's possible that xport might help since it could be aligning the audio to the same video frame that vdub is starting on. You should give it a try. Instead of demuxing the audio with ProjectX, use xport. The command line is:

xport clip.ts 1 1 1

The AC-3 audio will end up in a file called bits0001.mpa, which you can rename to .ac3 if you want.

If you have trouble with xport, post the output here and I'll help you out.

BTW, what's nadube? I did a search for it (both Google and here on doom9), but got nothing.

Ron

canTsTop
31st October 2007, 15:14
hello, i need some help please

i have TS (PAL) file with h264 video (PAFF) and mp2 audio

firs i demux TS with xport, then mux video to mp4 with yamb, yamb asks me fps of the video, i write 25.000. after that i create avs with FFmpegSource("myvideo.mp4"), load it with megui and analyze for deinterlacing, it says that my source is partially interlaced and it recommend to use Yadif(order=1).

then i encode that video it is longer duration than was in TS, i searched for reason for this and fount out that PAFF should be double fps (50.00 fps ?). i couldn't find solution for this problem. can anyone help me with this or point to right direction

thank you

(sorry for bad english)

LOP500
2nd December 2007, 23:57
xport SW_clip.ts 3306 1 1

xport Transport Stream Demuxer 1.00
program = 3306, video channel = 1, audio channel = 1
Program Number = 0 (0x0000), Program Map PID = 16 (0x0010)
Program Number = 1404 (0x057c), Program Map PID = 258 (0x0102)
Program Number = 3801 (0x0ed9), Program Map PID = 256 (0x0100)
Program Number = 3306 (0x0cea), Program Map PID = 257 (0x0101)
program descriptor = 0x09, 0x04, 0x0b, 0x00, 0xe0, 0x65
Video PID = 513 <0x0201>, type = 0x1b
Audio PID = 645 <0x0285>, type = 0x06
ES descriptor for stream type 0x06 = 0x0a, 0x04, 0x65, 0x6e, 0x67, 0x00
ES descriptor for stream type 0x06 = 0x6a, 0x01, 0x00
ES descriptor for stream type 0x04 = 0x0a, 0x04, 0x65, 0x6e, 0x67, 0x00
ES descriptor for stream type 0x06 = 0x59, 0x08, 0x73, 0x77, 0x65, 0x12, 0x00, 0
x01, 0x00, 0x01
ES descriptor for stream type 0x06 = 0x59, 0x08, 0x64, 0x61, 0x6e, 0x12, 0x00, 0
x01, 0x00, 0x01
ES descriptor for stream type 0x06 = 0x59, 0x08, 0x6e, 0x6f, 0x72, 0x12, 0x00, 0
x01, 0x00, 0x01
ES descriptor for stream type 0x06 = 0x59, 0x08, 0x66, 0x69, 0x6e, 0x12, 0x00, 0
x01, 0x00, 0x01
Audio Bitrate = 384000, Audio Sampling Rate = 48000
Audio Mode = 3/2, bsid = 6, bsmod = 0
8 frames before first I-frame
High Profile
Level = 4.0
First Video PTS = 0xac4c788c
First Audio PTS = 0xac4c73b0, -1244
ts rate = 19996888
packets for pid 0 <0x0000> = 44, first = 2467, last = 120545
packets for pid 257 <0x0101> = 43, first = 310, last = 119492
packets for pid 513 <0x0201> = 117810, first = 1, last = 121868
packets for pid 604 <0x025c> = 45, first = 60193, last = 69854
packets for pid 605 <0x025d> = 54, first = 59317, last = 70310
packets for pid 606 <0x025e> = 56, first = 59135, last = 70324
packets for pid 607 <0x025f> = 57, first = 59151, last = 70336
packets for pid 644 <0x0284> = 1513, first = 14, last = 121830
packets for pid 645 <0x0285> = 2246, first = 2980, last = 121863
coded pictures = 210, video fields = 0

When testing with BSPlayer, the sound seems to be right( 7 seconds long). The problem is the video. Video seems to last longer than it should(=29 seconds)

The clip is 7 seconds long. It can be found here. (http://koti.mbnet.fi/lop/video/SW_clip.ts)

Thanks already.

drmpeg
3rd December 2007, 14:56
xport SW_clip.ts 3306 1 1

xport Transport Stream Demuxer 1.00

8 frames before first I-frame

coded pictures = 210, video fields = 0

When testing with BSPlayer, the sound seems to be right (7 seconds long). The problem is the video. Video seems to last longer than it should(=29 seconds)

Thanks already.
It's not an xport problem. xport is reporting 210 coded pictures (actually, there's 210 - 8 coded pictures in the demuxed elementary stream since xport discards the frames before the first I-frame). This is an MBAFF stream at 25 fps, so 202 / 25 = 8.08 seconds (there's always a little more video in a demuxed Transport Stream due to T-STD buffer requirements).

Ron

LOP500
3rd December 2007, 17:33
It's not an xport problem. xport is reporting 210 coded pictures (actually, there's 210 - 8 coded pictures in the demuxed elementary stream since xport discards the frames before the first I-frame). This is an MBAFF stream at 25 fps, so 202 / 25 = 8.08 seconds (there's always a little more video in a demuxed Transport Stream due to T-STD buffer requirements).

Ron

So in this case video should be 29 seconds and audio 7 seconds? Sounds very odd. I thought that audio and video should be same length after demux if I'm going to proceed to the next step. :)

I tried xport before with Mpeg2 HD clip. Both audio and video was same length after the demux. Now I only have h264 material and it would be nice to demux these also with xport.

So is there any way to fix my "problem"?

drmpeg
3rd December 2007, 17:48
So in this case video should be 29 seconds and audio 7 seconds? Sounds very odd. I thought that audio and video should be same length after demux if I'm going to proceed to the next step. :)

I tried xport before with Mpeg2 HD clip. Both audio and video was same length after the demux. Now I only have h264 material and it would be nice to demux these also with xport.

So is there any way to fix my "problem"?
I think you misunderstood my post. There is only 8.08 seconds of video in that clip. If there's a problem, it's with BSPlayer.

Ron

LOP500
3rd December 2007, 18:08
I think you misunderstood my post. There is only 8.08 seconds of video in that clip. If there's a problem, it's with BSPlayer.

Ron

Okay, my bad. I'll try to test it with some different software.

EDIT:
Yep, 29 seconds according to windows media player too but the video stops actually after 7 seconds. I guess there's a codec or something making these 22 fake seconds.

Strange that when opening xport demuxed file in Gordian Knot, it still shows these empty frames in the end of file.

EDIT2: Hmmmz, it's impossible to encode to another format because of these empty frames in the end. Maybe I should try to delete(=cut) the empty part.

drmpeg, which software do you use to play/handle mpv files?