Skip to content

Commit

Permalink
Merge pull request #10 from jellyfin/segment-muxer-fix
Browse files Browse the repository at this point in the history
 Add patch fixing up segment muxer
  • Loading branch information
joshuaboniface authored Oct 2, 2019
2 parents 1901e78 + 959f377 commit da7926e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
37 changes: 37 additions & 0 deletions debian/patches/0001_fix-segment-muxer.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Index: jellyfin-ffmpeg/libavformat/segment.c
===================================================================
--- jellyfin-ffmpeg.orig/libavformat/segment.c 2019-10-02 13:05:57.119005772 -0400
+++ jellyfin-ffmpeg/libavformat/segment.c 2019-10-02 13:06:11.367388679 -0400
@@ -87,6 +87,7 @@
int64_t last_val; ///< remember last time for wrap around detection
int cut_pending;
int header_written; ///< whether we've already called avformat_write_header
+ int64_t start_pts; ///< pts of the very first packet processed, used to compute correct segment length

char *entry_prefix; ///< prefix to add to list entry filenames
int list_type; ///< set the list type
@@ -702,6 +703,7 @@
if ((ret = parse_frames(s, &seg->frames, &seg->nb_frames, seg->frames_str)) < 0)
return ret;
} else {
+ seg->start_pts = -1;
/* set default value if not specified */
if (!seg->time_str)
seg->time_str = av_strdup("2");
@@ -914,7 +916,15 @@
seg->cut_pending = 1;
seg->last_val = wrapped_val;
} else {
- end_pts = seg->time * (seg->segment_count + 1);
+ if (seg->start_pts != -1) {
+ end_pts = seg->start_pts + seg->time * (seg->segment_count + 1);
+ } else if (pkt->stream_index == seg->reference_stream_index && pkt->pts != AV_NOPTS_VALUE) {
+ // this is the first packet of the reference stream we see, initialize start point
+ seg->start_pts = av_rescale_q(pkt->pts, st->time_base, AV_TIME_BASE_Q);
+ seg->cur_entry.start_time = (double)pkt->pts * av_q2d(st->time_base);
+ seg->cur_entry.start_pts = seg->start_pts;
+ end_pts = seg->start_pts + seg->time * (seg->segment_count + 1);
+ }
}
}

1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0001_fix-segment-muxer.patch
6 changes: 6 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,14 @@ RUN \
curl -sLO https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
tar -jx --strip-components=1 -f ffmpeg-${FFMPEG_VERSION}.tar.bz2

COPY debian/patches/*.patch /tmp/ffmpeg/

RUN \
DIR=/tmp/ffmpeg && mkdir -p ${DIR} && cd ${DIR} && \
for patch in *.patch; do \
filename="$( grep '+++' ${patch} | awk '{ print $2 }' | sed 's|jellyfin-ffmpeg/||' )"; \
patch --verbose ${filename} ${patch}; \
done && \
./configure \
--disable-debug \
--disable-doc \
Expand Down

0 comments on commit da7926e

Please sign in to comment.