Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/FFmpegReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,13 @@ void FFmpegReader::Open() {
AVStream* st = pFormatCtx->streams[i];
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
// Only inspect the first video stream
#if (LIBAVFORMAT_VERSION_MAJOR < 62)
for (int j = 0; j < st->nb_side_data; j++) {
AVPacketSideData *sd = &st->side_data[j];
#else
for (int j = 0; j < st->codecpar->nb_coded_side_data; j++) {
AVPacketSideData *sd = &st->codecpar->coded_side_data[j];
#endif

// Handle rotation metadata (unchanged)
if (sd->type == AV_PKT_DATA_DISPLAYMATRIX &&
Expand Down
6 changes: 5 additions & 1 deletion src/FFmpegWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVStream *st) {
switch (video_codec_ctx->codec_id) {
case AV_CODEC_ID_H264:
video_codec_ctx->max_b_frames = 0; // At least this GPU doesn't support b-frames
video_codec_ctx->profile = FF_PROFILE_H264_BASELINE | FF_PROFILE_H264_CONSTRAINED;
video_codec_ctx->profile = AV_PROFILE_H264_BASELINE | AV_PROFILE_H264_CONSTRAINED;
av_opt_set(video_codec_ctx->priv_data, "preset", "slow", 0);
av_opt_set(video_codec_ctx->priv_data, "tune", "zerolatency", 0);
av_opt_set(video_codec_ctx->priv_data, "vprofile", "baseline", AV_OPT_SEARCH_CHILDREN);
Expand Down Expand Up @@ -2391,6 +2391,10 @@ void FFmpegWriter::AddSphericalMetadata(const std::string& projection, float yaw
map->pitch = static_cast<int32_t>(pitch_deg * (1 << 16));
map->roll = static_cast<int32_t>(roll_deg * (1 << 16));

#if (LIBAVFORMAT_VERSION_MAJOR < 62)
av_stream_add_side_data(video_st, AV_PKT_DATA_SPHERICAL, reinterpret_cast<uint8_t*>(map), sd_size);
#else
av_packet_side_data_add(&video_st->codecpar->coded_side_data, &video_st->codecpar->nb_coded_side_data, AV_PKT_DATA_SPHERICAL, reinterpret_cast<uint8_t *>(map), sd_size, 0);
#endif
#endif
}