Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

getMediaInformation blocks forever parsing MPEG-TS streams #113

Closed
leetreveil opened this issue Apr 4, 2019 · 5 comments
Closed

getMediaInformation blocks forever parsing MPEG-TS streams #113

leetreveil opened this issue Apr 4, 2019 · 5 comments
Assignees
Labels
enhancement New feature or request fixed

Comments

@leetreveil
Copy link

leetreveil commented Apr 4, 2019

mobile-ffmpeg calls ffmpeg to parse out media information:

https://github.com/tanersener/mobile-ffmpeg/blob/master/ios/src/MobileFFmpeg.m#L180

This call will block forever if the stream source is live video i.e. MPEG-TS.

Instead, we should consider using ffprobe which does not block parsing live streams and should simplify the media information parsing code significantly due to the machine readable output of ffprobe:

https://ffmpeg.org/ffprobe.html#Description

@tanersener tanersener self-assigned this Apr 4, 2019
@tanersener
Copy link
Owner

tanersener commented Apr 4, 2019

You may be right about this. I haven't tested getMediaInformation with live streams before. I'll make some tests soon and post an update about it.

@leetreveil
Copy link
Author

leetreveil commented Apr 4, 2019

As a short term fix we could consider removing the outfile options from the end of the args to prevent ffmpeg from blocking:

ffmpeg -i http://some_mpeg_ts_stream -hide_banner -v info -f null -

vs

ffmpeg -i http://some_mpeg_ts_stream -hide_banner

The latter complains about a missing output file and returns 1 but does not block:

Input #0, mpegts, from 'http://some_mpeg_ts_stream':
  Duration: N/A, start: 13912.704000, bitrate: N/A
  Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 185 kb/s
    Stream #0:2[0x102](eng): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
At least one output file must be specified

That's quite hacky though as it could cause issues with return code error handling.

@tanersener
Copy link
Owner

Unfortunately implementing ffprobe effects ffmpeg and too much effort is needed to split their contexts. So ffprobe is not an option for now.

I applied your suggestions on the development branch. Outfile options are removed in getMediaInformation. As you've pointed out method call won't be blocked for live streams.

This change will be included in the next minor release.

@tanersener tanersener added enhancement New feature or request and removed needs-analysis labels Apr 7, 2019
@leetreveil
Copy link
Author

Awesome! Thanks so much :)

@tanersener
Copy link
Owner

Awesome! Thanks so much :)

You are the one who have identified the issue and posted the fix. So I should be thanking to you 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request fixed
Projects
None yet
Development

No branches or pull requests

2 participants