Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#1 | Link |
unsigned int
Join Date: Oct 2012
Location: 🇪🇺
Posts: 760
|
Basic audio support for VapourSynth
https://github.com/dubhater/vapoursynth-damb
Code:
import vapoursynth as vs cc = vs.get_core() #cc.std.LoadPlugin("../libdamb.so") src = cc.ffms2.Source("7 minutes 50 seconds video.mp4") src = cc.damb.Read(src, "demuxed audio.wav") a = src[0:720] b = src[720:720*2] c = src[720*2:720*3] d = src[720*3:720*4] e = src[720*4:720*5] f = src[720*5:720*6] g = src[720*6:] src = f + d + a + g + c + b + e src = cc.damb.Write(src, "edited audio.wav") src.set_output() For the curious, "damb" means "Dingoes ate my baby" (it's a band). I wanted to call it "ding" (because it deals with audio, right?) but there is already some software with that name.
__________________
Buy me a "coffee" and/or hire me to write code! |
![]() |
![]() |
![]() |
#2 | Link |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,503
|
So it attaches the audio samples to each frame?
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
![]() |
![]() |
![]() |
#4 | Link |
ангел смерти
![]() Join Date: Nov 2004
Location: Lost
Posts: 9,555
|
Aww, and you could called the writer FriesAreDone() if you'd called it ding.
![]() How does it deal with framerate/audiorate mismatches, where a sample overhangs the end or starts late? Or is that more of an "if it hurts, don't do that!" kind of thing? Fudging a few samples on 48kHz audio probably isn't going to hurt anyway... |
![]() |
![]() |
![]() |
#5 | Link | |
unsigned int
Join Date: Oct 2012
Location: 🇪🇺
Posts: 760
|
Quote:
Read deals with mismatches in the audio and video lengths by returning an error if the audio is too short. That is, if the audio corresponding to a video frame does not exist at all (past the end of the audio file). Should it attach silence instead? It's okay if the last video frame has a bit fewer audio samples than the rest. If the audio is longer than the video, the extra samples at the end are ignored.
__________________
Buy me a "coffee" and/or hire me to write code! |
|
![]() |
![]() |
![]() |
#7 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 712
|
You should add a frame property indicating the (sub-sample) delay or lead of the audio buffer, even if you don’t use it now. This could help handling mismatch between audio and video frame durations.
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding |
![]() |
![]() |
![]() |
#8 | Link |
unsigned int
Join Date: Oct 2012
Location: 🇪🇺
Posts: 760
|
Here is v2, with a bit nicer behaviour and better documentation: https://github.com/dubhater/vapoursy...eleases/tag/v2
Code:
Read: * avoid desynchronisation due to accumulated rounding errors. Write: * reject clips with more than one type of audio * detect the output format from the extension
__________________
Buy me a "coffee" and/or hire me to write code! |
![]() |
![]() |
![]() |
#10 | Link | |
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 6,658
|
Quote:
src = cc.damb.Read(src, "demuxed audio.wav")
__________________
BeHappy, AviSynth audio transcoder. |
|
![]() |
![]() |
![]() |
#14 | Link |
unsigned int
Join Date: Oct 2012
Location: 🇪🇺
Posts: 760
|
Here is v3. It was supposed to include Dissolve(), but I changed my mind about writing that.
Code:
Read: * add support for delay * return silence instead of aborting in case of errors (like reading past the end of the audio file) * really reject unsupported formats * fix detection of the sample type Read and Write: * add support for WAV with WAVEFORMATEX
__________________
Buy me a "coffee" and/or hire me to write code! |
![]() |
![]() |
![]() |
#17 | Link | |
unsigned int
Join Date: Oct 2012
Location: 🇪🇺
Posts: 760
|
Quote:
No, audio will not be passed to ffmpeg. The audio is attached to video frames as properties. vspipe will only output the video itself. If your operating system has mkfifo, maybe you can avoid writing the audio to a real file.
__________________
Buy me a "coffee" and/or hire me to write code! |
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|