Audio to video conversion issue

Here you can submit bugreports
baev12
Posts: 16
Joined: Wed Feb 14, 2024 7:43 am

Audio to video conversion issue

Post by baev12 »

Hi,

Recently we found out curious thing with audio to video conversion (version 1.4.0.7).

We have this chain to encode everything to XDCAM-HD:

Code: Select all

Folder -- A/V Media Decoder -- Safe Color Limiter -- Normalize -- XDCAM-HD encoder
When some audio file come to Folder (mp3, wav and every media without video track) final duration is longer then one in source file.

Some investigation in webinterface show us that every audio after A/V Media Decoder became "rawvideo" with "r_frame_rate" 24/1 so XDCAM-HD encoder take wrong duration before converting to i50.
For example source audio file has 288.287333 sec and after A/V Media Decoder AviSynth script calculate "rawvideo" with 300.333333 sec. So XDCAM-HD starts its job with "rawvideo" with 300.333333 s duration and "pcm_s16le" 288.287333 s duration.
Output pitch is ok but 12 sec longer then source (1/25 from source duration) with 12 sec of silence in the end.

In some scenarios it could lead to wrong pitch adjustment etc.

Thanks!
emcodem
Posts: 1754
Joined: Wed Sep 19, 2018 8:11 am

Re: Audio to video conversion issue

Post by emcodem »

Hi baev12,

the reason for the 24 fps is that an audio file of course has no fps at all and when converting to video, we must "assume" some framerate in order to determine if we need to apply fps conversion or not. Usually transcoders and analyzers do have a global "default fps" setting for this case but at the best of my knowledge we do not have this. Avisynth or Bestaudiosource plugin obviously decided to go with 24 fps by default and we do nothing to override this yet.
One way to work with this is to apply a the framerate value yourself by adding a custom avs plugin after A/V decoder and do something like:

Code: Select all

m_clip = assumefps(m_clip,25)
return m_clip
If your workflow should support more than audio only and maybe even different framerates, we need add a check if we face audio only source, e.g.

Code: Select all

m_clip.height == 16 ? assumefps(m_clip,25) : m_clip 
return m_clip
This means in words: if the video height is 16 we do assume 25 fps, if not, we do nothing (go on with m_clip as it is)

You can search for "ternary operator" if you want to know more about how this works, its like:
CHECK ? do_when_true : do_when_false

In above code, we check if the video height is 16, because this basically means that we face audio only source because A/V decoder will generate 16x16px video in case of audio only sources. Additionally i assume that you don't feed any real 16x16px content.


@admin to confirm if we really dont have a default video framerate setting currently. If we don't and we want to add some, then it is not only a doing for Avisynth but it would also apply to ffmpeg encoders.
emcodem, wrapping since 2009 you got the rhyme?
admin
Site Admin
Posts: 1681
Joined: Sat Feb 08, 2014 10:39 pm

Re: Audio to video conversion issue

Post by admin »

Hi beav12,

Emcodem is correct that there is no customizable global setting for frame rate. But FFAStrans has it's own internal parameter set to static 25 that's used when we have none. In your case you can use either what emcodem suggest or simply use the inbuilt "FPS Converter" filter:
assume_fps.png
assume_fps.png (6.4 KiB) Viewed 1402 times
And we can certainly discuss the option for overriding the global parameter for frame rate in a future release.

-steinar
baev12
Posts: 16
Joined: Wed Feb 14, 2024 7:43 am

Re: Audio to video conversion issue

Post by baev12 »

Hi emcodem,

Thank you for the advice, it works like a charm, because we have sidechain for "only audio" in our workflow (%i_v_streams% == 0) already.
Thank you once more for this very helpful software!
baev12
Posts: 16
Joined: Wed Feb 14, 2024 7:43 am

Re: Audio to video conversion issue

Post by baev12 »

Hi Steinar,

Thank you for your answer!
We tried to try to use "FPS Converter" filter but with no luck unfortunatly ((
admin wrote: Sun Sep 22, 2024 10:54 am simply use the inbuilt "FPS Converter" filter:
admin
Site Admin
Posts: 1681
Joined: Sat Feb 08, 2014 10:39 pm

Re: Audio to video conversion issue

Post by admin »

Baev12, did you try with the setting displayed in the screen shot I posted?

-steinar
baev12
Posts: 16
Joined: Wed Feb 14, 2024 7:43 am

Re: Audio to video conversion issue

Post by baev12 »

admin wrote: Sun Sep 22, 2024 6:09 pm did you try with the setting displayed in the screen shot I posted?
I think no, sorry.. Because i tryed yesterday again with your setings and it worked fine for the same workflow too. Thank you!

I see that avs script with this settings does almost the same:

Code: Select all

m_clip = AssumeFPS(m_clip, 25, sync_audio = true).ResampleAudio(48000)
Return m_clip
emcodem
Posts: 1754
Joined: Wed Sep 19, 2018 8:11 am

Re: Audio to video conversion issue

Post by emcodem »

Hehe there are multiple ways that lead to the same goal :D
You want one using s_options? :geek: :lol:
emcodem, wrapping since 2009 you got the rhyme?
baev12
Posts: 16
Joined: Wed Feb 14, 2024 7:43 am

Re: Audio to video conversion issue

Post by baev12 »

emcodem wrote: Wed Sep 25, 2024 8:39 am Hehe there are multiple ways that lead to the same goal :D
You want one using s_options? :geek: :lol:
YESS! Curious! :D
emcodem
Posts: 1754
Joined: Wed Sep 19, 2018 8:11 am

Re: Audio to video conversion issue

Post by emcodem »

Thats very nerdy in deed ;-)

OK so here is how to override the input framerate by changing the internally calculated ffmpeg cmd:
1) use s_options to retrieve the internal encode cmd
2) remove -r 24 completely from the cmd
3) before the first input "-i", insert -r 25 to make ffmpeg assume this framerate


Enjoy 8-) But do such stuff at your own risk ;)
emcodem_s_options_defaultfrate.json
(7.16 KiB) Downloaded 62 times
emcodem, wrapping since 2009 you got the rhyme?
Post Reply