PDA

View Full Version : read VFR MKV file in avisynth without frame loss or gain?


adamhj
1st May 2005, 16:18
here i'm working on a vfr mkv(video stream encoded by nero avc and an aac audio track),when i try opening it with directshowsource i found that the frame number is less then it should be ...and i heard that it can be more or less than it original frame number when one open a vfr mkv with directshowsource...so i'm wondering how can i get exact frames in avisynth...no audio synchronization is needed as i only want to deal it as a frame sequence~

bond
1st May 2005, 16:56
how can you create a vfr mkv stream from the output of the nero avc encoder? the nero avc encoder doesnt output vfr streams

about the wrong framenumber via directshowsource:
what dshow filter graph do you use for decoding? are you sure these filter output the correct number of frames themselves?

avisynth cant handle vfr correctly, if you do what your are attempting, you will loose the vfr info and get a cfr output, which means you will get sync issues with the audio (as the lenght of the video will change)

adamhj
1st May 2005, 17:30
Originally posted by bond
how can you create a vfr mkv stream from the output of the nero avc encoder? the nero avc encoder doesnt output vfr streams

about the wrong framenumber via directshowsource:
what dshow filter graph do you use for decoding? are you sure these filter output the correct number of frames themselves?

avisynth cant handle vfr correctly, if you do what your are attempting, you will loose the vfr info and get a cfr output, which means you will get sync issues with the audio (as the lenght of the video will change)

it's simple.just strip the video track from a vfr source to a cfr source and use the encoder to encode it ,and then use timecode file to put the cfr stream in a mkv file and it is now vfr again

so i'm doing this too ,i want to strip the video stream out just as a frame sequence and recompress it with xvid, then pack it up into a mkv file with the timecode file i striped from the original mkv file

i'm decoding nero avc with nero decoder, to my thinking it could decode all frames out. for testifying i will try ffdshow

adamhj
1st May 2005, 17:40
err...ffdshow decoder got same result too...total frame no. is wrong...

Wilbert
1st May 2005, 17:50
If you download the latest binaries you can use

DirectShowSource("file.mkv",convertfps=29.97) # or whatever

Your video will be cfr, but it will remain in sync. The problem though, is you can't get the timecodes file this way.

adamhj
1st May 2005, 17:54
Originally posted by Wilbert
If you download the latest binaries you can use

DirectShowSource("file.mkv",convertfps=29.97) # or whatever

Your video will be cfr, but it will remain in sync. The problem though, is you can't get the timecodes file this way.

that's the problem..i don't need the sync.,i only need all original frames (= =)

bond
1st May 2005, 18:17
Originally posted by Wilbert
Your video will be cfr, but it will remain in sync.why will it remain in sync? :confused:

adamhj
1st May 2005, 18:25
Originally posted by bond
why will it remain in sync? :confused:

because when it meet a vfr clip and you have set the fps parameter it will calculate out a time duration, and seek with this time duration ..so it will be sync. but with more or less frames

jinkslynx
1st May 2005, 18:48
you could try and load it into avi-mux-gui, deselect all subtitles and audio, and save as .avi :)

avimux (http://www-user.tu-chemnitz.de/~noe/Video-Zeug/AVIMux%20GUI/index-eng.html)

adamhj
1st May 2005, 19:05
Originally posted by jinkslynx
you could try and load it into avi-mux-gui, deselect all subtitles and audio, and save as .avi :)

avimux (http://www-user.tu-chemnitz.de/~noe/Video-Zeug/AVIMux%20GUI/index-eng.html)


thanks..but it can only be saved as .mkv (= =)

jinkslynx
1st May 2005, 19:13
Try again, it wont work unless you deselect everything.

http://img205.echo.cx/img205/6179/demux2in.jpg

edit:uploaded resized pic.

adamhj
1st May 2005, 19:47
is there anything i forgot to deselect?
Image Link: http://es-File.com/pict.asp?PN8NE


edit:image link changed

bond
1st May 2005, 20:43
Originally posted by adamhj
because when it meet a vfr clip and you have set the fps parameter it will calculate out a time duration, and seek with this time duration ..so it will be sync. but with more or less frames ok you will get the same time lenght, but still you dont get correct sync with audio

lets say a constant framerate stream has 3 frames (lets say with 3fps) in sync with audio
lets say frame 1 and 2 are the same, so you can delete frame 2 and display frame 1 with the double time instead (variable framerate), still having sync with audio, average video framerate is now 1.5fps
but if you really give each frame a framerate of 1.5 you get desync with audio (as for sync the first frame has to be displayed 2 secs, frame "3" 1 sec, and not 1.5/1.5)

adamhj
1st May 2005, 21:01
Originally posted by bond
ok you will get the same time lenght, but still you dont get correct sync with audio

lets say a constant framerate stream has 3 frames (lets say with 3fps) in sync with audio
lets say frame 1 and 2 are the same, so you can delete frame 2 and display frame 1 with the double time instead (variable framerate), still having sync with audio, average video framerate is now 1.5fps
but if you really give each frame a framerate of 1.5 you get desync with audio (as for sync the first frame has to be displayed 2 secs, frame "3" 1 sec, and not 1.5/1.5)

it depend on the fps parameter, if you set it to 2 it would give a wrong result of course, but if you set it to 3 or above ,you will get the correct(or nearly correct if it is not mod 3) result.Take 3 fps for example, it's 3 frames/s , so it have 3 frames in 1 second, for frame #0 it seek to time 0 and gets frame 1,for frame #1 it seek to time 1/3 and returns frame 1 agian, for frame 2 it seek to time 2/3 and returns frame 3


edit:3fps/s => 3frames/s

jinkslynx
1st May 2005, 21:09
Pic link still don't work.

Unless you forgot to unchecked "all audio streams" and
"all subtitle streams", then i guess no. Afraid I don't have any other VFR clips to test on.

Long shot: try to pass the clip through mkvmerge first, then
mkv-mux-gui, after that, I'm out of ideas, sorry.

bond
1st May 2005, 21:10
still you cant convert vfr to cfr without loosing sync with audio, otherwise why is vfr needed at all? ;)

adamhj
1st May 2005, 21:14
Originally posted by bond
still you cant convert vfr to cfr without loosing sync with audio, otherwise why is vfr needed at all? ;)

it doesn't lose audio sync(may lose a little in some situation, but it's hard for man to found it out) , instead, it loses video frames...= =

adamhj
1st May 2005, 21:23
Originally posted by jinkslynx
Pic link still don't work.

Unless you forgot to unchecked "all audio streams" and
"all subtitle streams", then i guess no. Afraid I don't have any other VFR clips to test on.

Long shot: try to pass the clip through mkvmerge first, then
mkv-mux-gui, after that, I'm out of ideas, sorry.

try this link: http://pic13.album.tom.com/album_pic/2005/05/02/4cdfa48f9b017330c73722adc9a79e61?%75%4e%6c%46%66%73%49%79%6c%72

mkvmerge will keep the timecode infomation, i have no idea about mkv-mux-gui(mmg?it would do same as mkvmerge..)

to my point, avc stream can't be packed in avi as it is not supported..and that's why avi mux only have mkv output in my situation

thanks all the same

Wilbert
1st May 2005, 22:19
@Bond,

lets say a constant framerate stream has 3 frames (lets say with 3fps) in sync with audio
lets say frame 1 and 2 are the same, so you can delete frame 2 and display frame 1 with the double time instead (variable framerate), still having sync with audio, average video framerate is now 1.5fps
but if you really give each frame a framerate of 1.5 you get desync with audio (as for sync the first frame has to be displayed 2 secs, frame "3" 1 sec, and not 1.5/1.5)
This is the case if you use

DirectShowSource(mkv_vfr, fps=29.97)

(I'm not sure if adamhj is referring to the above or the below. Of course the above is not adding frames, that's why the desync.)

I'm talking about

DirectShowSource(mkv_vfr, convertfps=29.97)

I will add frames to the 23.976 part of the clip getting 29.97.

bond
1st May 2005, 22:25
Originally posted by Wilbert
I'm talking about

DirectShowSource(mkv_vfr, convertfps=29.97)

I will add frames to the 23.976 part of the clip getting 29.97. [/B] wow, didnt know that this exists, cool :)

Wilbert
1st May 2005, 22:37
Hmm. I see that it isn't available yet with the latest binaries :)

You can get it here:

http://www.geocities.com/wilbertdijkhof/DirectShowSource.dll

HeadlessCow
2nd May 2005, 05:15
Use mp_rel (or mkv2vfr, though I had problems with it giving me wrong results) to extract the timecodes from the mkv into a text file and the video into a cfr avi file. Perform whatever editing in avisynth (don't add/delete frames) and then mux the resulting avi back into a matroska file using the timecodes you extracted at the start.

adamhj
2nd May 2005, 05:41
Originally posted by HeadlessCow
Use mp_rel (or mkv2vfr, though I had problems with it giving me wrong results) to extract the timecodes from the mkv into a text file and the video into a cfr avi file. Perform whatever editing in avisynth (don't add/delete frames) and then mux the resulting avi back into a matroska file using the timecodes you extracted at the start.

i have tried this and it even can't find the video track(both old version of mp_rel and newest mkv2vfr return the same result),so i wrote a tool to extract the timecode of specified track from mkv file (using the mkv library on haali's homepage) but now i meet the problem of unable to get the video streams...

and i think a nero avc stream can't be contained in avi format at all, since the most powerful avi pack tool avi-mux gui(as i think) failed to do this...

edit: i used halli for haali by mistake (= =)

Wilbert
2nd May 2005, 11:55
i have tried this and it even can't find the video track(both old version of mp_rel and newest mkv2vfr return the same result),so i wrote a tool to extract the timecode of specified track from mkv file (using the mkv library on haali's homepage)
Could you share that tool with us please?

