Skip to content

Commit

Permalink
Possible fix for ffmpeg hanging 3/4 way through converting to hls
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaserlang committed Dec 10, 2023
1 parent 7888626 commit 52b7607
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions seplis_play_server/transcoders/hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,21 @@ def ffmpeg_extend_args(self) -> None:
self.ffmpeg_args.extend([
*self.keyframe_params(),
{'-f': 'hls'},
{'-hls_playlist_type': 'event'},
{'-hls_playlist_type': 'vod'},
{'-hls_segment_type': 'fmp4'},
{'-hls_time': str(self.segment_time())},
{'-hls_list_size': '0'},
{'-start_number': str(self.settings.start_segment or 0)},
{'-y': None},
{self.media_path: None},
])

if self.output_codec == 'h264':
self.ffmpeg_args.append({'-bsf:v': 'h264_mp4toannexb'})
elif self.output_codec == 'hevc':
self.ffmpeg_args.append({'-bsf:v': 'hevc_mp4toannexb'})

self.ffmpeg_args.append({self.media_path: None})

@property
def media_path(self) -> str:
return os.path.join(self.transcode_folder, self.media_name)
Expand Down
6 changes: 3 additions & 3 deletions seplis_play_server/transcoders/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ async def set_ffmpeg_args(self):
self.ffmpeg_args = [
{'-analyzeduration': '200M'},
]
if self.can_copy_video:
self.ffmpeg_args.append({'-fflags': '+genpts'})
self.set_hardware_decoder()
if self.settings.start_time:
self.ffmpeg_args.append({'-ss': str(self.settings.start_time)})
Expand Down Expand Up @@ -237,13 +239,11 @@ def set_video(self):
i = self.find_ffmpeg_arg_index('-ss')
# Audio goes out if sync if not used
self.ffmpeg_args.insert(i+1, {'-noaccurate_seek': None})

self.ffmpeg_args.insert(i+2, {'-fflags': '+genpts'})

self.ffmpeg_args.extend([
{'-start_at_zero': None},
{'-avoid_negative_ts': 'disabled'},
#{'-copyts': None},
{'-copyts': None},
])
else:
if config.ffmpeg_hwaccel_enabled:
Expand Down

0 comments on commit 52b7607

Please sign in to comment.