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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 8th April 2024, 08:47   #1581  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,998
v1194 seems work now with wav files.

BTW LSMASHAudioSource don't work for all raw audio, for instance raw eac3 or aac can't be read. Use only for "MP4, MOV, [ISO Base Media] and its derived file formats."

Use always LWLibavAudioSource to decode audio.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 10th April 2024, 11:43   #1582  |  Link
rgr
Registered User
 
Join Date: Jun 2022
Posts: 62
Quote:
Originally Posted by Selur View Post
@rgr: you might want your source, since that does seem to work fine here.
??? I don't understand.
rgr is offline   Reply With Quote
Old 10th April 2024, 14:02   #1583  |  Link
rgr
Registered User
 
Join Date: Jun 2022
Posts: 62
Should I have double indexing?

Code:
Creating lwi index file 100%
Creating lwi index file 12%
Code:
v=LWLibavVideoSource("test.mp4",fpsnum=50)
AudioDub(v, LWLibavAudioSource("test.mp4"))
rgr is offline   Reply With Quote
Old 11th April 2024, 04:26   #1584  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,344
Quote:
you might want your source, since that does seem to work fine here
=>
you might want to share your source, since that does seem to work fine here
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 11th April 2024, 06:47   #1585  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,958
Yes, if you index the video and then the audio, first it does the video, then it does the audio, hence you see two lines.
If you look at the lwi file, it gets bigger as it gets updated.
Once it's done, it won't index it again.

By the way, if you wanna see instances in which it may index things twice by mistake (not this case) you can just stare at the lwi index. If it gets overwritten and shrinks in size before raising again then something is wrong, but if it just grows then everything is fine.
In this case I'm sure it just grows as you're indexing the audio too, so everything is fine.
FranceBB is offline   Reply With Quote
Old 11th April 2024, 08:28   #1586  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 1,599
I am developing a snippet to automate audio decoding across a choice of audio decoders, here to control DRC (lower, deactivate/discard, invert) for decoding purposes.
Test source is a BD .m2ts with Track 1: 2.0 .ac3 + Track 2: 5.1 .dts.
Manually giving "5.1"or "0x3f" or "FL+FR+FC+LFE+SL+SR" decodes nicely, but I need to leave the channel layout default to LWLibavAudioSource, because the script can not know whats inside the source.
"Apply" needs to hand over all parameters up to the wanted one (drc_scale) in sequence. All the other parameters seem to work, so I can hand these over.
Now layout is parsed before drc_scale, so I am searching for the LWLibavAudioSource default layout parameter to hand this over too.
The 1194 readme says "", but this won't give any audio. "-1" does not and "0" does not and "0x0" does not help either. (BTW, bool indexingpr = true is missing in readme example line, but listed in explanations.)
Code:
#...we assume last() containing video already
audsrc="LWLibavAudioSource" #Asd-g versions only, here 1194
Libavaudtrk=2 #int stream_index = -1 #-1: default stream
Libavaudcache=true #bool cache = true
Libavaudcachefile=String(audfolder)+String(audfile)+String(audpid)+String(audext)+".lwi"#string cachefile = source +".lwi"
Libavaudavsync=false #bool av_sync = false
Libavaudlayout=""#"5.1"#"0x3f"#"FL+FR+FC+LFE+SL+SR" #string layout = ""  | CN ? No Audio |  5.1 -> "5.1" or "FL+FR+FC+LFE+SL+SR" or "0x3f"
Libavaudrate=0 #int rate = 0
Libavauddecoder="" #string decoder = ""
Libavaudffloglevel=0 #int ff_loglevel = 0
Libavaudcachedir="" #string cachedir = ""
Libavindexingpr=true #bool indexingpr = true
Libavauddrcscale=0.0 #float drc_scale = 1.0 #0.0 deactivates DRC, -values invert the DRC processing
Libavaudffopts="" #string ff_options = ""
Exist(String(avfolder)+String(avfile0)+String(avext0)) ? Apply(vidsrc,String(avfolder)+String(avfile0)+String(avext0))\
: Assert(false, "! NO SUCH AV FILE -> " + String(avfolder)+String(avfile0)+String(avext0) + "<- NO SUCH AV FILE !")
try {AudioDub(last,Apply(audsrc,String(audfolder)+String(audfile)+String(audpid)+String(audext),Libavaudtrk,Libavaudcache,Libavaudcachefile,Libavaudavsync,Libavaudlayout,Libavaudrate,Libavauddecoder,Libavaudffloglevel,Libavaudcachedir,Libavindexingpr,Libavauddrcscale,Libavaudffopts))}
catch (err) {last}
If I comment the try/catch lines out and run only
Code:
AudioDub(last,Apply(audsrc,String(audfolder)+String(audfile)+String(audpid)+String(audext),Libavaudtrk,Libavaudcache,Libavaudcachefile,Libavaudavsync,Libavaudlayout,Libavaudrate,Libavauddecoder,Libavaudffloglevel,Libavaudcachedir,Libavindexingpr,Libavauddrcscale,Libavaudffopts))
I get: "LWLibavAudioSource: Failed to open resampler."

Asd-g, what do I have to pass as default here ? Or is it a bug ?
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."

Last edited by Emulgator; 12th April 2024 at 16:39.
Emulgator is offline   Reply With Quote
Old 11th April 2024, 10:55   #1587  |  Link
rgr
Registered User
 
Join Date: Jun 2022
Posts: 62
Quote:
Originally Posted by Selur View Post
=>
you might want to share your source, since that does seem to work fine here
Yes of course. But it's private, so I can only send it to the plugin author.
rgr is offline   Reply With Quote
Old 11th April 2024, 10:57   #1588  |  Link
rgr
Registered User
 
Join Date: Jun 2022
Posts: 62
Quote:
Originally Posted by FranceBB View Post
Yes, if you index the video and then the audio, first it does the video, then it does the audio, hence you see two lines.
If you look at the lwi file, it gets bigger as it gets updated.
Once it's done, it won't index it again.
Thanks.
So it would be good to introduce the "LWLibavSource" command like ffms2 or BS
rgr is offline   Reply With Quote
Old 12th April 2024, 16:52   #1589  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,855
Quote:
Originally Posted by rgr View Post
Thanks.
So it would be good to introduce the "LWLibavSource" command like ffms2 or BS
I've been meaning to update this function for a long time, probably years, so it'll work with the latest L-SMASH Source.
I've only given it a quick check. It should be fine, but let me know if you find any issues.

Code:
# ===============================================================================
#            LibavSource2
# ===============================================================================
#
#  Similar to the original LibavSource2, but audio is enabled by default.
#  Both video and audio can be disabled.
#  Audio-only and video-only files can be opened without first having to
#  disable the audio or video accordingly to prevent an error message.
#
# ===============================================================================

function LibavSource2(string Source, int "VTrack", int "ATrack", int "Threads", \
bool "Cache", string "CacheFile", int "Seek_Mode", int "Seek_Threshold", bool "DR", \
int "FPSNum", int "FPSDen", bool "Repeat", int "Dominance", string "Format", \
string "VDecoder", string "ADecoder", int "Prefer_HW", int "FF_LogLevel", \
string "CacheDir", string "FF_Options", bool "AV_Sync", string "Layout", int "Rate") {

VTrack = default(VTrack, -1)
ATrack = default(ATrack, -1)
Threads = default(Threads, 0)
Cache = default(Cache, true)
CacheFile = default(CacheFile, Source + ".lwi")
Seek_Mode = default(Seek_Mode, 0)
Seek_Threshold = default(Seek_Threshold, 10)
DR = default(DR, false)
FPSNum = default(FPSNum, 0)
FPSDen = default(FPSDen,  1)
Repeat = default(Repeat, false)
Dominance = default(Dominance, 0)
Format = default(Format, "")
VDecoder = default(VDecoder, "")
ADecoder = default(ADecoder, "")
Prefer_HW = default(Prefer_HW, 0)
FF_LogLevel = default(FF_LogLevel, 0)
CacheDir = default(CacheDir, "")
FF_Options = default(FF_Options, "")
AV_Sync = default(AV_Sync, false)

VideoEnabled = (VTrack > -2)
AudioEnabled = (ATrack > -2)
VideoNotFound = false
AudioNotFound = false
IsVideo = false
IsAudio = false
LS2 = " LibavSource2 " + chr(10)
VideoError = ""
AudioError = ""

assert(VideoEnabled || AudioEnabled, LS2 + " Both video and audio are disabled " + chr(10))

# -------------------------------------------------------------------------------

AudioEnabled ? Eval("""

try{

Audio = LWLibavAudioSource(Source, stream_index=ATrack, \
cache=Cache, cachefile=CacheFile, av_sync=AV_Sync, layout=Layout, rate=Rate, \
decoder=ADecoder, ff_loglevel=FF_LogLevel, cachedir=CacheDir, ff_options=FF_Options)

IsAudio = true

}catch(err_msg){

AudioError = " LWLibavAudioSource " + chr(10) + " " + err_msg + " " + chr(10)
AudioNotFound = (FindStr(LCase(err_msg), "failed to get the audio track") > 0)
NotAudio = (FindStr(LCase(err_msg), "not an audio track") > 0)
assert(!NotAudio, LS2 + " The specified audio track is not an audio track " + chr(10))
assert(AudioNotFound || NotAudio, AudioError)

} """) : nop()

# -------------------------------------------------------------------------------

VideoEnabled ? Eval("""

try{

Video = LWLibavVideoSource(Source, stream_index=VTrack, threads=Threads, \
cache=Cache, cachefile=CacheFile, seek_mode=Seek_Mode, seek_threshold=Seek_Threshold, dr=DR, \
fpsnum=FPSNum, fpsden=FPSDen, repeat=Repeat, dominance=Dominance, format=Format, decoder=VDecoder, \
prefer_hw=Prefer_HW, ff_loglevel=FF_LogLevel, cachedir=CacheDir, ff_options=FF_Options)

IsVideo = true

}catch(err_msg){

VideoError = " LWLibavVideoSource " + chr(10) + " " + err_msg + " " + chr(10)
VideoNotFound = (FindStr(LCase(err_msg), "failed to get the video track") > 0)
NotVideo = (FindStr(LCase(err_msg), "not a video track") > 0)
assert(!NotVideo, LS2 + " The specified video track is not a video track " + chr(10))
assert(VideoNotFound || NotVideo, VideoError)

} """) : nop()

# -------------------------------------------------------------------------------

assert(!VideoNotFound || AudioEnabled, LS2 + " No video found & audio is disabled " + chr(10))
assert(!AudioNotFound || VideoEnabled, LS2 + " No audio found & video is disabled " + chr(10))

IsAudio = AudioEnabled && IsAudio
IsVideo = VideoEnabled && IsVideo

return IsAudio && IsVideo ? AudioDub(Video, Audio) : IsAudio ? Audio : Video }

# ===============================================================================
Edit: LSMASHSource2 version. Tested even less.

Code:
# ===============================================================================
#            LSMASHSource2
# ===============================================================================
#
#  Similar to the original LSMASHSource2, but audio is enabled by default.
#  Both video and audio can be disabled.
#  Audio-only and video-only files can be opened without first having to
#  disable the audio or video accordingly to prevent an error message.
#
# ===============================================================================

function LSMASHSource2(string Source, int "VTrack", int "ATrack", int "Threads", \
int "Seek_Mode", int "Seek_Threshold", bool "DR", int "FPSNum", int "FPSDen", \
string "Format", string "VDecoder", string "ADecoder", int "Prefer_HW", \
int "FF_LogLevel", string "FF_Options", bool "Skip_Priming", string "Layout", int "Rate") {

VTrack = default(VTrack, -1)
VTrack = (VTrack == -1) ? 0 : VTrack
ATrack = default(ATrack, -1)
ATrack = (ATrack == -1) ? 0 : ATrack
Threads = default(Threads, 0)
Seek_Mode = default(Seek_Mode, 0)
Seek_Threshold = default(Seek_Threshold, 10)
DR = default(DR, false)
FPSNum = default(FPSNum, 0)
FPSDen = default(FPSDen,  1)
Format = default(Format, "")
VDecoder = default(VDecoder, "")
ADecoder = default(ADecoder, "")
Prefer_HW = default(Prefer_HW, 0)
FF_LogLevel = default(FF_LogLevel, 0)
FF_Options = default(FF_Options, "")
Skip_Priming = default(Skip_Priming, true)

VideoEnabled = (VTrack > -2)
AudioEnabled = (ATrack > -2)
VideoNotFound = false
AudioNotFound = false
IsVideo = false
IsAudio = false
LS2 = " LSMASHSource2 " + chr(10)
VideoError = ""
AudioError = ""

assert(VideoEnabled || AudioEnabled, LS2 + " Both video and audio are disabled " + chr(10))

# -------------------------------------------------------------------------------

AudioEnabled ? Eval("""

try{

Audio = LSMASHAudioSource(Source, track=ATrack, skip_priming=Skip_Priming, \
layout=Layout, rate=Rate, decoder=ADecoder, ff_loglevel=FF_LogLevel, ff_options=FF_Options)

IsAudio = true

}catch(err_msg){

AudioError = " LSMASHAudioSource " + chr(10) + " " + err_msg + " " + chr(10)
AudioNotFound = (FindStr(LCase(err_msg), "failed to find audio track") > 0)
NotAudio = (FindStr(LCase(err_msg), "not an audio track") > 0)
assert(!NotAudio, LS2 + " The specified audio track is not an audio track " + chr(10))
assert(AudioNotFound || NotAudio, AudioError)

} """) : nop()

# -------------------------------------------------------------------------------

VideoEnabled ? Eval("""

try{

Video = LSMASHVideoSource(Source, track=VTrack, threads=Threads, seek_mode=Seek_Mode, \
seek_threshold=Seek_Threshold, dr=DR, fpsnum=FPSNum, fpsden=FPSDen, format=Format, \
decoder=VDecoder, prefer_hw=Prefer_HW, ff_loglevel=FF_LogLevel, ff_options=FF_Options)

IsVideo = true

}catch(err_msg){

VideoError = " LSMASHVideoSource " + chr(10) + " " + err_msg + " " + chr(10)
VideoNotFound = (FindStr(LCase(err_msg), "failed to find video track") > 0)
NotVideo = (FindStr(LCase(err_msg), "not a video track") > 0)
assert(!NotVideo, LS2 + " The specified video track is not a video track " + chr(10))
assert(VideoNotFound || NotVideo, VideoError)

} """) : nop()

# -------------------------------------------------------------------------------

assert(!VideoNotFound || AudioEnabled, LS2 + " No video found & audio is disabled " + chr(10))
assert(!AudioNotFound || VideoEnabled, LS2 + " No audio found & video is disabled " + chr(10))

IsAudio = AudioEnabled && IsAudio
IsVideo = VideoEnabled && IsVideo

return IsAudio && IsVideo ? AudioDub(Video, Audio) : IsAudio ? Audio : Video }

# ===============================================================================

Last edited by hello_hello; 12th April 2024 at 17:29.
hello_hello is offline   Reply With Quote
Old 30th April 2024, 15:47   #1590  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 635
I noticed there is an ff_options argument... is it possible to specify an audio track language with it? Something like...

Code:
LWLibavAudioSource(file, ff_options="map=0:a:m:language:eng")
flossy_cake is offline   Reply With Quote
Old 1st May 2024, 00:30   #1591  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,998
Quote:
Originally Posted by flossy_cake View Post
...is it possible to specify an audio track language with it?
Inside AviSynth the audio can't have a property like language.
Your ffmpeg parameter is for a container like mkv, not for an uncompresed audio file like LWLibavAudioSource output.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 1st May 2024, 18:46   #1592  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 635
Quote:
Originally Posted by tebasuna51 View Post
Your ffmpeg parameter is for a container like mkv, not for an uncompresed audio file like LWLibavAudioSource output.
Yep so in this case the first argument "file" points to an mkv file.
flossy_cake is offline   Reply With Quote
Old 1st May 2024, 19:33   #1593  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,998
Quote:
Originally Posted by flossy_cake View Post
Yep so in this case the first argument "file" points to an mkv file.
No mather the input file the LWLibavAudioSource output is uncompressed audio without a language property, and specify the language is usseless to select the track inside the mkv.
__________________
BeHappy, AviSynth audio transcoder.

Last edited by tebasuna51; 1st May 2024 at 19:37.
tebasuna51 is offline   Reply With Quote
Old 1st May 2024, 21:44   #1594  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 635
Quote:
Originally Posted by tebasuna51 View Post
No mather the input file the LWLibavAudioSource output is uncompressed audio without a language property, and specify the language is usseless to select the track inside the mkv.
I think there is a misunderstanding here - I was trying to tell LWLibavAudioSource to select the audio track to decode based on language instead of track number (stream_index). As far as I can tell the ff_options argument allows us to set some decoder settings which could potentially include language.

The reason I want to do this is because I have a large number of files in a series where the english track number changes from file to file and it's a pain to have to check them all manually one by one to set stream_index to the right number for each one.

I'm currently reducing the workload of this task by using a custom MediaInfo view so that it prints out the english track number of all files at a glance and then manually tagging the file names with [audio_track=n] and then inside my script if(FindStr(sourcefile, "[audio_track=n]" != 0)) setting stream_index based on the result of that.
flossy_cake is offline   Reply With Quote
Old 1st May 2024, 22:38   #1595  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,428
It would have been easier to just point at the documentation:
Code:
 + ff_options (default : "")
          Set the decoder options in FFmpeg.
          The format is `key=value` separated by " ". (e.g. "drc_scale=0 auto_convert=0")
-map is not a decoder option, so therefore no, it won't work. The examples even show this, drc_scale is an option specific to only certain decoders (like ac3, but not aac, for example), when you call up the options list with ffmpeg -h decoder=<format-name>.

For clarity, I would suggest that ff_options be renamed to ff_decoder_options to make that explicit (especially since it would be theoretically possible to have ff_demuxer_options as well, unless the two are already rolled into ff_options and the documentation just doesn't explain that).
qyot27 is offline   Reply With Quote
Old 2nd May 2024, 14:03   #1596  |  Link
Music Fan
Registered User
 
Join Date: May 2009
Location: Belgium
Posts: 1,745
Quote:
Originally Posted by flossy_cake View Post
The reason I want to do this is because I have a large number of files in a series where the english track number changes from file to file and it's a pain to have to check them all manually one by one to set stream_index to the right number for each one.
You could also remux all your files with ffmpeg keeping only the english track*, then re-encode them.
* with this :
Code:
-map 0:a:m:language:en: -c:a copy
Music Fan is offline   Reply With Quote
Old 3rd May 2024, 17:58   #1597  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 635
Quote:
Originally Posted by Music Fan View Post
You could also remux all your files with ffmpeg keeping only the english track*, then re-encode them.
* with this :
Code:
-map 0:a:m:language:en: -c:a copy
Thanks and yes I know and I was gonna do it in mkvtoolnix as well because I get better media player compatibility than ffmpeg but in the end it was a lot of work and was faster to just tag the files and I was also a bit worried remuxing might affect the audio sync somehow so I just didn't want potential trouble over such a large number of files.
flossy_cake is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:13.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.