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. |
18th July 2020, 23:29 | #1 | Link |
Registered User
Join Date: Sep 2017
Posts: 37
|
How to extract the original audio from the video?
Hello brothers, how are you?
I have a problem and I need your help. I use MeGUI to encode my modified videos with the AviSynth scripts. Before when I opened the videos in MeGUI it automatically extracted the original audios from the videos. Now the MeGUI doesn't do that most. So, I wanted to use the original audio of the video in the LPCM format because it has more quality than when I convert the MeGUI to AC3. So I would like to know from you, if there is anything I am doing wrong in my AviSynth script that is no longer extracting the original audio in LPCM? How can I solve this? I am very grateful if anyone can help me with this. xD |
18th July 2020, 23:56 | #2 | Link | |
Broadcast Encoder
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,905
|
Quote:
No, seriously, post your script and we'll be able to help you. For the records, since you wanna just encode the audio in PCM using Avisynth, I guess you're gonna be fine if you use AVS in ffmpeg like so: Code:
FFMpegSource2("your_super_uber_video.avi", atrack=-1) Code:
ffmpeg.exe -i "AVS Script.avs" -c:a pcm_s24le -ar 48000 -f wav "audio.wav" Code:
ffmpeg.exe -i "AVS Script.avs" -c:a pcm_s24le -ar 48000 -af loudnorm=I=-24:LRA=5:tp=-2 -f wav "audio.wav" As to MeGUI... well... if you can, you should really try to switch to the command line and use BATs to encode with your favorite encoder directly... Side Note: Am I crazy? Why am I indexing the video when he just wants the audio? Well, Avisynth won't react well if you're indexing audio only and will complain about a missing video. Sure, you could just create a fake blank video with BlankClip() and use AudioDub() to merge your fake video and your audio, but I don't really wanna mess up with it 'cause the length would have to be the same and it's 1AM on a Saturday night... (Not that I have to go anywhere since there's a global pandemic, but still...) Cheers, Frank Last edited by FranceBB; 19th July 2020 at 00:05. |
|
19th July 2020, 00:37 | #3 | Link |
...?
Join Date: Nov 2005
Location: Florida
Posts: 1,420
|
Actually, in this case I'd cut out the AviSynth steps and just demux the audio using FFmpeg. -acodec copy, since if the audio in the original file is *not* already LPCM, decoding it to LPCM is just going to waste space (and if it's already in some compressed format and there aren't any operations to the video that would cause desync, you can just remux the original audio with the filtered video). You really only need to touch the audio if you *must* use a particular format to ensure it conforms to [insert X standard here], or if you're doing stuff like splices that would affect the A/V sync.
|
19th July 2020, 05:49 | #4 | Link | |
Registered User
Join Date: Sep 2017
Posts: 37
|
Quote:
Sorry. I don't really understand much, I'm new to it. So this is my script: Code:
FFVideoSource ("video.avi").ConvertToYV12(interlaced=true).ColorMatrix (Mode="Rec.709->Rec.601") TFM() QTGMC(Preset="Placebo") Vinverse () SMDegrain (tr = 2,thsad = 400, lsb=true, chroma=true) Spline64Resize (1440, 1080, 1, 11, -8, -9) Thanks! |
|
19th July 2020, 05:51 | #5 | Link | |
Registered User
Join Date: Sep 2017
Posts: 37
|
Quote:
|
|
19th July 2020, 09:15 | #6 | Link | ||
Broadcast Encoder
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,905
|
Quote:
Code:
ffmpeg.exe -i "source.avi" -acodec copy "audio.wav" This will literally demux your PCM audio file from your container and mux it alone in a .wav. The other script I suggested before (namely using Avisynth to feed ffmpeg) will not work in your case 'cause you're using FFVideoSource instead of FFMpegSource2 which means that you're effectively indexing the video but not the audio. You can also use something like: Code:
video=FFVideoSource("video.avi") audio=FFAudioSource("video.avi") AudioDub(video, audio) Now, on to your script: Quote:
First of all, why are you using TFM as default, alone, before QTGMC? Secondly, although I don't use SMDegrain, I immediately spotted "lsb=true" which means that you're telling the filter to be working in 16bit stacked with MSB and LSB stacked one on top of the other (also called Double Height), however your source is definitely planar (and probably even 8bit), so why? Lastly, why are you cropping and resizing to FULL HD anamorphic NTSC? Like, the last time I saw a 1440x1080 was when I capped a .ts file from a terrestrial (Digital TV) NTSC channel... What are you trying to achieve...? And last but not least, can we really use colormatrix on interlaced materials? O_o If I may, I would do the following: Code:
#Indexing video=FFVideoSource("video.avi") audio=FFAudioSource("video.avi") AudioDub(video, audio) #Converting to 4:2:0 planar ConvertToYV12(interlaced=true) #Bobbing QTGMC(Preset="Placebo") #Matrix Conversion ColorMatrix (Mode="Rec.709->Rec.601") #DeCombing Vinverse() #From 8bit Planar to 16bit stacked Dither_convert_8_to_16() #Filtering with 16bit stacked precision SMDegrain (tr = 2,thsad = 400, lsb_in=true, lsb_out=true, chroma=true) #From 16bit stacked to 16bit planar ConvertFromStacked() #Dithering down to 8bit planar ConvertBits(bits=8, dither=1) |
||
19th July 2020, 10:09 | #7 | Link |
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,915
|
The command line to extract your pcm audio is:
"C:\Portable\megui\tools\ffmpeg\ffmpeg.exe" -i "un_pcm.avi" -map 0:1 -acodec copy "un_pcm.avi_1.wav" or "C:\Portable\megui\tools\ffmpeg\ffmpeg.exe" -i "un_pcm.avi" -vn -acodec copy "un_pcm.avi_1.wav" But the best option is use MeGUI: Input tab -> Audio encoding Track 1 -> Audio Input -> your avi Encoder sttings -> Flac -> Config -> Preferred Decoder: LWLibavAudioSource Rest off options unchecked or 'Keep Original...' Smallest file, slow encode And you can mux the flac in mkv with less size (~50%) but the same quality of your LPCM or "C:\Portable\megui\tools\ffmpeg\ffmpeg.exe" -i "un_pcm.avi" -vn -acodec flac "un_pcm.avi_1.flac"
__________________
BeHappy, AviSynth audio transcoder. Last edited by tebasuna51; 19th July 2020 at 11:15. Reason: add info |
19th July 2020, 10:29 | #8 | Link | ||
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,915
|
Quote:
Quote:
To recode video and audio and after remux is better separated avs's.
__________________
BeHappy, AviSynth audio transcoder. Last edited by tebasuna51; 19th July 2020 at 11:08. Reason: add info |
||
19th July 2020, 16:21 | #9 | Link |
Registered User
Join Date: Sep 2017
Posts: 37
|
Hey brothers, thank you so much.
Let's divide it all into parts now, so: Code:
ffmpeg.exe -i "source.avi" -acodec copy "audio.wav" Now in my script: Code:
First of all, why are you using TFM as default, alone, before QTGMC? Code:
Secondly, although I don't use SMDegrain, I immediately spotted "lsb=true" which means that you're telling the filter to be working in 16bit stacked with MSB and LSB stacked one on top of the other (also called Double Height), however your source is definitely planar (and probably even 8bit), so why? not work with this in false. That is the reason for choosing it in true. Code:
Lastly, why are you cropping and resizing to FULL HD anamorphic NTSC? Like, the last time I saw a 1440x1080 was when I capped a .ts file from a terrestrial (Digital TV) NTSC channel... What are you trying to achieve...? And last but not least, can we really use colormatrix on interlaced materials? O_o the image. And at the end I add "AddBorders (240,0,240,0)" to make the video with the aspect ratio 1920x1080 to watch on TV. I use to upscale non-anime videos, music video clips that I like. That's all I understand so far, I'm sorry if something seems to be wrong, I'm still learning about everything and I would like to learn even more, which you guys teach me a lot here, so thank you so much for all your help and for donating some of the time of you to clear my doubts. This script so far seem to work well for me, it gives me a very good sharpness, which I like a lot, without the video looking like blurry goo. I like to keep the details fine, making a light, discreet cleaning without losing quality or details. So I am very happy with all your help, it has helped me a lot. And there are still many things I would like to do how to example (I have videos that I need to cut the begginning of this or the end of, but I don't know how to cut the audio to synchronize, keeping the original audio, without having to convert it.), but I know it takes time, and sometimes I'm ashamed to come here for help, because I'm not good enough yet to be able to collaborate with anything that can help you yet. Thank you qyot24, thank you FranceBB, thnak you tebasuna51, I will try to test each of your tips. Thank you. So that's basically it. Sorry for the big text. Haha! Last edited by skywalker; 19th July 2020 at 16:47. |
Tags |
audio, audio extract, lpcm, original audio, pcm |
|
|