Log in

View Full Version : More than ~10 clips is a memory buster?


hinsdale1
5th October 2011, 17:13
I was attempting to automate splicing of 40-50 short clips, with transitions, various subtitle effects, etc. Finally got script to work as desired using 3-4 test clips, but when trying 40-50 clips (or even just 15) it results in memory errors when loading into MeGUI or VDub. I didnt realize that it would open two(2) Haiaii Splitters (not sure why two) and a Fdshow Video decoder for each of the 40-50 short 1080p clips.

Anyway, I am dumb(founded) and would be very grateful for any help pointing me in the direction of some solution to get around the memory issues. Is there a method to process the clips that doesnt load into RAM (speed is not an issue)? or any potential solution would be much appreciated!!!!

Here is an shortened version of the script:
LoadPlugin("c:\Program Files (x86)\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("c:\Program Files (x86)\AviSynth 2.5\plugins\TransAll.dll")
LoadPlugin("c:\Program Files (x86)\AviSynth 2.5\plugins\SubtitleEx.dll")

#convert non-conforming clips to following size/framerate/length/

Global Nfr_num=24000
Global Nfr_den=1001
Frate=23.976
Fw=1920
Fh=1080
Fcolor=$FF00FF #HOT PINK $FF00FF ,

########################
#global

Function myfunc(clip c1, clip c2, int x, int y, int z)
{
Overlay(c1,c2,x,y,opacity=.45)
}

Index=1


#########################
# VARIABLE DATA

file_clip1=DirectShowSource("K:\TEST VIDEO\Vacation-AA.mkv", fps=23.81)
artist_clip1="Thanksgiving Break"
song_clip1="Aruba-Caymens"
year_clip1="2002"
start_clip1=1200
end_clip1=1700
FPS_clip1=23.81
file_clip2=DirectShowSource("K:\TEST VIDEO\Vacation-KV.mkv", fps=23.976)
artist_clip2="Spring Break"
song_clip2="Costa Rica"
year_clip2="2011"
start_clip2=1200
end_clip2=1700
FPS_clip2=23.976
file_clip3=DirectShowSource("K:\TEST VIDEO\Vacation-66.mkv", fps=24)
artist_clip3="Christmas Trips"
song_clip3="Puerto Vallarta - Cabo"
year_clip3="2010"
start_clip3=1200
end_clip3=1700
FPS_clip3=24

###########################
#CLIP1

START = EVAL("start_clip"+string(index))
END = EVAL("end_clip"+string(index))
artist_clip = EVAL("artist_clip"+string(index))
song_clip = EVAL("song_clip"+string(index))
year_clip = EVAL("year_clip"+string(index))
frame_clip = EVAL("FPS_clip"+string(index))
framecnt=END-START

c1 = EVAL("file_clip"+string(index)).trim(START,END)

fps = frame_clip-frate
Ar=Audiorate(c1)
conv_audio_rate=round(Ar*frame_clip*Nfr_den/Nfr_num)

c1 = abs(fps)<.001 ? c1 : abs(fps) <= 1 ? ReSampleAudio(c1,conv_audio_rate).AssumeSampleRate(Ar).assumefps(Frate,false) : convertfps

(c1,frate)

c1 = height(c1)==Fh ? c1 : LanczosResize(c1,Fw, Fh)

C2= BlankClip(width=1920, height=180, fps=23.976, color=$00000000 ).trim(0,120)
c3= Animate(0,72,"myfunc",c1,c2,-2560,828,0,c1,c2,-240,828,1).trim(0,framecnt-72)
c4= Animate(framecnt-72,framecnt-24,"myfunc",c1,c2,-240,828,0,c1,c2,-1920,828,1).trim(framecnt-71,framecnt)

c3 + c4

subtitleEX(string(artist_clip)+"""|""""+string(song_clip)+"""" ("""+string(year_clip)+""")""", effects = "f

(48,48)",firstframe=72,lastframe=framecnt-48,halocolor = $00000000,x=246,y=906,textcolor=$00000000,size=60)

subtitleEX(string(artist_clip)+"""|""""+string(song_clip)+"""" ("""+string(year_clip)+""")""",effects = "f

(48,48)",firstframe=72,lastframe=framecnt-48,halocolor=$00000000,x=242,y=902,textcolor=$F8F8FF,size=60)

clip1=last
trans1=Clip1

index=index+1

###########################
#CLIP2

START = EVAL("start_clip"+string(index))
END = EVAL("end_clip"+string(index))
artist_clip = EVAL("artist_clip"+string(index))
song_clip = EVAL("song_clip"+string(index))
year_clip = EVAL("year_clip"+string(index))
frame_clip = EVAL("FPS_clip"+string(index))
framecnt=END-START

c1 = EVAL("file_clip"+string(index)).trim(START,END)

fps = frame_clip-frate
Ar=Audiorate(c1)
conv_audio_rate=round(Ar*frame_clip*Nfr_den/Nfr_num)

c1 = abs(fps)<.001 ? c1 : abs(fps) <= 1 ? ReSampleAudio(c1,conv_audio_rate).AssumeSampleRate(Ar).assumefps(Frate,false) : convertfps

(c1,frate)

c1 = height(c1)==Fh ? c1 : LanczosResize(c1,Fw, Fh)

C2= BlankClip(width=1920, height=180, fps=23.976, color=$00000000 ).trim(0,120)
c3= Animate(0,72,"myfunc",c1,c2,-2560,828,0,c1,c2,-240,828,1).trim(0,framecnt-72)
c4= Animate(framecnt-72,framecnt-24,"myfunc",c1,c2,-240,828,0,c1,c2,-1920,828,1).trim(framecnt-71,framecnt)

c3 + c4

subtitleEX(string(artist_clip)+"""|""""+string(song_clip)+"""" ("""+string(year_clip)+""")""", effects = "f

(48,48)",firstframe=72,lastframe=framecnt-48,halocolor = $00000000,x=246,y=906,textcolor=$00000000,size=60)

subtitleEX(string(artist_clip)+"""|""""+string(song_clip)+"""" ("""+string(year_clip)+""")""",effects = "f

(48,48)",firstframe=72,lastframe=framecnt-48,halocolor=$00000000,x=242,y=902,textcolor=$F8F8FF,size=60)

clip2=last

trans2=TransSprite(trans1, clip2, 48,"left")

index=index+1

#################################
#CLIP3


START = EVAL("start_clip"+string(index))
END = EVAL("end_clip"+string(index))
artist_clip = EVAL("artist_clip"+string(index))
song_clip = EVAL("song_clip"+string(index))
year_clip = EVAL("year_clip"+string(index))
frame_clip = EVAL("FPS_clip"+string(index))
framecnt=END-START

c1 = EVAL("file_clip"+string(index)).trim(START,END)

fps = frame_clip-frate
Ar=Audiorate(c1)
conv_audio_rate=round(Ar*frame_clip*Nfr_den/Nfr_num)

c1 = abs(fps)<.001 ? c1 : abs(fps) <= 1 ? ReSampleAudio(c1,conv_audio_rate).AssumeSampleRate(Ar).assumefps(Frate,false) : convertfps

(c1,frate)

c1 = height(c1)==Fh ? c1 : LanczosResize(c1,Fw, Fh)

C2= BlankClip(width=1920, height=180, fps=23.976, color=$00000000 ).trim(0,120)
c3= Animate(0,72,"myfunc",c1,c2,-2560,828,0,c1,c2,-240,828,1).trim(0,framecnt-72)
c4= Animate(framecnt-72,framecnt-24,"myfunc",c1,c2,-240,828,0,c1,c2,-1920,828,1).trim(framecnt-71,framecnt)

c3 + c4

subtitleEX(string(artist_clip)+"""|""""+string(song_clip)+"""" ("""+string(year_clip)+""")""", effects = "f

(48,48)",firstframe=72,lastframe=framecnt-48,halocolor = $00000000,x=246,y=906,textcolor=$00000000,size=60)

subtitleEX(string(artist_clip)+"""|""""+string(song_clip)+"""" ("""+string(year_clip)+""")""",effects = "f

(48,48)",firstframe=72,lastframe=framecnt-48,halocolor=$00000000,x=242,y=902,textcolor=$F8F8FF,size=60)

clip3=last

trans3=TransCrumple(trans2, clip3, 48)

index=index+1

#################################

return(trans3)



Please forgive the ineligant scripting - I am a complete novice. There is presumably a better method to handle the clips to avoid memory blowout - any help is greatly appreciated.

Gavino
5th October 2011, 18:24
I suspect most of the memory is used by the repeated calls to Overlay(). As a first step in the investigation, try using Layer (http://avisynth.org/mediawiki/Layer)() instead. You will have to convert your clips to RGB32 if they are not already in this format.

hinsdale1
5th October 2011, 19:09
Thank you Gavino for your reply.. you are clearly a scholar and a gentleman.

I changed Overlay to Layer (/w convertoRGB32) as you suggested but unfortunately the scripts result in the same memory errors when using 10+ video clips and loading into virtualdub.


VirtualDub Error

X Avisynth read error:

GetFrameBuffer: Returned a VFB with a 0 data pointer!
size=8294464, max=536870912, used=66971072
I think we have run out of memory folks!

Any other thoughts you may have would be greatly appreciated?

hinsdale1
5th October 2011, 21:21
In a furthur effort to narrow down things, I have basically removed everything from the script (no plugins, no subtitles,no function,animate) - leaving basically just converting all clips to the same framesize, framerate, audiorate and then splicing using dissolve.

LoadPlugin("c:\Program Files (x86)\AviSynth 2.5\plugins\DGDecode.dll")

#convert non-conforming clips to following size/framerate/length/

Global Nfr_num=24000
Global Nfr_den=1001
Frate=23.976
Fw=1920
Fh=1080

Index=1


#########################
# VARIABLE DATA

file_clip1=DirectShowSource("K:\TEST VIDEO\Vacation-AA.mkv", fps=23.81)
artist_clip1="Thanksgiving Break"
song_clip1="Aruba-Caymens"
year_clip1="2002"
start_clip1=1200
end_clip1=1700
FPS_clip1=23.81
file_clip2=DirectShowSource("K:\TEST VIDEO\Vacation-KV.mkv", fps=23.976)
artist_clip2="Spring Break"
song_clip2="Costa Rica"
year_clip2="2011"
start_clip2=1200
end_clip2=1700
FPS_clip2=23.976
file_clip3=DirectShowSource("K:\TEST VIDEO\Vacation-66.mkv", fps=24)
artist_clip3="Christmas Trips"
song_clip3="Puerto Vallarta - Cabo"
year_clip3="2010"
start_clip3=1200
end_clip3=1700
FPS_clip3=24

###########################
#CLIP1

START = EVAL("start_clip"+string(index))
END = EVAL("end_clip"+string(index))
artist_clip = EVAL("artist_clip"+string(index))
song_clip = EVAL("song_clip"+string(index))
year_clip = EVAL("year_clip"+string(index))
frame_clip = EVAL("FPS_clip"+string(index))


c1 = EVAL("file_clip"+string(index)).trim(START,END)

fps = frame_clip-frate
Ar=Audiorate(c1)
conv_audio_rate=round(Ar*frame_clip*Nfr_den/Nfr_num)

c1 = abs(fps)<.001 ? c1 : abs(fps) <= 1 ? ReSampleAudio(c1,conv_audio_rate).AssumeSampleRate(Ar).assumefps(Frate,false) : convertfps

(c1,frate)

c1 = height(c1)==Fh ? c1 : LanczosResize(c1,Fw, Fh)
c1

clip1=last

index=index+1

###########################
#CLIP2

START = EVAL("start_clip"+string(index))
END = EVAL("end_clip"+string(index))
artist_clip = EVAL("artist_clip"+string(index))
song_clip = EVAL("song_clip"+string(index))
year_clip = EVAL("year_clip"+string(index))
frame_clip = EVAL("FPS_clip"+string(index))


c1 = EVAL("file_clip"+string(index)).trim(START,END)

fps = frame_clip-frate
Ar=Audiorate(c1)
conv_audio_rate=round(Ar*frame_clip*Nfr_den/Nfr_num)

c1 = abs(fps)<.001 ? c1 : abs(fps) <= 1 ? ReSampleAudio(c1,conv_audio_rate).AssumeSampleRate(Ar).assumefps(Frate,false) : convertfps

(c1,frate)

c1 = height(c1)==Fh ? c1 : LanczosResize(c1,Fw, Fh)
c1

clip2=last

index=index+1

#################################
#CLIP3

START = EVAL("start_clip"+string(index))
END = EVAL("end_clip"+string(index))
artist_clip = EVAL("artist_clip"+string(index))
song_clip = EVAL("song_clip"+string(index))
year_clip = EVAL("year_clip"+string(index))
frame_clip = EVAL("FPS_clip"+string(index))


c1 = EVAL("file_clip"+string(index)).trim(START,END)

fps = frame_clip-frate
Ar=Audiorate(c1)
conv_audio_rate=round(Ar*frame_clip*Nfr_den/Nfr_num)

c1 = abs(fps)<.001 ? c1 : abs(fps) <= 1 ? ReSampleAudio(c1,conv_audio_rate).AssumeSampleRate(Ar).assumefps(Frate,false) : convertfps

(c1,frate)

c1 = height(c1)==Fh ? c1 : LanczosResize(c1,Fw, Fh)
c1

clip3=last


index=index+1

#################################

dissolve(clip1,clip2,clip3,48)

The script results in the same memory errors if loading more than 16 or so video clips. I am completely baffled as to how to address this issue ... feeling a bit frustrated and would welcome any help from anyone?


Or perhaps I should make the question easier for those offended by my poor scripting: instead of checking my obviously novice and incredibly flawed effort....

if any experienced avisynth scripter wanted to simply splice a preview of 40-50 clips (using just 8-15 seconds of each of the clips) together (converting all to same 1080p framesize/rate/audio), along with simple titles that faded in/out for each clip and had a simple transition between each clip - how would you do it??? Is it even possible without memory issues?

Nevilne
5th October 2011, 21:26
Try something like Setmemorymax(2048)

and different source filters (avisource/ffms2)

Groucho2004
5th October 2011, 21:55
Avisynth developers do not want to develop a x64 edition (strange programmers?!)

Way to go to piss off the Avisynth developers who spent countless hours of their spare time over the years to give us such a great tool - for free.

You obviously have no clue about programming and no idea what is involved in properly porting an application from 32 bit to 64 bit particularly considering the huge amount of inline assembler code in Avisynth.

So, why don't get your head out of your ass for a moment and think before accusing the developers of being strange or lazy.

Guest
5th October 2011, 21:58
He also reported that DGDecNV is "useless", based (apparently) on his evaluation of a cracked binary that is almost 30 versions old. I'm not holding my breath waiting for him to explain that.

IanB
5th October 2011, 22:52
@hinsdale1,

Yes it is the number of Direct Show environments created by each DirectshowSource() that is killing you. Each one is sizeable.
GetFrameBuffer: Returned a VFB with a 0 data pointer!
size=8294464, max=536870912, used=66971072
I think we have run out of memory folks!
The error message indicates severe lack of free memory in the process address space.

The call was for an 8Mb chunk, SetMemoryMax was 512Mb, but there was only 64Mb already allocated (probably as 8 of 8Mb buffers) in the frame cache so far. So the address space is pretty maxed out, 64MB is about 3% of the 2GB address space.

Options:-

If you environment supports it you could try the 3GB hack. This might give you upto 50% more address space.

Try SetMemoryMax(32), this will force very aggressive reuse of the existing buffers.

Assuming the shape and sizes are compatible, externally splice your individual .mkv sources into a single big mkv source so you only need a single Direct Show environment. You could then cut the single input clip back into component clips to maintain your work flow.

Try a different source filter technology, like ffmeg or DG, that may be less memory intensive.

TheRyuu
5th October 2011, 23:50
DirectShowSource is probably the absolute last thing I would try if all else fails. I'm not saying it's the source of your problems but I certainly wouldn't want to be using it either way.

Try ffms2 (http://code.google.com/p/ffmpegsource/).

2Bdecided
6th October 2011, 14:27
Don't lots of codecs have issues when you load them multiple times? I've hit this with AVISource and over 60 clips joined together - first I lost audio, then with even more clips I lost the lot.

hinsdale1
6th October 2011, 18:27
Don't lots of codecs have issues when you load them multiple times? I've hit this with AVISource and over 60 clips joined together - first I lost audio, then with even more clips I lost the lot.

I have switched to FFMS2 as many of the helpful contributors to this forum (thank you everyone) suggested and it did allow me to expand from about 12 clips to over 25 video clips - although now I lost audio :(. Too many clips more than that and it also resulted in same memory errors.

My plan now is two create two (2) lossless 25 clip chunks avi's and then splice together to get to my 50 clip requirement. THen hopefully figure out a script/method to process the audio seperately and mux to the final x264 video...... Unless somebody has a better suggestion?

Its not going as far as I would have hoped in streamlining / automating the process though.

TheRyuu
7th October 2011, 01:04
although now I lost audio :(.

ffaudiosource doesn't work?

cobo
7th October 2011, 02:41
I have switched to FFMS2 as many of the helpful contributors to this forum (thank you everyone) suggested and it did allow me to expand from about 12 clips to over 25 video clips - although now I lost audio :(.

Is this the problem you're having?
Re: FFMS2 (The Fabulous FM Source 2) (http://doom10.org/index.php?PHPSESSID=jtq80btbf1e89ra3sn4do9bnc4&topic=25.msg6430#msg6430)
forclip

Seeking should be sample-accurate with most codecs in AVI, MKV, MP4 and FLV with two notable exceptions, namely MP3 and AC3 where FFmpeg's decoders seem to be completely brokenI have another sample (here it is), "FFAudioSource: No audio track found" - that`s what I get. But FFplay can play it and FFmpeg can see the audio stream. It`s another problem, or the same ("FFmpeg's decoders seem to be completely broken")?

Plorkyeran
The last packet of that file fails to decode (which is pretty common), and for some bizarre reason FFAudioSource uses error handling mode 1 (pretend the track doesn't exist) for indexing. Explicitly calling FFIndex lets you override this (or just leave it at the default as FFIndex defaults to ignoring errors).

hinsdale1
7th October 2011, 04:08
I was able to resolve the audio issue with the ffmpegsource2 sourced clips after a read thru of the FFMS2.avsi script and a slight modification.

I was very excited after days of mind numbing scripting to have finally completed an avisynth script that automatically spliced 25 or so HD clips together with transitions, fading titles, etc.

HOWEVER,( as it always goes).. although FFmpegsource2 allowed me to utilize more clips in my script, the audio is now out-of-sync in many of the clips. DirectShowSource did not have the same sync issues. Some more testing revealed that the issue is the audio/video delay on the clips. DirectShowSource accounts for any audio/video delay to sync the clips properly but FFmpegsource2 does not appear to handle the delays.

Does anyone know of a modification (besides manually looking up and entering in the DelayAudio() for each clip) to allow FFMS2 to accurately handle the audio/video delays?

As always, i am very grateful to the kind contributors to this very helpful forum.

Guest
7th October 2011, 05:10
I checked it was unlicensed version. I downloaded it from some site to see if I fit the video card. After three hours of experimentation, I deleted and went to the store and replaced the video card to Radeon. Your candor and generous spirit command respect. For my part, the slate is clean and all I can say is welcome to the forum and good luck with your projects. Maybe I can help you with them!

Guest
7th October 2011, 05:32
Does anyone know of a modification (besides manually looking up and entering in the DelayAudio() for each clip) to allow FFMS2 to accurately handle the audio/video delays? I prefer to bypass the need for lots of source filters where possible. For example, for transport streams with AC3 audio (like from camcorders) I would simply concatenate the transport files first. Then I would index that and serve the video via one source filter instance. For the audio, the demuxer then has to be smart enough to adjust the audio as it is demuxed. EAC3TO can do it. So can DGIndexNV. Then just source the demuxed audio in your script, dub it to the video, and do trims on the combined clip. No memory problems, no hassles.

I assume you know about aligned splices and use them where needed (a ++ b).

hinsdale1
7th October 2011, 06:10
The video clips are primarily AVC of varying framerates(23.976,24,25,29.97,30) & dimensions(480p-1080p) with usually LPCM audio in MKV containers.

My comprehension level is limited so I am probably not understanding you - do you mean demuxing all the video clips (using EAC3TO or DGIndexNV) prior to running the script.. and just sourcing the audio and video seperately and then dubbing.trimming.etc? Is there a method to accomplish this through the script that would not involve having to demux all the videos manually (will be thousands of clips - am automating a script to preview 50 or so of the collection at a time)? Sorry for my lack of sophistication, I realize you are a developer and is very kind of you to wade into the kiddie pool with me.


I should clarify as well: FFmpegsource2 does handle the audio/video delay when the audio delay is positive (for example audio delay is 300ms). It only fails to handle in circumstances where the difference between the audio start and the video start is negative. This may be because MKV allows the video to be delayed - unlike (i believe) mpeg (where a negative audio delay simply chops off that amount from the beginning of the audio) - so perhaps this is the issue.

As of now, I have circumvented the issue by exporting the video_delay info from Mediainfo into the spreadsheet I use to assign all the variables in the script and an appropriate DelayAudio() , when applicable, is added automatically as a parameter.

Guest
7th October 2011, 13:45
The video clips are primarily AVC of varying framerates(23.976,24,25,29.97,30) & dimensions(480p-1080p) with usually LPCM audio in MKV containers. Then my idea won't work for you.

TheFluff
7th October 2011, 14:12
I should clarify as well: FFmpegsource2 does handle the audio/video delay when the audio delay is positive (for example audio delay is 300ms). It only fails to handle in circumstances where the difference between the audio start and the video start is negative. This may be because MKV allows the video to be delayed - unlike (i believe) mpeg (where a negative audio delay simply chops off that amount from the beginning of the audio) - so perhaps this is the issue.

Which adjustdelay mode are you using?

hinsdale1
7th October 2011, 19:34
^I did not specify the adjustdelay so it is at default. Is there adjustdelay setting that would handle a video delay? (ffmpegsource2 seems to handle an audio delay without issue ).

TheFluff
9th October 2011, 02:49
^I did not specify the adjustdelay so it is at default. Is there adjustdelay setting that would handle a video delay? (ffmpegsource2 seems to handle an audio delay without issue ).

What do you mean by a video delay? That the audio starts before the video?

There are three possible values for adjustdelay that are relevant to you, namely:

-3: No adjustment is made; the first decodable audio sample becomes the first sample in the output.
-2: Samples are created (with silence) or discarded so that sample 0 in the decoded audio starts at time zero.
-1: Samples are created (with silence) or discarded so that sample 0 in the decoded audio starts at the same time as frame 0 of the first video track. This is the default, and probably what most people want.


You can try -2 or -3 and see what happens. If neither works as intended, then there's a bug in FFMS2 and I'd very much appreciate a small sample file that shows the problem, so I can attempt to fix it.

hinsdale1
9th October 2011, 04:46
These parameters did not resolve the issue.

Yes, the audio starts before the video if you have a video delay.

I can send you a sample if you like, just let me know how/where.

Or your can just create your own. Open any mp4, avi, mpeg2, etc. using mkvmergeGUI. Then select the video track and there is a "format specific options" tab that allows you to enter a video delay in milliseconds (enter for example 1000ms). Mux together into a matroska container and the resulting .mkv video will then be out of sync by the amount of the video delay you enter (in this case 1 sec) - however, when sourced through ffmg2 and avysynth the resulting video will still be insync because it does not appear to recognize the video delay.

Plorkyeran
9th October 2011, 17:13
Fixed in r578. The data for track zero was getting overwritten so the start time was always zero.

hinsdale1
10th October 2011, 01:29
I see r570 (beta version).. but cannot locate r578..

TheRyuu
10th October 2011, 07:49
I see r570 (beta version).. but cannot locate r578..

Check again. (http://code.google.com/p/ffmpegsource/downloads/detail?name=ffms2-r578.7z)

hinsdale1
10th October 2011, 20:22
Thanks for the link, and the r578 release is handling the video delays without issue now. THank you to all the developers and contributors.

I have encountered another issue with FFmpegSource'd mkv's though: A quick, practically lossless (no video re-encode required) method to convert 1080p,720p Pal >> 1080p or 720p NTSC (or reverse) is to simply speed the video/audio up or down the ~4% difference. The limited downside to this method is the time stretch changes the audio tempo by 4% and the pitch (there are ways to generally correct the pitch if required) - which is not terrible and is generally a better alternative than the time and degradation to the video required of a full processing video conversion from 25fps to 23.976fps (or vica-versa).

This can be done very simply using mkvmerge GUI's format specific options to change the video framerate (for example: change the existing 25 to 24000/1001) and the audio options to time stretch (for example: set a 25000/23976 stretch). Just takes a few seconds to remux the pal material and the resulting ntsc .mkv file plays properly in all players (wmp, zoomplayer, media player classic)...

However, when source'd thru ffmpegsource and avisynth, the new video framerate of the converted .mkv is applied properly but the audio timestrech does not appear to be applied and the resulting output is out-of-sync?

2Bdecided
12th October 2011, 12:39
Any lossy compressed video put through AVIsynth cannot be "smart rendered" or re-compressed to the original format without loss, so this is a bad way of doing it compared with lossless options.

AVIsynth certainly can time stretch the audio correctly - I've done almost exactly what you say (but with a downsize to the video, so lossless was not required!). Post your script.

Cheers,
David.

hinsdale1
12th October 2011, 15:02
^The method of my conversion is lossless (using mkvmerge GUI to simply speed up/slow down audio/video without re-encoding) - that is not my problem. The resulting converted .mkv are standard format and play normally. The purpose of these NTSC>PAL or PAL>NTSC conversions is for BluRay compatibility when burning to BluRay - otherwise there would be no need to bother converting.

My problem is that my current avisynth script is designed to splice together 10-15 second preview clips of many of these previously PAL>NTSC converted videos. . Ffmpegsource is not recognizing the audio time stretch that has been set in these videos.

I am not an expert on containers (or on anything), but apparently the Matroska container allows an audiorate multiplier (stretch) to be set and this flag is then passed along to .mkv compliant codecs and players (similar to how you manually can set the video framerate). When sourcing .mkv videos (with an audio timesstretch flag set) thru avisynth and Ffmpegsource, the audiorate multiplier (stretch flag) is not being recognized and is causing the audio to be out-of-sync.

henryho_hk
13th October 2011, 03:59
hv u tried piping with avs26pipemod?

TheFluff
13th October 2011, 08:33
hv u tried piping with avs26pipemod?

The problem isn't in Avisynth's output, it's that ffms2 does not assumesamplerate() internally. Which could be considered a bug, I guess.