[FFmpeg-user] Problem remuxing corrupted HLS-stream

Vadim Lazovskiy vadim.lazovskiy at gmail.com
Sat Jan 25 21:44:30 CET 2014


Hello.

I've got a problem with remuxing corrupted HLS stream.
I have a bunch of ts-segments from IP-camera. Ex.:

ts01.ts
ts02.ts
ts03.ts
 -- camera rebooted --
ts04.ts
ts05.ts
ts06.ts

Sequence 01-03 is continuous and valid. Sequence 04-06 is also valid.
But all these segments are in the same m3u8-playlist.

When I'm trying to use this playlist to remux whole stream into single
flv-file I'm getting playback problems.
Technically the obtained video is fully playable but duration is
unpredictable and invalid.

Here is the ffmpeg output cut:

ffmpeg -i /tmp/stream.m3u8 -codec:v copy -an -y /tmp/flv.flv

Input #0, hls,applehttp, from '/tmp/stream.m3u8':
  Duration: 00:01:50.00, start: 26108.042267, bitrate: N/A
  Program 0
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv,
bt709), 1280x720, 25 fps, 25 tbr, 90k tbn, 50 tbc
Output #0, flv, to '/tmp/flv.flv':
  Metadata:
    encoder         : Lavf55.19.104
    Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 1280x720,
q=2-31, 25 fps, 1k tbn, 90k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 2577 fps=0.0 q=-1.0 Lsize=   25320kB time=19:16:07.11 bitrate=
3.0kbits/s
video:25269kB audio:0kB subtitle:0 global headers:0kB muxing overhead
0.200305%

Input video is 1.5 min avg., resulting time is 19:16:07.11

With -loglevel debug I've found interesting log entries:
[mpegts @ 0x10f2e80] Continuity check failed for pid 17 expected 5 got 0
[mpegts @ 0x10f2e80] Continuity check failed for pid 0 expected 7 got 0
[mpegts @ 0x10f2e80] Continuity check failed for pid 4096 expected 7 got 0
[mpegts @ 0x10f2e80] Continuity check failed for pid 256 expected 13 got 0

I've managed to fix the issue using setpts filter:

ffmpeg -i /tmp/stream.m3u8 -filter:v "setpts=N/(25*TB)" -an -y /tmp/flv.flv

In this case output file duration is correct. But it is unable to use
"-codec:v copy", so the stream is being transcoded with all ensuing
consequences (cpu and time wasting).

Is it somehow possible to fix PTS without transcoding the input?

Thanks!

ffmpeg version 2.1.1 Copyright (c) 2000-2013 the FFmpeg developers
  built on Nov  8 2013 10:57:47 with gcc 4.8 (SUSE Linux)
  configuration: --shlibdir=/usr/lib64 --prefix=/usr
--mandir=/usr/share/man --libdir=/usr/lib64 --enable-shared
--disable-static --enable-debug --disable-stripping --extra-cflags='-O2 -g
-m64 -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector
-funwind-tables -fasynchronous-unwind-tables -fPIC -I/usr/include/gsm'
--enable-gpl --enable-x11grab --enable-version3 --enable-pthreads
--enable-libfaac --enable-libfdk_aac --enable-nonfree --enable-avfilter
--enable-libpulse --enable-libvpx --enable-libopus --enable-libass
--enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex
--enable-libxvid --enable-libx264 --enable-libschroedinger --enable-libgsm
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-postproc
--enable-libdc1394 --enable-librtmp --enable-libfreetype
--enable-avresample --enable-libtwolame --enable-libvo-aacenc
--enable-gnutls
  libavutil      52. 48.101 / 52. 48.101
  libavcodec     55. 39.101 / 55. 39.101
  libavformat    55. 19.104 / 55. 19.104
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.100 /  3. 90.100
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Hyper fast Audio and Video encoder

-- 
Best Regards,
Vadim Lazovskiy


More information about the ffmpeg-user mailing list