View Full Version : Trimming audio
valja
8th September 2005, 17:21
I'm trying to cut off ads, audio and video are loaded from separate files. trim() works as expected with the video, but has no effect to the audio. Here is script:
LoadPlugin("d:\DGDecode.dll")
video=MPEG2Source("oshibka.d2v",cpu=0,iPP=true)
audio=WAVsource("oshibka_PCM_fixed2.wav")
AudioDub(video, audio)
DelayAudio(-0.071)
YV12ToYUY2()
trim(0,29229)+trim(33608,66369)+trim(69122,105522)+trim(109512,166503)
crop(8,16,0,-8)
In the video, after the frame 29229 follows the frame 33608 - just as expected, frames 29230-33607 are cut off. But in the audio there is no effect - respective audio part is not cut off, it continues just as without trim().
Am I missing something obvious?
zambelli
8th September 2005, 17:51
Try this and see if it makes a difference:
video = YV12ToYUY2()
final = video.trim(0,29229) + video.trim(33608,66369) + video.trim(69122,105522) + video.trim(109512,166503)
final = final.crop(8,16,0,-8)
return final
valja
8th September 2005, 18:58
@zambelli
Well, it works.
But I still don't understand, why did not work my script. Are "YV12ToYUY2()", "trim()", "crop()" applied to the "video" clip and it is finally returned by the script? But video and audio are joined after "AudioDub(video, audio)" - in output there is audio, and until frame 29229 this audio is in sync (initially "oshibka.d2v" has no audio). So I don't understand reason, why trim() in my script affects only video part but not joined audio.
And finally, after some playing with scripts I opened intital one again (I did not touch it), and it started working as expected. :confused:
zambelli
8th September 2005, 21:28
I can't explain why it works now and not before, but the reasoning behind my suggestion was to make sure you were applying Trims to the same original clip and not inadvertently re-trimming the same clip over and over again and then adding it onto itself. The cleaner the Avisynth syntax, the less likelihood of hitting any bugs.
squid_80
8th September 2005, 22:52
Were you by chance working on this in virtualdub and had "WAV audio" selected instead of "Source Audio"? I've made that mistake before.
valja
9th September 2005, 07:53
Were you by chance working on this in virtualdub and had "WAV audio" selected instead of "Source Audio"? I've made that mistake before.Sounds reasonable. In this case the script worked all the time correctly, but VirtualDub used wrong audio stream - just my own mistake.
stickboy
9th September 2005, 10:59
I can't explain why it works now and not before, but the reasoning behind my suggestion was to make sure you were applying Trims to the same original clip and not inadvertently re-trimming the same clip over and over again and then adding it onto itself.That's not what happens.
Valja's script:
LoadPlugin("d:\DGDecode.dll")
video = MPEG2Source("oshibka.d2v",cpu=0,iPP=true)
audio = WAVsource("oshibka_PCM_fixed2.wav")
AudioDub(video, audio)
DelayAudio(-0.071)
YV12ToYUY2()
trim(0,29229)+trim(33608,66369)+trim(69122,105522)+trim(109512,166503)
crop(8,16,0,-8)is equivalent to:
LoadPlugin("d:\DGDecode.dll")
video = MPEG2Source("oshibka.d2v",cpu=0,iPP=true)
audio = WAVsource("oshibka_PCM_fixed2.wav")
last = AudioDub(video, audio)
last = last.DelayAudio(-0.071)
last = last.YV12ToYUY2()
last = last.trim(0,29229) + last.trim(33608,66369) + last.trim(69122,105522) + last.trim(109512,166503)
last = last.crop(8,16,0,-8)
return lastSo there should be no difference.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.