Btw, mkv2vfr works for me, but the new timecodes file is different as the one used to create the mkv file.

adamhj
2nd May 2005, 12:41
Originally posted by Wilbert
Could you share that tool with us please?

Btw, mkv2vfr works for me, but the new timecodes file is different as the one used to create the mkv file.


i would share it once i finished testing it..but now i am blocked here...= =

haali's tool caculate timecode v1 out, but it seems that the date format in mkv file is just like timecode v2, so my tool only generate timecode v2 file , as it is a simpler and exacter way(although not suitable for human to read...)

HeadlessCow
3rd May 2005, 19:33
Originally posted by Wilbert
Btw, mkv2vfr works for me, but the new timecodes file is different as the one used to create the mkv file.

As I posted here (http://forum.doom9.org/showthread.php?s=&postid=614527#post614527) the difference is pretty drastic in the version I was using and the mkv2vfr output is pretty obviously not what it should be. I know at one point Haali was pointed at that thread, but I don't know if he updated and released a new mkv2vfr.

Wilbert
3rd May 2005, 20:44
Do you still have this mp_rel? I would like to try that one :)

adamhj
4th May 2005, 06:11
Originally posted by Wilbert
Do you still have this mp_rel? I would like to try that one :)
http://s10.yousendit.com/d.aspx?id=1W8DLG7NIMRUZ191RMLT7CMENN

lamer_de
4th May 2005, 10:38
If you don't care for sync at all, use dshowsource with a fps parameter higher than your real framecount (29.970fps for example). Load into vdub and encode. Please note: The following is just guessing from me, I have no clue how dshowsource works in reality: Dshowsource will get the clip's length and calculate the framenumber by multiplying it with the fps argument. Then it will read as many frames as it computed. As there aren't that many frames in the video stream, it will read everything that is there and add dummy frames afterwards.</speculation>. You can't preview it in vdub. Just encode and you'll see that there are many dummy frames at the end. You can cut those later then. At least that way it worked for me (although I did wanted sync, so in the end, that method was useless for me without a timecode file :P).

However, if you're going for vfr again, why not simply keep the original? Or download another groups release? Or buy the DVD? Ah, the possibilites...

CU,
lamer_de

Wilbert
4th May 2005, 10:47
Then it will read as many frames as it computed. As there aren't that many frames in the video stream, it will read everything that is there and add dummy frames afterwards.
No, it won't add dummy frames. The duration of the video will be shorter and thus out of sync.

See my post on the first page:
http://forum.doom9.org/showthread.php?s=&postid=648378#post648378

However, if you're going for vfr again, why not simply keep the original? Or download another groups release? Or buy the DVD? Ah, the possibilites...
Because i'm writing documentation. I hope you don't mind.

@adamhj,

Thx!

lamer_de
4th May 2005, 14:27
he duration of the video will be shorter and thus out of sync.Please read my post again. Especially my first sentence. And it will loop the last frame after it has read all the frames which are in the original file. That was what I wanted to say with dummy frames (hence afterwards, and not during the process). adamhj does not want a cfr output. He just wants all the frames, and for that task, the method I proposed should be sufficient. If you don't have a timecode file and don't mux the video in a container that is capable of using it, the video will be out of sync, yes.

Because i'm writing documentation. I hope you don't mind.Of course not. How this relates to the breach of forum rule 6 (please remember my post was targeted at adamhj, not you) I wanted to hint at with my sentence is beyond me, though.

CU,
lamer_de

adamhj
4th May 2005, 18:02
Originally posted by lamer_de
If you don't care for sync at all, use dshowsource with a fps parameter higher than your real framecount (29.970fps for example). Load into vdub and encode. Please note: The following is just guessing from me, I have no clue how dshowsource works in reality: Dshowsource will get the clip's length and calculate the framenumber by multiplying it with the fps argument. Then it will read as many frames as it computed. As there aren't that many frames in the video stream, it will read everything that is there and add dummy frames afterwards.</speculation>. You can't preview it in vdub. Just encode and you'll see that there are many dummy frames at the end. You can cut those later then. At least that way it worked for me (although I did wanted sync, so in the end, that method was useless for me without a timecode file :P).

However, if you're going for vfr again, why not simply keep the original? Or download another groups release? Or buy the DVD? Ah, the possibilites...

CU,
lamer_de

err...it's out of my expecting..i tried to use fps=119.88 parameter but found at last it is still losing frames...this is strange...and the frames lost seem unregularly...

i just want to do a experiment and find out a way of vfr video recompression. the clip itself is not my destiny..