Search - User list
Full Version: TOPs ffmpeg audio
Root » PDG/TOPs » TOPs ffmpeg audio
papsphilip
Is there a way to add audio when converting image sequence to video in TOPs using ffmpegencode?
tamte
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
papsphilip
yeah thanks! i will look into that. maybe turn it into a TOPs hda
papsphilip
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?
tamte
does the same command work for you when you execute it in the command line?
papsphilip
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
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.
papsphilip
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?
tpetrick
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]
papsphilip
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?
papsphilip
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
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB