TOPs ffmpeg audio

   1769   10   1
User Avatar
Member
385 posts
Joined: 7月 2018
Offline
Is there a way to add audio when converting image sequence to video in TOPs using ffmpegencode?
User Avatar
Member
8580 posts
Joined: 7月 2007
Online
at the very bottom you can check FFmpeg Command and you can compose any command you need
it will no longer update based on parameters, so if you want some parameters to still update the command you will need to reference them in there by expression
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
385 posts
Joined: 7月 2018
Offline
yeah thanks! i will look into that. maybe turn it into a TOPs hda
User Avatar
Member
385 posts
Joined: 7月 2018
Offline
tried some commands i found here

How to add a new audio (not mixing) into a video using ffmpeg? [stackoverflow.com]

specifically tried these :

ffmpeg -i C:/MYPATH/video.mkv -i C:/MYPATH/audio.mp3 -map 0 -map 1:a -c copy -shortest C:/MYPATH/video.mkv

ffmpeg -i C:/MYPATH/video.mkv -i C:/MYPATH/audio.mp3 -map 0:0 -map 1:0 -c copy -shortest C:/MYPATH/video.mkv


But nothing is working for some reason. i noticed not providing an output on the actual outputfilepath parameter of the ffmpegencodevideo TOP node (because i am providing it in the custom command) the node fails. Other than that the node executes but the video still has no audio.

i tried also naming the output file differently, also didn't work.
Probably not understanding the node properly.
Any tips on how to troubleshoot this?
Edited by papsphilip - 2023年2月26日 13:24:30

Attachments:
Capture.JPG (59.2 KB)

User Avatar
Member
8580 posts
Joined: 7月 2007
Online
does the same command work for you when you execute it in the command line?
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
385 posts
Joined: 7月 2018
Offline
tested it in the command line.
needed a few changes to work

ffmpeg -i "C:/MYPATH/video.mkv" -i "C:/MYPATH/audio.mp3" -map 0 -map 1:a -c copy -shortest "C:/MYPATH/output.mkv"

1)needed quotes for the paths and
2)ffmpeg couldn't overwrite the same file so i have to put a different output filename.

The above command worked great in the command line but not in TOPs, because instead of "C:/MYPATH" I use "`@pdg_output`" to get the incoming output file from a previous ffmpeg operation that creates the video from a sequence. @pdg_output was empty

had to store the @pdg_output to a string attribute in order to pass it down
User Avatar
スタッフ
586 posts
Joined: 5月 2014
Offline
@pdg_output refers to the output of the current work item itself. If you want to use the output path produced by an upstream work item, you should use @pdg_input.
User Avatar
Member
385 posts
Joined: 7月 2018
Offline
tpetrick
@pdg_output refers to the output of the current work item itself. If you want to use the output path produced by an upstream work item, you should use @pdg_input.

yes thank you! works. in the start it wasn't evaluating to anything probably because the upstream node wasn't cooked.

Is there a way to access @pdg_input in a python expression?
User Avatar
スタッフ
586 posts
Joined: 5月 2014
Offline
Yep, in a parameter that's configured to use Python for its expression language, you can use pdg.input(..) to do the same thing as @pdg_input. There's also pdg.workItem() which will return the pdg.WorkItem instance that's being used to evaluate the parameter. Those functions are described at the very top of the pdg module doc: https://www.sidefx.com/docs/houdini/tops/pdg/#input [www.sidefx.com]
Edited by tpetrick - 2023年2月27日 19:32:24
User Avatar
Member
385 posts
Joined: 7月 2018
Offline
Thanks a lot for the suggestions. I am working on uploading an example file here for everyone.

Bumped into another problem though ffmpeg related. How do i trim the audio to the frame range i am exporting?

There is this command i could run before adding the audio to my flipbook

ffmpeg -i music.wav -ss 0 -t 37 musicshort.wav [stackoverflow.com]

but how do i convert my frame to seconds? i have 24 frames per second. not sure if i can give ffmpeg fraction of a second. will test though.

Any suggestions?
Edited by papsphilip - 2023年3月1日 07:11:39
User Avatar
Member
385 posts
Joined: 7月 2018
Offline
The above command worked like a charm and to get the seconds i just divide with my frame per second. So frame number 240 would be 240/24 = 10second.
Pretty obvious i guess
  • Quick Links