diff --git a/daemon/media_player.c b/daemon/media_player.c index 2d4d5ad26..2085e05c9 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -1255,6 +1255,8 @@ static const rtp_payload_type *media_player_play_init(struct media_player *mp) { static bool media_player_play_start(struct media_player *mp, const rtp_payload_type *dst_pt, str_case_value_ht codec_set) { + int ret = 0; + // needed to have usable duration for some formats. ignore errors. if (!mp->coder.fmtctx->streams || !mp->coder.fmtctx->streams[0]) avformat_find_stream_info(mp->coder.fmtctx, NULL); @@ -1280,10 +1282,14 @@ static bool media_player_play_start(struct media_player *mp, const rtp_payload_t // if start_pos is positive, try to seek to that position if (mp->opts.start_pos > 0) { ilog(LOG_DEBUG, "Seeking to position %lli", mp->opts.start_pos); - av_seek_frame(mp->coder.fmtctx, 0, mp->opts.start_pos, AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD); + ret = av_seek_frame(mp->coder.fmtctx, 0, mp->opts.start_pos, AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD); } else // in case this is a repeated start - av_seek_frame(mp->coder.fmtctx, 0, 0, AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD); + ret = av_seek_frame(mp->coder.fmtctx, 0, 0, AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD); + + if (ret < 0) + ilog(LOG_ERR, "Failed to seek to beginning of media file"); + // should we return false at this point? media_player_read_packet(mp);