MP4(3)
π MP4(3) β MP4 File Format Library π
ok so bestie, welcome to the MP4(3) corner of the manual, aka the MP4 File Format Library. today's main character is one very specific lil function and she slays. no cap.
β¨ NAME β¨
MP4CopyTrack β make a copy of a specified track. that's it. that's the whole job. π«Ά
πΈ SYNTAX πΈ
#include <mp4.h>
MP4TrackId MP4CopyTrack(
MP4FileHandle srcFile,
MP4TrackId srcTrackId,
MP4FileHandle dstFile = MP4_INVALID_FILE_HANDLE,
bool applyEdits = false,
MP4TrackId dstHintTrackReferenceTrack = MP4_INVALID_TRACK_ID
)
yes she takes five arguments, she's high maintenance and honestly? deserved. π
π ARGUMENTS π
srcFileβ the mp4 file where the source track lives. like, the origin story file. this is the one you're copying from, bestie.srcTrackIdβ the track id of the track you wanna copy. point at it. be specific. πdstFileβ the mp4 file where the shiny new copied track goes. and here's the tea: if this value isMP4_INVALID_FILE_HANDLE, then the new track just gets created in the same file as the source track. same file, new track, no travel required. β¨applyEditsβ do we apply the track edit list while copying the media samples or not? iffalse, then all samples get copied. iftrue, then only the samples that the track edit list actually includes get copied. it's giving "curated playlist" vs "dump the whole album". π§dstHintTrackReferenceTrackβ when you're cloning a hint track, this parameter tells you the track id of the reference track in the destination file. very niche, very specific, very iconic. π¦
π RETURN VALUES π
- on success? you get the track id of the new track. slay. π
- on error? you get
MP4_INVALID_TRACK_ID. π not the vibe.
π DESCRIPTION π
MP4CopyTrack creates a new track in an mp4 file that is a copy of an existing track β and it copies the track media type, the other control information, and the media samples. full package deal, no notes. π
the applyEdits parameter is lowkey the best part of this function, because it lets you create standalone clips out of a bigger mp4 file super easily. here's the recipe, bestie:
- use
MP4AddTrackEdit()to specify the start and duration of the clip you want. - then use
MP4CopyTrack()to export that portion of the media to a new mp4 file.
boom. clip. periodt. π¬
okay so important aside β if you do not want to copy the media samples, and you just want to create a track with the same type and control information as the source track, then you want MP4CloneTrack() instead. different function, different energy, don't mix them up fr fr. π
π₯ SEE ALSO π₯
and that's the whole page, bestie!! this manual came to you courtesy of Cisco Systems Inc., sitting pretty at Version 0.9 β go forth and copy some tracks, you've got this π β¨
π¦ where this page comes from
- fedora 43: libmp4v2-devel 2.1.0-0.34.trunkREV507.fc43 Β· LicenseRef-Callaway-MPLv1.1
- fedora 43: libmp4v2-devel 2.1.0-0.34.trunkREV507.fc43 Β· LicenseRef-Callaway-MPLv1.1
- fedora 44: libmp4v2-devel 2.1.0-0.35.trunkREV507.fc44 Β· LicenseRef-Callaway-MPLv1.1
- fedora 44: libmp4v2-devel 2.1.0-0.35.trunkREV507.fc44 Β· LicenseRef-Callaway-MPLv1.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms