Insert Media after 10 sec

Questions and answers on how to get the most out of FFAStrans
authorleon
Posts: 108
Joined: Fri May 08, 2020 5:18 pm

Insert Media after 10 sec

Post by authorleon »

Hello all,

I have a strange request please.

Scenario:

I have a 2 minute video.
  • Would it be possible to insert media after 10 seconds
If the above is possible.

Would be possible to get a variable (number) and insert media after variable?

The variable could be obtained by extracting the last two digits of the video file or reading from a text file that has exactly the same filename as the video.

Thank you all
emcodem
Posts: 1656
Joined: Wed Sep 19, 2018 8:11 am

Re: Insert Media after 10 sec

Post by emcodem »

Sure, I'll show you 2 different approaches.

1) custom avisynth
The only thing that needs some attention is the audio: The Audio of the inserted clip is currently set to be silent.
It would be a little work to come up with something that grabs the audios from the clip to be inserted. If you need that, tell me how many channels your clip has (or if you cannot guarantee the number of channels)

2) generate ffconcat list
This approach requires you to have the clip you want to insert in the SAME DIRECTORY as your source file is. Also it will write a text file back to the source's directory. I am not 100% sure if this approach is always frame accurate but if it works for you...

Both approaches are done quick and dirty, i guess the last frame of the first clips mark out will be shown after the inserted clip again, but not sure about that.
emcodem_Insert_Clip_At_Position_2.json
(8.97 KiB) Downloaded 212 times
Sure above are not the only possible ways but the quickest hehe.
Let me know all your doubts :D
emcodem, wrapping since 2009 you got the rhyme?
authorleon
Posts: 108
Joined: Fri May 08, 2020 5:18 pm

Re: Insert Media after 10 sec

Post by authorleon »

emcodem wrote: Tue Feb 02, 2021 4:01 pm Sure, I'll show you 2 different approaches.

1) custom avisynth
The only thing that needs some attention is the audio: The Audio of the inserted clip is currently set to be silent.
It would be a little work to come up with something that grabs the audios from the clip to be inserted. If you need that, tell me how many channels your clip has (or if you cannot guarantee the number of channels)

2) generate ffconcat list
This approach requires you to have the clip you want to insert in the SAME DIRECTORY as your source file is. Also it will write a text file back to the source's directory. I am not 100% sure if this approach is always frame accurate but if it works for you...

Both approaches are done quick and dirty, i guess the last frame of the first clips mark out will be shown after the inserted clip again, but not sure about that.

emcodem_Insert_Clip_At_Position_2.json

Sure above are not the only possible ways but the quickest hehe.
Let me know all your doubts :D
1. Thank you very much for the quick reply
2. The intermedia will only have a standard two channel. That would be great if that's feasible.
3. With all this could work, it is time for me to donate somewhere. Please tell me how
4. If you are looking for beta testers. I think I could be the ideal person as I specialise Video/serve stuff.

Please let me know. All this good work you have done must be recognised!!

I will testing this out for sure...

Image

Thank you
emcodem
Posts: 1656
Joined: Wed Sep 19, 2018 8:11 am

Re: Insert Media after 10 sec

Post by emcodem »

Ah no worries, you have been so patient and kind so i really enjoy helping you out if i can. Donating is for sure always a good idea ;-) Just hit the donate button on ffastrans.com ;-)
Please be aware that i uploaded an updated version in my first reply here, so you need to re-download and also note that the only things you should change for starting is in the first and last nodes: populate and deliver. Then just submit some source file to the populate node or insert a watchfolder processor...

If nobody is faster, ill send you an Update for Support of 2 audios in the avisynth workflow tomorrow. The second one should work with Audio already
emcodem, wrapping since 2009 you got the rhyme?
authorleon
Posts: 108
Joined: Fri May 08, 2020 5:18 pm

Re: Insert Media after 10 sec

Post by authorleon »

Hello emcodem,

I have tested the system above and it does work, But the audio after the insert is delayed.

Thank you for this work.

If it is okay, I would like to work out the Scenario below. Now that I know it can be done I can set out a clear structure.

I think it is a very good idea to use a text file to hold the time required. This means there's a higher level of flexibility.

I have created a scenario below which I think is flexible for a lot of people.

Video File Name: VID001_I_Love_Cats_06.mxf
Text File Name: VID001_I_Love_Cats_06.txt

The video file name and the text file name must be the same except for the extension.

X:\Video System\Video In - Location of VID001_I_Love_Cats_06.mxf & VID001_I_Love_Cats_06.txt
X:\Video System\Video Out - Final location of the file
X:\Video System\Intros\Intro.mxf - Video inserted after x seconds
X:\Video System\Intros\Outro.mxf - Video inserted at the end
Variable X - The time from the txt file. In this case. 08

VID001_I_Love_Cats_06 + Intro.mxf + VID001_I_Love_Cats_06 + Outro.mxf

Thank you for this. The donations will be on the way for sure.

I have to say I had no idea that your system can do all of this. I am definitely going to learn more about it.
admin
Site Admin
Posts: 1669
Joined: Sat Feb 08, 2014 10:39 pm

