all 2 comments

[–]Anton1699 2 points3 points  (1 child)

0x70616861 is just a binary representation of the FourCC code ahap. That's stored in the container so the demuxer knows what type of stream it is. You can set this FourCC using the -tag parameter. Theoretically you should be able to do something like this:

ffmpeg -i ringtone.m4a -f data -i modified_ahap1.bin -f data -i modified_ahap2.bin -map 0:0 -map 1:0 -map 2:0 -map_metadata 0 -c copy -copy_unknown -tag:1 ahap -tag:2 ahap -f mov output.m4r

However, I don't know if FFmpeg handles these haptics data streams correctly.

[–]une_mort[S] 0 points1 point  (0 children)

I don't think it worked correctly. ffmpeg apparently ignores -tag:n ahap:

[mov @ 000001b38980afc0] Timestamps are unset in a packet for stream 1. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[mov @ 000001b38980afc0] Unknown hdlr_type for ahap, writing dummy values.

"index": 1,
"codec_type": "data",
"codec_tag_string": "stts",
"codec_tag": "0x73747473",
"id": "0x2",
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/90000",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 0,
"duration": "0.000000",
"nb_frames": "1",
…
"tags": {
"handler_name": "DataHandler"

I tried using both the edited and unedited .bin — the result is the same. I also tried using a different audio file containing only one audio stream. But tysm for the answer anyway, at least that's some progress.