How do I preserve side data when concatenating files in ffmpeg?
Asked Answered
G

2

8

I have multiple 360 videos that I'm trying to concatenate in ffmpeg. The command it self is pretty straightforward:

ffmpeg -f concat -i 0036_concat.txt -c copy -strict unofficial 36.mp4

where 0036_concat.txt is just a list of the individual files. The issue I'm having is that I can't get ffmpeg to preserve side data. Very simply put, ffprobe on any of the source files includes this:

Side data:
  spherical: equirectangular (0.000000/0.000000/0.000000)

And I can't, for the life of me, get that to propagate to the output file.

this question has a solution that works for single files, but it doesn't work when concatenating multiple files.

I'd be perfectly fine injecting that entire string if anyone knows how.

Griffiths answered 9/5, 2020 at 18:0 Comment(5)
Can you provide a link to one of the individual files listed in 0036_concat.txt?Vogul
@Vogul -- File contents are just file 'name.mp4'\nfile 'name2.mp4', etcGriffiths
@Vogul -- my bad, misread that. Here's a 1 sec clip: dropbox.com/s/qntwf6m85sxvar9/GS020101.mp4?dl=0Griffiths
See if this helps? #11706549Valida
@TarunLalwani -- Unfortunately not. I've seen that answer before and don't understand why it doesn't work, I'm guessing this isn't actually "metadata" according to ffmpeg. There's almost zero documentation on side dataGriffiths
A
5

Apparently ffmpeg doesn't support that. Many people suggest developing your own extension for FFmpeg, but i found it overkill.

Instead, I have successfully done it using google spatialmedia to add the side data to the output video resulting from the FFmpeg concat. It is as simple as

python spatialmedia -i 36.mp4  equirectangular.mp4

You can get spatialmedia from its official repo. Download the latest release, unzip it, and you will be able to run the above command directly.

In case you don't have it, you need to install python first.

That is all you need.


Bellow I add an example in my local with your own video.

I downloaded your sample file, and created the below file list

enter image description here

Run ffprobe GS020101.mp4, we can see that Side data: spherical: equirectangular (0.000000/0.000000/0.000000) is there

enter image description here

Run ffmpeg -f concat -i 0036_concat.txt -c copy -strict unofficial output.mp4

Run ffprobe output.mp4, as you expected, side data is not there

enter image description here

Run python spatialmedia -i output.mp4 equirectangular.mp4

enter image description here

Run ffprobe equirectangulat.mp4, this time you can see successfully the expected side data.

enter image description here

Amelia answered 27/5, 2020 at 16:41 Comment(2)
Unfortunately this doesn't actually answer the question. I'm aware of the spatial media injector, but I not everything I have is equirecangular so it doesn't workGriffiths
This is the only answer I have found so far that allowed me to get a badly stitched 360 video uploaded to YouTube. Thanks! Just need to work on my stitching problem!Airflow
G
4

Although it seems like ffmpeg doesn't support this, I found that ExifTool seems to do the job. Run this command after your ffmpeg concat:

exiftool -tagsFromFile first_file_inside_concat_file.mp4 -all:all 36.mp4
Grosberg answered 8/2, 2022 at 17:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.