MP4(3)

πŸ“¦ version 2.1.0, in fedora 43, fedora 44

πŸ’– 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 is MP4_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? if false, then all samples get copied. if true, 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:

  1. use MP4AddTrackEdit() to specify the start and duration of the clip you want.
  2. 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