MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / AddSphericalMetadata

Method AddSphericalMetadata

src/FFmpegWriter.cpp:2378–2406  ·  view source on GitHub ↗

In FFmpegWriter.cpp

Source from the content-addressed store, hash-verified

2376
2377// In FFmpegWriter.cpp
2378void FFmpegWriter::AddSphericalMetadata(const std::string& projection, float yaw_deg, float pitch_deg, float roll_deg) {
2379 if (!oc) return;
2380 if (!info.has_video || !video_st) return;
2381
2382 // Allow movenc.c to write out the sv3d atom
2383 oc->strict_std_compliance = FF_COMPLIANCE_UNOFFICIAL;
2384
2385#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 0, 0)
2386 // Map the projection name to the enum (defaults to equirectangular)
2387 int proj = av_spherical_from_name(projection.c_str());
2388 if (proj < 0)
2389 proj = AV_SPHERICAL_EQUIRECTANGULAR;
2390
2391 // Allocate the side‐data structure
2392 size_t sd_size = 0;
2393 AVSphericalMapping* map = av_spherical_alloc(&sd_size);
2394 if (!map) return;
2395
2396 // Populate it
2397 map->projection = static_cast<AVSphericalProjection>(proj);
2398 // yaw/pitch/roll are 16.16 fixed point
2399 map->yaw = static_cast<int32_t>(yaw_deg * (1 << 16));
2400 map->pitch = static_cast<int32_t>(pitch_deg * (1 << 16));
2401 map->roll = static_cast<int32_t>(roll_deg * (1 << 16));
2402
2403 ffmpeg_stream_add_side_data(video_st, AV_PKT_DATA_SPHERICAL,
2404 reinterpret_cast<uint8_t*>(map), sd_size);
2405#endif
2406}

Callers 1

Calls 1

Tested by

no test coverage detected