replace audio on video

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

replace audio on video

Post by authorleon »

hello. I just wanted to know if it were possible to replace the audio on a video clip.

Of course I would provide the file path to the audio file.

I'm just asking a general question here because I'm not quite sure if there is an existing module that allows you to do that, or if it's custom?

Thanks
User avatar
FranceBB
Posts: 235
Joined: Sat Jun 25, 2016 3:43 pm
Contact:

Re: replace audio on video

Post by FranceBB »

The good news is that you can totally do that. :)
The question is: do you just want to remux the video with a completely different audio OR do you want to re-encode the video and the new audio and create a new file with the new video and audio?
The reason why I'm asking is that depending on your answer it's gonna be either a command executor (remux) OR a Custom Avisynth Script (re-encode). ;)
authorleon
Posts: 108
Joined: Fri May 08, 2020 5:18 pm

Re: replace audio on video

Post by authorleon »

Hello FranceBB.

Technically I need both however I think it's best to focus on the one that I need the most. okay so I just looked up REMUX and effectively it is just replacing the audio but keeping the same video if I'm correct?

Effectively, I would like to re-encode the video with a new audio file. In this case an MP3 with some music.

Please note. If the MP3 is 10 minutes long for example, and the video is only one minute long. Then of course it should encode one-minute video with one minute of audio.

Thank you
ThomasM
Site Admin
Posts: 227
Joined: Wed Feb 22, 2017 6:36 am

Re: replace audio on video

Post by ThomasM »

Hi authorleon,

Code: Select all

ffmpeg -i "%s_original_full%" -i "PathOfAudio.Here" -c:v copy -map 0:v:0 -map 1:a:0 -shortest "NewPathAndNameOfOutputFile.Here"
in a Command Executor coul do the trick.

Just an idea...

Thomas
authorleon
Posts: 108
Joined: Fri May 08, 2020 5:18 pm

Re: replace audio on video

Post by authorleon »

Hi Thomas,

I gave it a got. But it did not work:

Code: Select all

ffmpeg -i "%s_original_full%" -i "A:\FFAStrans_Video_Processing\00_Test\audio.mp3" -c:v copy -map 0:v:0 -map 1:a:0 -shortest "A:\FFAStrans_Video_Processing\00_Test\out\%s_original_full%"
https://i.imgur.com/QATALnA.png

I have played around but I cannot get it to work.
ThomasM wrote: Mon Nov 21, 2022 12:15 pm Hi authorleon,

Code: Select all

ffmpeg -i "%s_original_full%" -i "PathOfAudio.Here" -c:v copy -map 0:v:0 -map 1:a:0 -shortest "NewPathAndNameOfOutputFile.Here"
in a Command Executor coul do the trick.

Just an idea...

Thomas
emcodem
Posts: 1652
Joined: Wed Sep 19, 2018 8:11 am

Re: replace audio on video

Post by emcodem »

authorleon wrote: Wed Nov 23, 2022 1:34 pm

Code: Select all

ffmpeg -i "%s_original_full%" -i "A:\FFAStrans_Video_Processing\00_Test\audio.mp3" -c:v copy -map 0:v:0 -map 1:a:0 -shortest "A:\FFAStrans_Video_Processing\00_Test\out\%s_original_full%"
Thoma's concept is correct, i suspect there is some issue with your command line, e.g. you use "ffmpeg" at start, which implies that ffmpeg.exe is available somewhere in the PATH of your System. Otherwise you'd need to use "%s_ffmpeg%", this points to the ffmpeg location that is shipped with ffastrans.

Example implementation here:
emcodem_replace_audio.json
(2.34 KiB) Downloaded 43 times
Btw, i did't know that the A: drive is already free to use, isn't there still lots of legacy software having troubles with that? :D
emcodem, wrapping since 2009 you got the rhyme?
authorleon
Posts: 108
Joined: Fri May 08, 2020 5:18 pm

Re: replace audio on video

Post by authorleon »

thank you. Let me get back to you and find out what thee problem is
authorleon
Posts: 108
Joined: Fri May 08, 2020 5:18 pm

Re: replace audio on video

Post by authorleon »

just a quick question.

If the video file is "test.mp4".
The mp3 file should be "test.mp4.mp3"

" "%s_original_path%\%s_original_name%_newaudio%s_original_ext%" "

it is just that I've tried many different variations and it still waiting. I have also put the MP3 in the same folder as the video file.
ThomasM
Site Admin
Posts: 227
Joined: Wed Feb 22, 2017 6:36 am

Re: replace audio on video

Post by ThomasM »

Yeah, I got ffmpeg.exe in PATH for using it quick and got it handy on CMD.

@authorleon, try your Command-Executor-Node Codes in the windows-commandline. That is faster and easier to debug. If that works, copy the line to your Node. then, one after one, try to exchange the full paths with variables.

In your case, I assume the .mp4-File will be picked up by a Monitor-Node - right? so you got [example on D:\] "D:\MyVideosAndReplaceAudioFiles\test.mp4" in built-in File-Variable %s_original_full% and "D:\MyVideosAndReplaceAudioFiles" in built-in File-Variable %s_original_path%.

To add the audio-file "test.mp4.mp3" the path would be "D:\MyVideosAndReplaceAudioFiles\test.mp4.mp3" - right?
This would be the same as ""%s_original_path%\%s_original_name%.%s_original_ext%.mp3"

@emcodem: I always use the A:\-Drive for my 5 1/4"-Floppy-Disk. Still working with WordStar 7.0 under DOS 6.22 (just updated from 12" FloppyDisk!) :D

regards,
Thomas
emcodem
Posts: 1652
Joined: Wed Sep 19, 2018 8:11 am

Re: replace audio on video

Post by emcodem »

Sorry there is a copy/paste issue in the workflow.
The hold node should wait for the file
"%s_original_full%.mp3"

that resolves to test.mp4.mp3 then in reality if test.mp4 was the video that you submitted.

@ThomasM
you got a "working" floppy drive? :D
emcodem, wrapping since 2009 you got the rhyme?
Post Reply