View Full Version : Some tools for Ogg Media files
Suiryc
4th September 2002, 17:51
Hi
For those who are interested, I tried to make a command line multiplexer for ogm files (see attachment).
It should work with AVI (video stream only), Ogg/Ogm, AC3 and SRT subtitle files as input.
I also included a tool to extract information from an Ogg/Ogm file.
Be aware that thoses tools aren't perfect (far from it), so USE AT YOUR OWN RISK!
NB :
- you need the ogg.dll and vorbis.dll files (installed by OggDS filter I think) for the tools to work
- these programs are inspired (not based) by ogmtools (developped by Moritz Bunkus)
- these programs don't use DirectShow
Attachment removed. See posts below to find the latest versions of those tools :)
Koepi
4th September 2002, 17:55
Great job, I hope the tools work as expected.
Any plans to make them opensource later on?
I'd like to add that to the oggmux sourceforge project, making it a real OGM suite there...
Thanks for your work,
best regards,
Koepi
Suiryc
5th September 2002, 09:53
Great job, I hope the tools work as expected.
Me too :).
One more thing : compared to OggMux one cannot specify user comments (i.e. language of audio or subtitle, nor chapters), nor make the output file splitted.
Any plans to make them opensource later on?
Yes of course, just need to be sure this works, and clean up a little the source code ;)
Now, new day, new tool : the Demuxer :) (see attached file)
You should be able able to demux known stream type, i.e. :
- video stream -> AVI file (be aware there may be problems with files larger than 2GB)
- vorbis stream -> Ogg file
- AC3 stream -> AC3 file
- Subtitle stream -> SRT subtitle file
NB :
- again "USE AT YOUR OWN RISK"
- again needing ogg.dll
- again inspired by Moritz Bunkus ogmtools
- again not using DirectShow
Attachment removed, see posts below to find the tool :)
Dark-Cracker
5th September 2002, 16:06
hi,
very nice work :) but if i can suggest u could try to make an oggcut tool because a lot of people (especialy under win2k) have reported a crash with the tobias tool (oggcut) .
bye
Taranli Maren
5th September 2002, 19:20
Thank you very much. This is going to be quite useful, though I have had a problem with the ogm demuxer. It said "Video stream Packet contains more than one Frame, skipped." And the avi ends up smaller than its supposed to be. It plays, but only if I skip to the second keyframe, it crashes when I try to play the first keyframe. The two ogg files also ended up smaller than they were before, but they played perfectly. The srt was good. The video was divx5 compressed if that makes a difference. The ogm was muxed originally with oggmux.
Thanks :)
Koepi
5th September 2002, 20:14
Heh, I just started coding an OggDeMux based on Tobias' filters, but I delay that again - it's so complicated to figure all these filter properties out in a program :-/
Well, maybe I find some motivation again later, but for now I'm fed up with DShow framework again ;)
Would've been nice to see the difference...
Best regards,
Koepi
Suiryc
5th September 2002, 21:20
Originally posted by Taranli Maren
It said "Video stream Packet contains more than one Frame, skipped."
Strange, I though this message should never appear (I just included it in my sources in case ...). Will see if there could be something else causing that ...
And the avi ends up smaller than its supposed to be.
I also ended up with smaller AVI files after demuxing, but VirtualDub said me there were the same number of frames, so it seems OK.
Anyway if there are problems here I cannot do anything since I completely rely on AVILib :)
This may be the fact I use AVILib which may behave differently than the encoder (VirtualDub, ...) that have been used to make the original video.
It plays, but only if I skip to the second keyframe, it crashes when I try to play the first keyframe.
This is due (I think) to the "Video stream Packet contains more than one Frame, skipped" message.
As I said this should not happen because this would mean a Packet say it contains at least two video frames, which make then impossible to know where begins the second one and the others :/
Oh yeah, could you use "OGMInfo -p -v3 -l C:\Log.txt ..." on your ogm file and send the first lines (headers and first Page containing "D Packet" from the video stream) so that I could see what is the problem with the first frames in your video stream ? :)
The two ogg files also ended up smaller than they were before, but they played perfectly.
Are you sure ? There should not be any difference (not even a single byte) before muxing and after demuxing ogg vorbis streams.
But it may be due to DirectShow ... I noticed last time that an ogm file I made using OggMux ended with a "redundant" End Of Stream page for the vorbis stream (while the stream had already ended earlier in the file) ...
The video was divx5 compressed if that makes a difference.
No this should not make a difference.
Happy to see it helps some of you :)
Taranli Maren
5th September 2002, 21:50
I may be giving you too much here, but better safe than sorry...
0, 1V Page 0 ( 0) 28+ 57 bytes, (INITPAGE, !CONTINUED), pos 0, 0.00-> 0.00ms SYNC, 1 packet(s)
0, 1V H Video Header : DX50, 640x480, 23.976 fps
0, 1V H Packet 0 : 57 bytes, , BOS, !EOS, pos 0
1, 1v Page 0 ( 0) 28+ 30 bytes, (INITPAGE, !CONTINUED), pos 0, 0.00-> 0.00ms SYNC, 1 packet(s)
1, 1v H Vorbis Header : 91200 bps, 2 channels, 48000 Hz
1, 1v H Packet 0 : 30 bytes, , BOS, !EOS, pos 0
2, 2v Page 0 ( 0) 28+ 30 bytes, (INITPAGE, !CONTINUED), pos 0, 0.00-> 0.00ms SYNC, 1 packet(s)
2, 2v H Vorbis Header : 91200 bps, 2 channels, 48000 Hz
2, 2v H Packet 0 : 30 bytes, , BOS, !EOS, pos 0
3, 1T Page 0 ( 0) 28+ 57 bytes, (INITPAGE, !CONTINUED), pos 0, 0.00ms-> SYNC, 1 packet(s)
3, 1T H Text Header
3, 1T H Packet 0 : 57 bytes, , BOS, !EOS, pos 0
4, 2T Page 0 ( 0) 28+ 57 bytes, (INITPAGE, !CONTINUED), pos 0, 0.00ms-> SYNC, 1 packet(s)
4, 2T H Text Header
4, 2T H Packet 0 : 57 bytes, , BOS, !EOS, pos 0
0, 1V Page 1 ( 0) 28+ 48 bytes, ( ...... , !CONTINUED), pos 0, 0.00-> 0.00ms SYNC, 1 packet(s)
0, 1V C Packet 1 : 48 bytes, , !BOS, !EOS, pos 0, Comment Packet
Vendor : Xiphophorus libVorbis I 20011217
1, 1v Page 1 ( 0) 28+ 68 bytes, ( ...... , !CONTINUED), pos 0, 0.00-> 0.00ms SYNC, 1 packet(s)
1, 1v v Packet 1 : 68 bytes, , !BOS, !EOS, pos 0
2, 2v Page 1 ( 0) 28+ 69 bytes, ( ...... , !CONTINUED), pos 0, 0.00-> 0.00ms SYNC, 1 packet(s)
2, 2v v Packet 1 : 69 bytes, , !BOS, !EOS, pos 0
3, 1T Page 1 ( 0) 28+ 68 bytes, ( ...... , !CONTINUED), pos 0, 0.00ms-> SYNC, 1 packet(s)
3, 1T C Packet 1 : 68 bytes, , !BOS, !EOS, pos 0, Comment Packet
Vendor : Xiphophorus libVorbis I 20011217
Comment 1 : LANGUAGE=English
4, 2T Page 1 ( 0) 28+ 68 bytes, ( ...... , !CONTINUED), pos 0, 0.00ms-> SYNC, 1 packet(s)
4, 2T C Packet 1 : 68 bytes, , !BOS, !EOS, pos 0, Comment Packet
Vendor : Xiphophorus libVorbis I 20011217
Comment 1 : LANGUAGE=English
0, 1V Page 2 ( 0) 44+ 4335 bytes, ( ...... , !CONTINUED), pos 0, 0.00-> 0.00ms SYNC, 0 packet(s)
1, 1v Page 2 ( 0) 42+ 3606 bytes, ( ...... , !CONTINUED), pos 0, 0.00-> 0.00ms SYNC, 1 packet(s)
1, 1v v Packet 2 : 3606 bytes, , !BOS, !EOS, pos 0
2, 2v Page 2 ( 0) 42+ 3606 bytes, ( ...... , !CONTINUED), pos 0, 0.00-> 0.00ms SYNC, 1 packet(s)
2, 2v v Packet 2 : 3606 bytes, , !BOS, !EOS, pos 0
3, 1T Page 2 ( 0) 28+ 5 bytes, ( ...... , !CONTINUED), pos 0, 0.00ms-> SYNC, 1 packet(s)
3, 1T D Packet 2 : 5 bytes, SYNCPOINT, !BOS, !EOS, pos 0, 0.00-> 7087.00ms, 7087 samples
4, 2T Page 2 ( 0) 28+ 5 bytes, ( ...... , !CONTINUED), pos 0, 0.00ms-> SYNC, 1 packet(s)
4, 2T D Packet 2 : 5 bytes, SYNCPOINT, !BOS, !EOS, pos 0, 0.00-> 7087.00ms, 7087 samples
0, 1V Page 3 ( 0) 44+ 4335 bytes, ( ...... , CONTINUED), pos 0, 0.00-> 0.00ms SYNC, 0 packet(s)
0, 1V Page 4 ( 0) 44+ 4283 bytes, ( ...... , CONTINUED), pos 0, 0.00-> 0.00ms SYNC, 1 packet(s)
0, 1V D Packet 2 : 9638 bytes, SYNCPOINT, !BOS, !EOS, pos 0, 0.00-> 83.42ms, 2 samples
0, 1V Page 5 ( 0) 44+ 4224 bytes, ( ...... , CONTINUED), pos 3, 0.00-> 125.12ms SYNC, 2 packet(s)
0, 1V D Packet 3 : 5278 bytes, !SYNCPOINT, !BOS, !EOS, pos -1, 0.00-> 41.71ms, 0 samples
0, 1V D Packet 4 : 731 bytes, !SYNCPOINT, !BOS, !EOS, pos 3, 41.71-> 83.42ms, 0 samples
1, 1v Page 3 ( 0) 50+ 4131 bytes, ( ...... , !CONTINUED), pos 22080, 0.00-> 460.00ms SYNC, 23 packet(s)
1, 1v v Packet 3 : 12 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 4 : 112 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 5 : 176 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 6 : 187 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 7 : 195 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 8 : 188 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 9 : 186 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 10 : 186 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 11 : 188 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 12 : 180 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 13 : 198 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 14 : 193 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 15 : 176 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 16 : 191 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 17 : 194 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 18 : 197 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 19 : 198 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 20 : 183 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 21 : 194 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 22 : 196 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 23 : 201 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 24 : 190 bytes, , !BOS, !EOS, pos -1
1, 1v v Packet 25 : 210 bytes, , !BOS, !EOS, pos 22080
Suiryc
5th September 2002, 22:40
Thanks.
Originally posted by Taranli Maren
I may be giving you too much here, but better safe than sorry...
...
0, 1V D Packet 2 : 9638 bytes, ... 0.00-> 83.42ms, 2 samples
...
So here is the problem. I wonder how the decompressor can handle this (I mean if what say the ogm file is correct and there are realy 2 frames).
I can't do anything here, except giving this "new" version of the demuxer (it won't skip the data but send it to AVILib as if it where one frame, and warn you that there were n frames in a packet, so don't know what this will give). Please try and tell if this solve the first frame problem.
PS : when the attachement is validated, I will remove the previous one.
Attachment removed. See posts below to find the latest version of the tool :)
Selur
6th September 2002, 08:20
thx, for the tool !!
and like "Dark- Cracker" mentioned a oggCut tool would really be appreciated (especially if it can handle 2GB+ ogm files), but no hurry it's just a thing I'd like to have mentioned,..
Cu Selur
alky
6th September 2002, 19:25
do you have a little html page or something i could look for new versions?
Suiryc
6th September 2002, 20:23
Sorry, don't have a HTML page.
I only posted those tools here, and I will let you know when I make some changes.
Taranli Maren
8th September 2002, 00:43
Sorry it took me so long to get back to this. That new version works. The avi plays properly, though the filesize is still different, thats not a problem. Thanks :)
Mosu
11th September 2002, 12:14
It's always good to see that one's source code is useful to others :)
Suiryc
12th September 2002, 09:35
@Taranli Maren :
I finally found what was the problem with your video :). It is due to dropped frames.
When you have dropped frames in your video, say 1 good frame and then 4 dropped ones, then the OGM (obtained with the DirectShow Ogg Multiplexer) will have a Packet that say to contain 5 samples.
Here you are lucky because you have only one dropped frame, and since I didn't know what happens with dropped frames, in fact my Demuxer acts like it throw away them (so the final AVI clip is shortened by the number of dropped frames you have in your video).
@Mosu :
Hi, your tools was a great help at the beginning because I wanted to see if it was possible to mux "manually" streams to OGM :).
Before I publish my sources, I can however tell you about a problem I encountered while rewriting the whole thing (well in fact I didn't quite understand all what was doing your source code, so I rewrote it from scratch :D ) : The granulepos correspond to the end of data and not the beginning.
Why do I tell you that? Simple : as you when I mux, at the end I decide in which order place the Pages in the file, and of course this order is defined by the timestamp of the Page, the timestamp is calculated depending on he granulepos and the samplerate. The problem : as the granulepos correspond to the end of the Page, it's the same with the timestamp, so in fact ordering Pages depending on their timestamp is not that good (I experienced severe stuttering with my first tests :( ). In my case I introduced a new variable named last_granulepos that contains the last known granulepos of the stream, and I calculate the "beginning" timestamp of a Page with that value, and of course now the video is more "stable" :).
Hope this will help you, and again thanks for your tools :).
Well I think that today I will post the latest versions of my tools, plus a cutter (well in fact it's just a splitter at the moment ...).
Expect something great ;) (I hope :D )
Mosu
12th September 2002, 10:40
Hi.
The granulepos correspond to the end of data and not the beginning.
Yes, I know, and I've already experimented with it a bit. But as a matter of fact the OggDS drivers don't do that correctly either.
Nevertheless I've just modified the relevant files (the packetizers and ogminfo, which now bases decisions about 'being out of sync' on the start time (the last page's granulepos of the current stream) rather than on it's end time). The reason I haven't done it before is that with the interleaving being slightly wrong did not give me any problems at all - neither with mplayer nor with OggDS (e.g. ZoomPlayer, WMP6).
Now it should (like 'I hope but am not sure' ;)) be ok. I'll release a new version soon (as soon as I get MP3 support working correctly...)
Suiryc
12th September 2002, 11:35
Eh eh my newest version also include MP3 support, and another format (but you will know more when I post the tools).
BTW your idea of using Reader and Packetizer was really great, but I found a thing that helped me a lot compared to what you did :
You have a Reader for each type of input file (me too), and a Packetizer for each type of stream (one for video, one for vorbis, one for PCM), but I succeeded in having only one Packetizer for everything, which is a bit more handy (I think).
The hard thing was to find how to calculate sample_rate and timestamp in each case : in fact there is one formula that apply to everything, but I found it the hard way (first by guessing it - and it was a good guess :) - and then by "verifying" it).
So compared to you what I do is fill the stream_header in the Reader, and send it to the Packetizer (which then have everything it needs to calculate timestamps).
As I didn't know that much thing about multimedia and everything, it was also hard for me to find how to correctly fill this damn stream_header :devil: , and maybe you are experiencing same things with your MP3 support :
I had the really bad idea that stream_header.samples_per_unit was related to the number of samples contained in one Frame (i.e. 1 sample - 1 frame - for video, and for example n samples for 1 Frame of MP3 - n=384 for LayerI and 1152 for LayerII/III) ... but I ended up with really bad timing at the end (I first experienced that with AC3 : there was no problem playing the file, but the indicated time was completely wrong). Finally I found that it is related to the final sample_rate (i.e. if the MP3 or AC3 is 48KHz, then samples_per_unit must be set to 48000, and so on).
Maybe this will help you (or maybe I am the only person on earth who didn't knew that :scared: ).
tiki4
12th September 2002, 14:22
Mmh, I've got a question, maybe someone of you can help me. As all of you know it has been quite a hassle to get a format like AC3 into an Ogg container. The problem seemed to be in the first place, that the muxing in Graphedit using the direct show filters didn't work out right.
Then someone had the idea to use a muxed AVI with AC3 sound and mux that stuff directly into the Ogg file. That method works but one cannot add additional soundtracks as the AC3 sound is always played.
When I saw this thread with the new command line muxer I had the idea to use the ogmuxer first on the AC3 stream to create a n Ogg file containing only the AC3 soundtrack. Then I used Koepi's program to mux an XviD AVI without sound, the Ogg containing the AC3 stream and an additional 2 channel Ogg Vorbis stream into the final OGM.
Unfortunately the playback has the same problem as before. The AC3 stream is always played and one has to use mmswitch.ax to switch between the AC3 and the Vorbis soundtrack.
When I render the file in Graphedit the output pin of the AC3 stream says something like AVIform.
Does that mean that the problem is in the OggDS implementation and there's no way to cirumvent that problem? I'd be really interested in a solution as MC Vorbis never worked the right way and the channel coupling may take some more month to get implemented.
Any ideas are welcome.
Regards,
tiki4
Suiryc
12th September 2002, 14:27
Hi,
Time for a little update :).
As the zipped file exceeded the 200K limit (213K :( ), I first used RAR (with Solid Compression) (see attachement)...
So you will have to unzip and then unrar it (sorry for that guys).
So what are the changes ?
First I added buffering to speed up a little the process (for all the tools).
I then tried to push AVILib to its (in theory) possible limits (i.e. 4GB AVI files), but I failed on that :(. So I took some extreme measures, and decided to try some routines coming from a well known tool .... VirtualDub (1.4.10).
This push my tools in a real alpha state because as you know VirtualDub is a Windows GUI application, and so behave its tools. But my tools here are commandline ones :D . So I had to "remove" some functions (those relying on the GUI part of VirtualDub), and thus I cannot guarantee you that all will work like a charm in every situation.
So more than ever : USE AT YOUR OWN RISK!
Now changes for each tools:
- OGMinfo
-> added some more info (granulepos estimation, & timestamp estimation for Vorbis streams)
- OGMuxer
-> removed the use of AVILib
-> added some reading routines coming from VirtualDub 1.4.10
-> added some functions coming from OggMux (the automatisation setup file parsing). In other words you can use your omx file with OGMuxer
-> enabled MP3 files as input
-> added another known input file type : it begins with an 'A', finish with an 'F' and have a '$' in the middle (yes you read well). As for AVI only the video stream is muxed
- OGDemuxer
-> removed the use of AVILib
-> added some writing routines coming from VirtualDub 1.4.10
And the new tool : OGMCutter (well in fact it's only a splitter at the moment).
OGMCutter should be able to cut your ogm file on (video) keyframes, choosing them depending on the split size you gave.
OGMCutter should also be able to "adjust" the comments that are in the original file (Title and Chapters) according to where it cut (see the txt file that come with OGMCutter).
So what is good in all that :
- the use of some routines coming from VirtualDub should break the 2GB limit of the previous version of the tools (I successfully muxed a 2.3GB / 3 hours AVI file into an OGM file)
BUT
- as I said VirtualDub is a GUI and I had to "cut" some parts, so maybe there will be more problems with the latest version of the tools than before
- there is also a bad news : it seems that >2GB OGM files give headaches to Windows (when I select such a file in the Explorer, then the "explorer.exe" process - i.e. the Windows' Desktop - stay forever @ 99% of CPU use and I have to "kill" it :(, and moreover when I try to read the file with WMP6.4 the video stutter and I cannot seek). Fortunately when I cut the file into 702MB there is no more problem :).
Enjoy.
Attachment removed. See posts below to find the latest versions of those tools
Suiryc
12th September 2002, 14:32
Originally posted by tiki4
The problem seemed to be in the first place, that the muxing in Graphedit using the direct show filters didn't work out right.
...
Does that mean that the problem is in the OggDS implementation and there's no way to cirumvent that problem?
There is the same problem when you mux everything with OGMuxer : the AC3 track is allways played. So I also think it's related to OggDS (but maybe there is no solution for that, who knows).
Taranli Maren
12th September 2002, 16:25
I'm confused, if the grame was dropped during encoding, then wouldn't it just be missing? so it wouldn't shorten the length of the avi my any amount. or are you saying that your demuxer is dropping the frame for some reason? This was encoded from a dvd, as opposed to video capture, so it doesn't seem like there should be any dropped frames in encode-time. (Except for the ones decimate drops as part of ivtc)
Mosu
12th September 2002, 16:39
If frames are drop during encoding the encoder may insert 'empty' frames into an AVI. For an AVI there is an index entry for this frame, but the data has zero length. For a OGM this translates into a video packet whose length header is set to the number of 'empty' frames that were present in the AVI. If there were no 'empty' frames then the length header is not present.
Now if someone wants to recreate an AVI from an OGM then he has to recreate these 'empty' entries in the AVI index aswell. Otherwise the audio/video synchronization will be of. The problem is that apparently only the video frame was dropped, but not the corresponding audio frame.
Suiryc
12th September 2002, 16:46
Originally posted by Taranli Maren
or are you saying that your demuxer is dropping the frame for some reason?
Yes, and the reason is : I didn't know at that time that dropped frames would cause that, so while processing my demuxer was telling to the AVI writer to write 1 frame (whereas it should also write a 0-length frames for each dropped one).
But the new version should handle that now.
eclipsedvd
12th September 2002, 19:09
Hi,
here is a little addon to Cyrius Tools.
Now, you can demux/cut ogm files with the right-click on the mouse
http://www.eclipsedvd.firstream.net/FILES/OGMTools_20020912.exe
Greets
ECLiPSE
Suiryc
12th September 2002, 19:34
:)
Oh BTW I forgot something with the A$F support : I forgot to reuse the code (that I uses with AVI support) for correctly handling dropped frames. Normally there should be no problem with the resulting OGM file except that demuxing it back to an AVI file could result in shortened clip (as I said before).
So if I were you I wouldn't use A$F too much for the moment (it's corrected in my sources but ATM I am trying to add audio support).
Emp3r0r
12th September 2002, 22:30
great work guys, can't wait to test the AC3 support and the >2GB file support, thanks for the tools
Belgabor
13th September 2002, 02:04
Originally posted by Suiryc
:)
Oh BTW I forgot something with the A$F support : I forgot to reuse the code (that I uses with AVI support) for correctly handling dropped frames. Normally there should be no problem with the resulting OGM file except that demuxing it back to an AVI file could result in shortened clip (as I said before).
So if I were you I wouldn't use A$F too much for the moment (it's corrected in my sources but ATM I am trying to add audio support).
while you're at it, plz add some error tolerance if possible. This could be the perfect way to rescue those f**ked up a$fs we all learned to love.
Cheers
Belgabor
sherpya
13th September 2002, 03:52
I don't known if is the right place, anyway I've made a python library
to parse and handle ogg chapter list.
It's not for newbe (sorry) but I think it's better than nothing :D
Peraps I'm currently using it.
You can download caplib.py (http://forum.doom9.it/software/other/caplib.py)
The lib is designed to be used by a small python prog:
You can open ogg chapter files
Split an ogg chapter file
Parse result from a html page donwloaded from http://www.bn.com/
(search for a title and select "From the DVD->Scene Index")
Can import titles from a list parse from html file
A simple example:
#!/usr/bin/env python
import caplib
a = caplib.Caps("lotrcaps.txt")
b = caplib.Caps("lotr.html", format='bn')
a.import_titles(b)
c,d = a.split_at("01:30:00.000")
print c
print "*" * 78
print d
Note: It's not very tested it only the first public version.
@Suiryc
It would be great to integrate your tools into virtualdub
The Link
13th September 2002, 08:36
Cool! There are other python users than me on this forum. Hope I get some time to have a look at this.
Suiryc
13th September 2002, 10:30
Originally posted by Belgabor
while you're at it, plz add some error tolerance if possible. This could be the perfect way to rescue those f**ked up a$fs we all learned to love.
:D
Well it seems there is no good way to export "special" audio format (for example WMA or DivX Audio) from A$F (or AVI) to Ogg. The Ogg file won't play the audio (saying it lacks a codec ... don't know why .... it seems to be OK with MP3 audio in AVI so either it's a "problem" with OggDS, or it's a restriction from Micro$soft that doesn't allow format other than AVI and A$F to play those kind of stream).
Well anyway I have my "VirtualDub 1.4.10 special A$F" version (I had to add some things because of this damn "VBR Audio" check) ... (hey sometimes you find really strange things in those A$F files ... like a >10MB Script Command stream that doesn't seem to do anything :rolleyes: )
Originally posted by sherpya
It would be great to integrate your tools into virtualdub
Well this is another thing ...
Belgabor
13th September 2002, 10:52
Anything with more error tolerance than the original VDub implementation floating around would be really nice :)
Cheers
Belgabor
P.S: I second sherpyas wish ;)
Suiryc
13th September 2002, 10:59
Originally posted by Belgabor
Anything with more error tolerance than the original VDub implementation floating around would be really nice :)
Cheers
Belgabor
P.S: I second sherpyas wish ;)
The VirtualDub old (i.e. Version 1.3) A$F support doesn't have error tolerance ? (I just took the code, modified some things, added others so that it was "up-to-date" with version 1.4.10)
TobiasWaldvogel
13th September 2002, 13:18
Streams which are created with my DirectShow filters MAY contain more than one frame per packet. I just take the frames that I get from the preceeding filter (in most cases the AVI splitter) and store them in the stream with the corresponding timestamps. It seems that the AVI splitter sometimes sends more than 1 frames at a time . Thats's all. In Windows there the MPEG4 decoders accept more than one frame per packet. Currently I don't know how to seperate them. Any ideas are welcome.
Kind regards,
Tobias
Suiryc
13th September 2002, 15:52
Originally posted by TobiasWaldvogel
Streams which are created with my DirectShow filters MAY contain more than one frame per packet. I just take the frames that I get from the preceeding filter (in most cases the AVI splitter) and store them in the stream with the corresponding timestamps. It seems that the AVI splitter sometimes sends more than 1 frames at a time . Thats's all. In Windows there the MPEG4 decoders accept more than one frame per packet. Currently I don't know how to seperate them. Any ideas are welcome.
The only case where I saw more than one frame in a Packet (with your DirectShow filter) was due to dropped frames. So in fact there wasn't really various frames in the Packet, just the (first) good one. As DirectShow still give good timestamps (because it takes care of the dropped frames), there is no problem (I mean while playing the OGM file times are still good).
So I don't think there is need to separate them (since in that case it's impossible because there is in reality only one frame)
IMO DirectShow won't send more than one frame at a time to your filter (it would be crazy to do so because that would mean each filter involved in video processing under DirectShow should have the ability to separate adjacent frames whatever is the format of the frame : uncompressed, Indeo, DivX 3.11, DivX 4, DivX 5, XviD, and so on ...).
Now my commanline muxer acts like your DirectShow filter concerning dropped frames in the AVI source file.
There is however one thing you may know : with an AVI file that had at the very beginning one good frame and 4 bad ones, the first video Page (with data) had a granulepos of 0 with your DirectShow filter (the way I do it with my muxer the granulepos would have been 4, i.e. the granulepos of the last data in the Packet).
But this doesn't seem to be a problem while decoding (well in fact I cannot really tell because of the dropped frames that make the video like "stuttering").
Then a question concerning the subtitle stream : why having choosed the beginning of the Page for granulepos and not the end (as described in the Ogg secification) ?
And while I am at it (I know I may ask too much things at a time :) ), I have one question concerning the way your DirectShow filter give audio streams to the next filters : the type of audio is based on the stream_header.subtype field, isn't it ? (so if I have "0161" in the subtype field, your filter tells that the audio format - I think of the wFormatTag field in WAVEFORMAT or WAVEFORMATEX structure here - is 0x0161 ?)
This would help me knowing if the fact that my OGM file containing a video stream and a WMA (or DivX Audio) stream won't play the audio (saying it lacks codec whereas the codec is here) is related to your filter or (more likely) to a restriction of Micro$oft in their filters.
Thanks.
TobiasWaldvogel
13th September 2002, 19:08
Originally posted by Suiryc
Then a question concerning the subtitle stream : why having choosed the beginning of the Page for granulepos and not the end (as described in the Ogg secification) ?
I don't set the page granulepos. I just set the packet granulepos and the ogg library sets the page position accordingly. Therefore the page granulepos is always the first position of the last complete packet in a page. This applies also to vorbis packets. The page granulepos is never set manually.
And while I am at it (I know I may ask too much things at a time :) , I have one question concerning the way your DirectShow filter give audio streams to the next filters : the type of audio is based on the stream_header.subtype field, isn't it ? (so if I have "0161" in the subtype field, your filter tells that the audio format - I think of the wFormatTag field in WAVEFORMAT or WAVEFORMATEX structure here - is 0x0161 ?)
This would help me knowing if the fact that my OGM file containing a video stream and a WMA (or DivX Audio) stream won't play the audio (saying it lacks codec whereas the codec is here) is related to your filter or (more likely) to a restriction of Micro$oft in their filters.
You are right, for other audio format (not vorbis) I use a waveformatex structure for pbFormat and subtype contains the wFormatTag field. 0x0161 is WindowsMedia but it seems that the WMA decoder ONLY connects to the AFS reader. If you try to connect it to an AVI or WAV containing audio with ID 0x0161 it happens the same. It seems that Microsoft wants to limit the use of Windows Media to ASF/WMA
Suiryc
13th September 2002, 20:20
Originally posted by TobiasWaldvogel
I don't set the page granulepos. I just set the packet granulepos and the ogg library sets the page position accordingly. Therefore the page granulepos is always the first position of the last complete packet in a page. This applies also to vorbis packets. The page granulepos is never set manually.
Sorry for having said it like that because in fact I know that (I talked of Page because in the case of subtitle streams there is only one Packet in a Page, which means Packet granulepos = Page granulepos - and of course even I don't set the Page granulepos manually, the ogg library is kind enough to do that :) ).
In fact I was wondering if I were misunderstanding the Ogg specification or the way subtitle streams are described :
Page's granulepos is described as the granular position of the last fully decodable data of the Page ("The position specified is the total samples encoded after including all packets finished on this page" is what is said). And for Packet containing text data, it is said that "lenbytes" (that represents the number of samples in the Packet) is expressed in ms.
So when the first Page/Packet containing text data says it contains 5000 samples (i.e. the subtitle lasts 5 seconds), I was surprised to see that its granulepos was 0 (i.e. the position of the first sample), whereas I would expect it to be 5000 (number of samples in the Page/Packet).
inoteb
13th September 2002, 20:31
Originally posted by Suiryc
There is the same problem when you mux everything with OGMuxer : the AC3 track is allways played. So I also think it's related to OggDS (but maybe there is no solution for that, who knows).
I agree with that: 3 month ago I made several tests with OGM containing [Avi+AC3]+Ogg, and never reach success really. (see ).
Nevertheless, Blight put a nice code in ZoomPlayer to change from one audio track (AC3) to the other (Ogg), so the 2 are not superimposed anymore...
I quote him:
"To support multiple audio tracks in zoom player, originally written for AVI, I included code that checks the number of renderers then shuts them off only keeping the first renderer active. This assures only one audio track at a time is active.
I wrote it in such a way that it isn't AVI specific, so in theory, it should work with anything with more than one audio renderer.
All the detected audio renders are then listed under the "Audio Track" entry of the context menu."
I'd love to hear Tobias' opinion on the subject. I know you're working with the TCMP team to improve the OggMedia support. But can we expect new releases of your DS filters (Ogg & subtitles) fixing some issues (particularly concerning AC3 and SRT display, if there is solutions, of course!) in the future ?
Regards,
inoteb ;-]
PS @Suiryc
"OGMCutter should also be able to "adjust" the comments that are in the original file (Title and Chapters) according to where it cut" :
I love that!!! :D I gonna try it very soon...
sherpya
13th September 2002, 20:50
Originally posted by Suiryc
And while I am at it (I know I may ask too much things at a time :) ), I have one question concerning the way your DirectShow filter give audio streams to the next filters : the type of audio is based on the stream_header.subtype field, isn't it ? (so if I have "0161" in the subtype field, your filter tells that the audio format - I think of the wFormatTag field in WAVEFORMAT or WAVEFORMATEX structure here - is 0x0161 ?)
This would help me knowing if the fact that my OGM file containing a video stream and a WMA (or DivX Audio) stream won't play the audio (saying it lacks codec whereas the codec is here) is related to your filter or (more likely) to a restriction of Micro$oft in their filters.
Thanks.
You will able to use "outside the asf reader" only hacked dlls (aka divx audio)
0x160/0x161 are handled by windows media audio v1/2
0x162 is the new media audio from corona
There is only a "Direct Media Object" for decode it (0x162) and connects only to ASFReader.
So wmv9 is more "Blackboxed" than previous versions
Note divxaudio in divx3.22 package is an acm driver not a directshow filter
Btw beware, take a look here:
http://www.advogato.org/article/101.html
---
A question:
I've seen ogm splitter is able to split correctly chapter list.
It would be possible to "trim" out chapters not bound in the file
Also it would be (or it is) possible to mux subtitles and chapter
into an existing ogm file?
Suiryc
13th September 2002, 22:31
Originally posted by sherpya
You will able to use "outside the asf reader" only hacked dlls (aka divx audio)
I installed DivX audio (from Nimo codec pack) and I was able to have the audio coming from an AVI file that have audio at 0x0161 format.
But it didn't worked with the OGM file :(
Btw beware, take a look here:
http://www.advogato.org/article/101.html
Yeah I know, but my test were more for educational purpose than anything else, since there is no interest in "converting" A$F to something else (OGM here) if you cannot have the audio with it :(
So I doubt anyone use this "functionality" (I even don't)
And unless somebody tells me not to do so, I would consider to remove that ...
A question:
I've seen ogm splitter is able to split correctly chapter list.
It would be possible to "trim" out chapters not bound in the file?
Well I made it the easiest way here : I know where I cut, and I look at all the chapters in the comments and adjust the time.
It would be easy to throw away chapters that belong to next parts, but it is another thing for those belonging to previous parts, because comments are like that :
CHAPTER01=...
CHAPTER01NAME=...
CHAPTER02=...
CHAPTER02NAME=...
...
In the first time I threw away chapters belonging to previous parts, for example the first chapter, which make the comments like that :
CHAPTER02=...
CHAPTER02NAME=...
The problem is that (at least in BSPlayer) then chapters are not taken into account anymore (because there is not the first chapter - CHAPTER01 things -).
So the solution would be to look at all the chapters, throw away those not belonging to the current part, search the lowest one (here CHAPTER02) and also adjust the chapter number.
This is possible of course, but I thought it was maybe too much here.
I also thought that keeping all the chapters was the best solution after cutting : in each file you know what are all the chapters in the entire clip, and their time (unless they belong to a previous part).
Of course if some of you think that just throwing away chapters is better in some situations, I could allow that too (then you would precise whether you want to keep all the chapters, or if you want to "trim" them).
Also it would be (or it is) possible to mux subtitles and chapter into an existing ogm file?
Yes it is possible.
You can use an omx file (same as OggMux) :
in the "movie" tag you use your ogm file, in the subtitles tag, you precise your subtitle file with the comment, and in the chapters tag you precise the file (same formats supported that OggMux) containing the chapters.
That's all :).
Well you wouldn't be able to use this omx file with OggMux since the video file must be an AVI one, but omx file was a convenient way for me to add comments and chapters functionality :)
With OGMuxer you would also be able to precise other OGM files, or even AC3/MP3/SRT ones in the soundtracks or subtitles tags because I just take the filename and open the file (my program determines automatically the format).
sherpya
13th September 2002, 22:48
About the divx audio, what are you using to demux the audio?
DirectShow or ACM? (I will look the enitire thread maybe I've yet replied to this).
Anyway you don't need to decode the stream but extracting divxaudio to a file becomes a wma file?
If you put an avi file with divx audio into graphedit you will see
divxaudio is decoded by windows media audio dmo decoder
and accepts the input from avi splitter (and also from an avi parser)
Then I think it's also possibile... however I don't known about to insert a dmo into a graph
for chapter splitting in my python library I do this for the next split part:
- chapter list for the previous is truncated
- chapter number restart from 1
- find the time for the last chapter of the previous split and insert it as chapter 1 with time 0, this only if the first chapter of the second split is not at the ogm split time (I doubt for it :D )
This replicates last chapter (and for me it's ok) but you can also add an option to prevent this.
Edit: Ogm files with wma audio wont play in wmplayer 6.4 because doesn't support dmo, peraps with 9 oggds crashes, just to wait the new tobias's release that fixes issue with wmp9 or found an hacked wma filter (only for version 1/2, version 3 hasn't directshow filter)
Suiryc
13th September 2002, 22:57
Originally posted by sherpya
About the divx audio, what are you using to demux the audio?
DirectShow or ACM? (I will look the entire thread maybe I've yet replied to this)
No, I use a "hacked" VirtualDub (if we are talking of the same thing).
I ask this VirtualDub to open the file, and to give me the video and audio stream (so no problem here).
I loop on the number of frames for each stream and give this to my program tools, which then create Packets that are given to the Ogg library which returns Pages I write in the file.
So, normally, I have the real good audio stream in the OGM file, but the stream is then not usable with DirectShow (when I open the file in graphedit it says it couldn't render one of the streams, and of course it is the audio one).
For the chapter thing I should be able to implement that.
Emp3r0r
14th September 2002, 00:05
I have an older OGM that has AC3 in it which I created with the old method of muxing with avi first then into the ogm file. I demuxed it to the .avi and the .ac3 and the .ac3 file plays fine in WMP6.4 but when I try to remux it using ogmuxer I get the following error
G:\Documents and Settings\Jeremy\My Documents\My Movies>ogmuxer -o matrix.ogm matrix.ac3
OGMuxer v0.9a2 - an Ogg Media File multiplexer
Copyright (C) 2002 Cyrius
Using some of the VirtualDub 1.4.10 reading routines
VirtualDub Copyright (C) 1998-2001 Avery Lee
<http://www.virtualdub.org>
Warnning in parse_args (OGMuxer.cpp) @ 257 : matrix.ac3 is not of a known type,
skippeddoes my .ac3 file need a special wav header?
PS: I will try with an .ac3 file created by dvd2avi and see if i get the same error
[update] ok it must be a bummed .ac3 file because the other .ac3 I tried worked fine, i'll try and demux it using graphedit and see if that fixes my problem
sherpya
14th September 2002, 02:31
Originally posted by Suiryc
So, normally, I have the real good audio stream in the OGM file, but the stream is then not usable with DirectShow (when I open the file in graphedit it says it couldn't render one of the streams, and of course it is the audio one).
I've wmp9 installed so I'm able to render such audio files, wmp9 installs WMA DMO Decoder, but I'm not able to play wma into ogm (muxed with oggmux, not tried with your muxer)
But remember this is only possible for audio, windows media video stream will connect ONLY to an ASFReader
For the chapter thing I should be able to implement that.
This is fine
:D
@Emp3r0r
If you have used nandub to demux ac3 the file now has a "wave" header, even besweet won't work with wave ac3 files.
I've solved it with graphedit:
render the file and connect a "Dump" (is in the audiofilter package) after wave parser, then delete the other (rendering filters)
Press play...
Note: Render of an ac3 file in graphedit don't work if you don't have installed an ac3 decoder filter (in audiofilters package)
DSPguru
14th September 2002, 11:01
Originally posted by sherpya
even besweet won't work with wave ac3 files.are you sure about it ?
i always thought it handles it correctly... :o
anyway, you can remove that wav header with BeSplit.. (also mentioned in the 'Audio FAQ' sticky thread)
Koepi
14th September 2002, 11:12
I can verify this, you have to fix the Wav-ac3 with besplit, after that besweet works with it.
Regards,
Koepi
Suiryc
14th September 2002, 12:16
Originally posted by sherpya
I've wmp9 installed so I'm able to render such audio files, wmp9 installs WMA DMO Decoder, but I'm not able to play wma into ogm (muxed with oggmux, not tried with your muxer)
No need to try with my muxer, only the version I have here (and not the one I released) can "try" to do that ;)
If you have used nandub to demux ac3 the file now has a "wave" header, even besweet won't work with wave ac3 files.
Well if files are not 100% normal (i.e. without any Wave header - so do not demux with VirtualDub/Nandub and then try to mux with my muxer, because this won't wotk : you have to remove the wave header), they won't work.
BTW few months ago I succeeded in encoding Waved AC3 to MP3 using BeSweet :/.
As DSPguru said I think that BeSweet can handle Wave headers on those kinf of files.
Mosu
14th September 2002, 13:26
So when the first Page/Packet containing text data says it contains 5000 samples (i.e. the subtitle lasts 5 seconds), I was surprised to see that its granulepos was 0 (i.e. the position of the first sample), whereas I would expect it to be 5000 (number of samples in the Page/Packet).
I agree. Although I've made the same mistake (actually I've just tried to emulate the OggDS behaviour and not thought about it all that much) with my Linux tools I'd strongly suggest that you, Tobias, correct your filter's approach. I'd like the OGM files (produced bei either OggDS, the Windows tools or my Linux tools) to be as standards compliant as possible, and at the moment subtitle support is definitely broken.
Suiryc
14th September 2002, 16:39
Originally posted by Mosu
I'd like the OGM files (produced bei either OggDS, the Windows tools or my Linux tools) to be as standards compliant as possible
It's what we all want to do I think :)
While we are at it, I have a question for both of you (Tobias & Mosu) : what is according to you the granular position of the first sample in a stream? 0 (like in VirtualDub : first frame = frame 0) or 1?
Because with OggDS video & text samples seem to start at granularpos 0 (i.e. first sample = granularpos 0, and so on), but it seems that Vorbis samples (in Ogg files) starts at granularpos 1 (i.e. the first sample in the stream is at granularpos 1 - I think it's like that because every Page's granularpos is an even number, but correct me if I am wrong here).
Presently I assume that it is 0, but every time I make a modification I wonder if it is good or not (because of the Vorbis case).
If anyone knows the answer, please don't leave me in the dark here :)
Mosu
14th September 2002, 17:30
Originally posted by Suiryc
While we are at it, I have a question for both of you (Tobias & Mosu) : what is according to you the granular position of the first sample in a stream? 0 (like in VirtualDub : first frame = frame 0) or 1?
My current implementation sets it to 1 for the first video frame, because Xiph's documentation clearly states that a page's granulepos (and therefore the packet's granulepos as well) corresponds to the end position.
On the other hand my OGMTools emulate the OggDS behaviour regarding the subtitle's granulepos... The problem is that there are already files that use the 'broken' method, and these would not be displayed correctly if the behaviour was changed. Perhaps Tobias can add an option to switch between the two interpretations while demultiplexing and fix the multiplexing method.
MPlayer, THE movie player for Linux, has only recently got support for subtitles in OGM which emulates the OggDS behaviour as well. But I will submit patches to change that as soon as Tobias indicates that he will do that for his filters.
Tobias, you see, we'd really like you to do that :)
Suiryc
14th September 2002, 17:48
Originally posted by Mosu
My current implementation sets it to 1 for the first video frame, because Xiph's documentation clearly states that a page's granulepos (and therefore the packet's granulepos as well) corresponds to the [B]end position
In the beginning I was doing the same (because of the Xiph's documentation too), but then I saw what seem to do OggDS in such cases I changed to the present situation because I thought that even if my tools (try to) comply to the standard, it's of no use if the filter that render the file behave another way ...
Now I think I will come back to the previous behavior (i.e. first sample = granulepos 1).
Thanks :)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.