Log in

View Full Version : Take Audio from Video without going through the video?


zerowalker
15th February 2016, 14:50
I wonder if it's possible to load Audio from a Video file without actually going through the video.

As i think that's what it does anyway, so if i want to mix audios and stuff it takes forever if the audio is in a video, and i guess it's cause it loads through the entire file as it goes.

Perhaps there is nothing to be done about it, but one would think that as it's interleaved it could just Not read every other (or whatever) byte in order to only get the audio.
But perhaps it does that and it's slow anyway, not sure how this all works.

Thanks:)

raffriff42
15th February 2016, 15:16
Doesn't this work? ffmpeg -i video.xyz -vn -c:a copy audio.wav
Set output extension appropriately for the audio type, ie AAC→m4a, PCM→wav etc.

If you want a GUI, try XMedia in audio out, copy mode - it's blazingly fast. You can start with this tutorial:
Losslessly Cutting Short Video Samples - Tutorial Thread [XMedia Recode]
http://forum.doom9.org/showthread.php?t=172557
And make changes as needed.

The key is to copy, not re-encode.

zerowalker
15th February 2016, 16:00
Will try, but i am using Avisynth so i would usually assume that it's that layer that needs to be changed. Though i am using ffmpeg on a script and a file, and the script has video and audio (but it's the audio i take).

EDIT:

Okay don't think it works as i noticed it had a global impact instead of a single video where Mapping is the dominant force.

Basically i do something like.

ffmpeg -i "somevideo.mkv" -i "somevideowithaudio.avs" -c:v copy -c:a libopus -b:a 512000 "outpufile.mkv".
In my case it will just take the video from source 1 and audio from source 2 automatically.

vivan
15th February 2016, 18:25
Perhaps there is nothing to be done about it, but one would think that as it's interleaved it could just Not read every other (or whatever) byte in order to only get the audio.
But perhaps it does that and it's slow anyway, not sure how this all works.Reading and decoding audio is a very fast process. Decoding video is not.
Have you tried to use audio decoder, like LWLibavAudioSource?

creaothceann
15th February 2016, 18:53
DirectShowSource(file, video=false)

zerowalker
16th February 2016, 12:46
DirectShowSource had same effect as Avisource, it's very slow, tried changing seek and seekzero just in case.
LWLibavAudioSource might work is the same basically.

Though thing is, it's not Decoding the video as far as i can tell, it's reading the entire file.
And the file is like 167gb. And obviously like 90% of that is the Audio.
Perhaps the issue is cause it's interleaved, maybe non-interleaved can prevent this?

poisondeathray
16th February 2016, 17:12
What other audio filters or manipulations? (ie. why are you using avisynth?) Post your full script

zerowalker
16th February 2016, 20:27
Why i am using a script is simply cause the Audio is in the AVI file, and i Trim the video.
I could of course extract the audio and trim a blankclip, but i wanted to be able to Not do that extra step, as then i could just go the normal route anyway as it takes the same amount of time to read as to extract:)

So that's all, i want to read audio from an AVI file without going through the entire file.
But i think it has to do with it being interleaved.

tebasuna51
16th February 2016, 22:28
Why i am using a script is simply cause the Audio is in the AVI file, and i Trim the video

You can extract the audio from avi with Virtualdub or AVIMuxGUI.

After you can split the audio with BeSplit.

MeGUI have a Tools -> Audio Cutter, BeSplit based, than can do the job with a .clt file created with Tools -> Avs Cuter (with the frames desired from the video).

raffriff42
16th February 2016, 22:31
But i think it has to do with it being interleaved.I think not. Seeking for an "audio" frame requires first seeking for a "video" frame (I think; and depending on container type), and with a long-GOP video (which is what I assume you have?) it requires seeking to the nearest prior I-frame and walking forwards to the frame you want (more or less). That's what's taking the time. With an audio-only track you should avoid that problem. If you want to trim audio, try AudioTrim (http://avisynth.nl/index.php/AudioTrim).

tebasuna51
17th February 2016, 12:01
If you want to trim audio, try AudioTrim (http://avisynth.nl/index.php/AudioTrim).

Yep.

1) AudioTrim (AviSynth)
- Quick search, even more with CBR audio (mp3, ac3 from avi).
- Audio decode, and you need recode at end.
- Good precission because cut PCM samples (0.02 ms)

2) BeSplit (command line)
- Also quick search.
- Don't need decode and recode.
- Less precission, cut at frame boundaries (32 ms in ac3, 24 ms in mp3)
Recommended if avi audio is uncompressed PCM (same precission than AviSynth).

zerowalker
17th February 2016, 14:48
I think not. Seeking for an "audio" frame requires first seeking for a "video" frame (I think; and depending on container type), and with a long-GOP video (which is what I assume you have?) it requires seeking to the nearest prior I-frame and walking forwards to the frame you want (more or less). That's what's taking the time. With an audio-only track you should avoid that problem. If you want to trim audio, try AudioTrim (http://avisynth.nl/index.php/AudioTrim).

Yeah assumed it worked something like this.
Though i was under the assumption that non-interleaved AVI bypassed this.

@tebasuna51

The problem isn't audio itself, i know i can cut it etc.
The thing i wanted to do was prevent extracting the audio if possible.
Just cause it takes time, and i wanted to simple one-way solution so to speak.

But it seems it's not possible with AVI sadly.
Appreciate all the suggestions though, was more ways of cutting Audio than i knew, Thanks:)