Re: Insert Media after 10 sec

Post by admin »

Hi authorleon,

We could always use some good beta testers other than the ones that are in the FFAStrans team. Just send a mail to post@ffastrans.com and let us know a little more about your expertise and how you think you contribute as beta tester :-)

-steinar
emcodem
Posts: 1656
Joined: Wed Sep 19, 2018 8:11 am

Re: Insert Media after 10 sec

Post by emcodem »

Yeah you know, what ffastrans does is to allow you to automate existing nice programs like avisynth and ffmpeg easily. FFAStrans does a very good job but in the end the frame accuracy and such is just a matter of the executed tools. I cannot really think of anyhting you couldnt do in this area with ffastrans as long as you know the tools you want to automate good enough.

OK, i guess the "second" approach cannot really be frame accurate (at least not at non iframe only stuff). So lets stick with the first.

Again, you just configure the first and Last processors, all others should be left as they are. In the First Populate proc, take care that you set the duration of your Inserted clip in frames, if you don't i am sure you will have audio shift as you described it.

We need to use some "functions" here which allow quick calculation of stuff, e.g. filename .txt instead of .mxf and the timecode from your txt file in frames instead of seconds.
Also take note if you want to change anything: all is about getting the "INPOINT" in frames into the i_insertion_point_frames variable.

The Video resolution, framerate and audio samplerate of the inserted clip should match the ones of the source clip, otherwise we have again different troubles. If you need to support different framerates and audio samplerates at the input then let me know how broad the spectrum is.
emcodem_Insert_Clip_At_Position_3.json
(10.77 KiB) Downloaded 237 times
Btw, it would be good if you get in touch with variables and functions pretty soon, it might be dangerous to go into production with stuff that you don't really understand ;-)
emcodem, wrapping since 2009 you got the rhyme?
authorleon
Posts: 108
Joined: Fri May 08, 2020 5:18 pm

Re: Insert Media after 10 sec

Post by authorleon »

hello. Thank you for the fantastic work.

I will be in contact later on today, if not tomorrow for sure.

FYI I am using 1080p @ 50fps for everything. So there are no major conversions involved.

Thank you very much.

PS. I will be in contact with the admin.
authorleon
Posts: 108
Joined: Fri May 08, 2020 5:18 pm

Re: Insert Media after 10 sec

Post by authorleon »

Okay. I gave it a go:

I am getting this error:

Image

Here is the video format I am using:

Image

Thank you... I am testing out everything.

Ideally, I would just like to use MP4 format which I think is easier, but I could be wrong.
emcodem
Posts: 1656
Joined: Wed Sep 19, 2018 8:11 am

Re: Insert Media after 10 sec

Post by emcodem »

Yeah sorry, i should have mentioned:
1) you should start the WF by submitting only the video file. E.g. if you test in a watchfolder, exclude *.txt... the WF calculates the text files name from the video file name and waits 1 hour until it exists. Sure you could easily exchange this and submit the text file, then calculate the video's file name (if the extension of the video is always the same, e.g. *.mxf)
2) currently i assume that opener and closer have one audio track with stereo. If they have any other audio configuration it would fail.

The audio configuration of the "main" clip does not matter.

If you want to use opener and closer with mono tracks, e.g. XDCAMHD style, you can use this script in the "custom avisynth" processor:

Code: Select all

ffidxfile = "%s_job_work%\idx.idx"

#trim existing source, creating 2 clips: one up to the point of insert, the other one from the point of insert
clip1=Trim(m_clip, 0,%i_insertion_point_frames%)
clip3=Trim(m_clip, %i_insertion_point_frames%,0)


#generate silent audio for insertion clip
audio_null = BlankClip( length=251 ,width=1920, height=1080, color=$000000, channels=30, audio_rate=48000, fps=25)
#load Clip to insert
_audio_21 = FFAudioSource("%s_clip_to_insert%",1,cachefile=ffidxfile)
_audio_22 = FFAudioSource("%s_clip_to_insert%",2,cachefile=ffidxfile)
_audio_2 = MergeChannels(_audio_21,_audio_22)
_audio_2 = MergeChannels(_audio_2, audio_null)
_video_2 = FFVideoSource("%s_clip_to_insert%",cachefile=ffidxfile,seekmode=0)
clip2 = AudioDub(_video_2,_audio_2)

#load outro
audio_null = BlankClip( length=251 ,width=1920, height=1080, color=$000000, channels=30, audio_rate=48000, fps=25)
_audio_41 = FFAudioSource("%s_outro_locatoin%",1,cachefile=ffidxfile)
_audio_42 = FFAudioSource("%s_outro_locatoin%",2,cachefile=ffidxfile)
_audio_4 = MergeChannels(_audio_41, _audio_42)
_audio_4 = MergeChannels(_audio_4, audio_null)
_video_4 = FFVideoSource("%s_outro_locatoin%",cachefile=ffidxfile,seekmode=0)

clip4 = AudioDub(_video_4,_audio_4)


m_clip = clip1 + clip2 + clip3 + clip4

Return m_clip
emcodem, wrapping since 2009 you got the rhyme?
Post Reply