Skip to content

Instantly share code, notes, and snippets.

@ofTheo
Last active October 11, 2022 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ofTheo/0784930c829d8cae8e1dca1f618227a9 to your computer and use it in GitHub Desktop.
Save ofTheo/0784930c829d8cae8e1dca1f618227a9 to your computer and use it in GitHub Desktop.
pseudo code for adding audio to a video file
float audioDuration = (1.0/1000.0) * (float)(lastTimestampMillis-firstTimestampMillis);
string audioCommands;
if( audioPath.length() ){
audioCommands = " -ss "+ofToString(timelineOffset, 3)+" -t " + ofToString(audioDuration, 3)+ " -i "+ ofToDataPath(audioPath, true);
}
string addAudio = ffmpeg + " -i "+ofToDataPath(savefile, false)+" "+ audioCommands +" -codec copy -shortest " + ofToDataPath(ofFilePath::removeExt( savefile ) + "withAudio." + ofFilePath::getFileExt(savefile), false);
system(addAudio.c_str());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment