Re: Real-time 432hz Audio Auto-Pitching

And what the best?
You said about "This also gives a more accurate pitch"

Re: Real-time 432hz Audio Auto-Pitching

AviSYnth can either return INT16, INT24, INT32 or FLOAT32 audio. I did some tests with it. When returning FLOAT32, the sound is almost the same quality as the input. Very little distortion at all. If instead using INT32, then the sound feels a bit more "square", losing a bit of smoothness.

As far as plugging into the ffdshow chain, is there any technical reason preventing from doing this in the same way as SVP is doing it?

28

Re: Real-time 432hz Audio Auto-Pitching

Mystery wrote:

Here's the AviSynth code that's working best so far

I think LSMASHSource is better.

TimestretchYV12.avs:

file="Imput.mp4"
SetMTMode(3,4)
LoadPlugin("LSMASHSource.dll")
LSMASHVideoSource(file).AudioDub(LSMASHAudioSource(file))
/*
LoadPlugin("ffms2.dll")
Import("FFMS2.avsi")
FFmpegSource2(file, atrack=-1, cache=false, threads=1)
*/
SetMTMode(2)
ResampleAudio(48000)
SemiTone = -0.3176665363342977
TimeStretch(pitch = 100.0 * pow(2.0, SemiTone / 12.0))
# if you need 16bit Integer audio
#ConvertAudioTo16bit()

Mystery wrote:

With the above script, some videos play corrupted with SVP.

That's maybe decoder chain problem.
(maybe "AVI Decompressor(I420)" and "ffdshow raw video filter"....)
You should re-check "Play->Filters".

There's two solutions.

    Solution1.  Install LAV Filters. (and make it prefer)

    Solution2. Uncheck  "Options->Internal Filters->Source Filters->Avisynth"


When "Avisynth" is checked and LAV Filters is not installed : (Corrupted video and IEEE Float)

Properties: (TimestretchYV12.avs)
        Video: I420 854x480 29.97fps [V: rawvideo, yuv420p, 854x480]
        Audio: IEEE Float 48000Hz stereo 3072kbps [A: pcm_f32le, 48000 Hz, 2 channels, fp32, 3072 kb/s]

    Video filter chain:
        LAV Splitter Source (internal) -> (I420, 854x480) ->
        AVI Decompressor (I420) -> (RGB24, 854x480) ->
        ffdshow raw video filter -> (RGB32, 864x480) ->
        Enhanced Video Renderer (custom presenter)

    Audio filter chain:
        LAV Splitter Source (internal) ->
        LAV Audio Decoder (internal) -> (IEEE Float 48000Hz) ->
        Audio Switcher -> (IEEE Float 48000Hz) ->
        Internal Audio Renderer


When "Avisynth" is checked and LAV Filters is installed : (Fine video and IEEE Float)

Properties: (TimestretchYV12.avs)
        Video: I420 854x480 29.97fps [V: rawvideo, yuv420p, 854x480]
        Audio: IEEE Float 48000Hz stereo 3072kbps [A: pcm_f32le, 48000 Hz, 2 channels, fp32, 3072 kb/s]

    Video filter chain:
        LAV Splitter Source (internal) -> (I420, 854x480) ->
        LAV Video Decoder -> (YV12, 854x480) ->
        ffdshow raw video filter -> (NV12 896x480) ->
        Enhanced Video Renderer (custom presenter)

    Audio filter chain:
        LAV Splitter Source (internal) ->
        LAV Audio Decoder (internal) -> (IEEE Float 48000Hz) ->
        Audio Switcher -> (IEEE Float 48000Hz) ->
        Internal Audio Renderer


When "Avisynth" is unchecked: (Fine video and PCM)

Properties: (TimestretchYV12.avs)
        Video: YV12 854x480 29.97fps [Avisynth video #1]
        Audio: PCM 48000Hz stereo 1536kbps [Avisynth audio #1]

    Video filter chain:
        AVI/WAV File Source -> (YV12, 854x480) ->
        ffdshow raw video filter -> (NV12, 896x480) ->
        Enhanced Video Renderer (custom presenter)

    Audio filter chain:
        AVI/WAV File Source -> (PCM 48000Hz) ->
        Audio Switcher -> (PCM 48000Hz) ->
        Internal Audio Renderer


I don't know why "LAV Video Decoder (internal)" don't work with I420....

29 (edited by Nintendo Maniac 64 24-11-2015 19:52:52)

Re: Real-time 432hz Audio Auto-Pitching

Mystery wrote:

When returning FLOAT32, the sound is almost the same quality as the input. Very little distortion at all. If instead using INT32, then the sound feels a bit more "square", losing a bit of smoothness.

That's not surprising since 32bit floating point is typically considered higher quality than 32bit integer even though the former "only" has 24bits of precision.

30 (edited by Mystery 24-11-2015 19:58:09)

Re: Real-time 432hz Audio Auto-Pitching

I'll try LSMASHSource.

As for the video corruption, it happened when the video width was not mod 4. Adding a script to ensure it is mod 4 fixes it.

It's working "most of the time", but sometimes there's weird issues like the video restarting at the beginning in the middle of playback. Perhaps LSMASHSource will work better.

and I do have LAV Filters installed

31 (edited by Mystery 25-11-2015 02:45:30)

Re: Real-time 432hz Audio Auto-Pitching

LSMASHSource is giving me an Access Violation Error on this video

Video: VP90 1920x1080 29.97fps [V: English [eng] (vp9 profile 0, yuv420p, 1920x1080) [default]]
Audio: AAC 44100Hz stereo [A: aac lc, 44100 Hz, stereo [default]]

Whereas FFmpegSource2 occasionally gives an error that causes MPC-HC to restart videos from the beginning; very occasional and random.

LWLibavVideoSource is working so far. Will test that one.

32

Re: Real-time 432hz Audio Auto-Pitching

recommend:

LoadPlugin("LSMASHSource.dll")
function LSMASHSourceVA(string src, bool "audio")
{
    audio = Default(audio, true)
    ext = RightStr(src, 3)
    v = ((ext=="mp4") || (ext=="mov")) ? LSMASHVideoSource(src) : LWLibavVideoSource(src)
    clip = audio ? ((ext=="mp4") || (ext=="mov")) ? AudioDub(v,LSMASHAudioSource(src)) : AudioDub(v,LWLibavAudioSource(src)) : v
    return clip
}

file="Input.webm"
LSMASHSourceVA(file)

But "VP9+AAC"? webM ?
WebM normally use "VP9+Vorbis" or "VP9+Opus".

Re: Real-time 432hz Audio Auto-Pitching

On YouTube, AAC videos are 256kbps while Vorbis is only 128kbps. Many of my videos are in MKV format so that won't help much. Although I can apply that logic from my software while generating the script, at which point I can read the video format inside the file.

Re: Real-time 432hz Audio Auto-Pitching

Mystery wrote:

On YouTube, AAC videos are 256kbps

Only older videos; newer videos only have AAC at 128kbps at max.

Vorbis, like you said, also maxes out at 128kbps.

In such situations is best to either use Opus (assuming it's available for said video) or the 192kbps AAC track from the non-DASH fmt22 720p format.

Re: Real-time 432hz Audio Auto-Pitching

Nintendo Maniac 64 wrote:
Mystery wrote:

On YouTube, AAC videos are 256kbps

Only older videos; newer videos only have AAC at 128kbps at max.

Vorbis, like you said, also maxes out at 128kbps.

In such situations is best to either use Opus (assuming it's available for said video) or the 192kbps AAC track from the non-DASH fmt22 720p format.

Yes I look at what's available and get the best combination. That's why I often have MKV files with mixed content.

36 (edited by Mystery 27-11-2015 04:18:55)

Re: Real-time 432hz Audio Auto-Pitching

LSMASHVideoSource works with MP4 videos with "AVC" video codec, EXCEPT that it fails to play the videos I'm re-encoding myself with x264.exe. These videos are muxed back with their original MP2 audio into a MKV container. It seems to work with other MP4 files so far.

I also got a crash causing the video to reset. LWLibavVideoSource is the most reliable so far, for all types of videos.

Re: Real-time 432hz Audio Auto-Pitching

I found a page where it teaches you how to convert music to 432 hz: