Handling codec changes mid-stream

About encoding, codec settings, muxers and filter usage
quequotion
New Cone
New Cone
Posts: 8
Joined: 24 Sep 2012 16:20

Handling codec changes mid-stream

Postby quequotion » 25 Oct 2012 07:19

Hello!

Once again on the topic of watching Japanese ISDB-T I have a challenging problem.

ISDB supports several combinations of video and audio codecs, so different channels, and even different programs on a channel, are using different encodings.

The hardware, an Earthsoft PT-2, has no trouble changing channels and encodings on the fly, and vlc is fine with changing channels that use the same encoding, but changing codecs mid-stream will crash vlc.

This also crashes mplayer and I don't know of any software player that could handle this.Is it possible to implement some kind of buffer that could handle sudden changes in encoding?

At the moment, I use a script that changes the channel, waits eight seconds, checks if VLC has crashed and restarts it if necessary. It just happens to take about 8 seconds for VLC to crash... Channel changes without codec changes take about one second, channel changes with codec changes take about ten seconds (8 for VLC to crash, 2 to start a new process).

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Handling codec changes mid-stream

Postby Jean-Baptiste Kempf » 25 Oct 2012 12:06

Please share crashing samples...
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

quequotion
New Cone
New Cone
Posts: 8
Joined: 24 Sep 2012 16:20

Re: Handling codec changes mid-stream

Postby quequotion » 25 Oct 2012 16:52

Here's mplayer playing 10 seconds of NHK 1 (channel 14 in my area):

Code: Select all

$ recpt1 --b25 --strip 14 10 - | mplayer -vo vdpau -cache 8192 - using B25... enable B25 strip pid = 16577 MPlayer SVN-r34707-4.6 (C) 2000-2012 MPlayer Team Playing -. Reading from stdin... Cache fill: 0.00% (0 bytes) C/N = 30.421604dB Cache fill: 0.00% (0 bytes) Recording... Cache fill: 15.60% (1308668 bytes) libavformat version 54.0.0 (internal) TS file format detected. VIDEO MPEG2(pid=256) AUDIO AAC(pid=272) NO SUBS (yet)! PROGRAM N. 61448 VIDEO: MPEG2 1440x1080 (aspect 3) 29.970 fps 20000.0 kbps (2500.0 kbyte/s) Load subtitles in ./ Cache not responding! [performance issue] Cache not responding! [performance issue] ========================================================================== Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family libavcodec version 54.0.0 (internal) Selected video codec: [ffmpeg2] vfm: ffmpeg (FFmpeg MPEG-2) ========================================================================== ========================================================================== Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders AUDIO: 48000 Hz, 2 ch, s16le, 0.0 kbit/0.00% (ratio: 0->192000) Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio)) ========================================================================== AO: [pulse] 48000Hz 2ch s16le (2 bytes per sample) Starting playback... Unsupported PixelFormat 61 Unsupported PixelFormat 53 Unsupported PixelFormat 81 Movie-Aspect is 1.78:1 - prescaling to correct movie aspect. VO: [vdpau] 1440x1080 => 1920x1080 Planar YV12 A:12592.9 V:12592.9 A-V: -0.044 ct: -0.821 250/250 17% 29% 0.4% 1 0 0% Cache empty, consider increasing -cache and/or -cache-min. [performance issue] A:12593.1 V:12593.0 A-V: 0.098 ct: -0.824 251/251 17% 29% 2.3% 2 0 0% Cache empty, consider increasing -cache and/or -cache-min. [performance issue] Cache empty, consider increasing -cache and/or -cache-min. [performance issue] Cache empty, consider increasing -cache and/or -cache-min. [performance issue] Recorded 12sec TS_PARSE: COULDN'T SYNC A:12593.1 V:12593.6 A-V: -0.436 ct: -0.858 269/269 17% 29% 21.0% 2 0 0% Exiting... (End of file)
And here's 10 seconds of OBS (a local channel, 22):

Code: Select all

~$ recpt1 --b25 --strip 22 10 - | mplayer -vo vdpau -cache 8192 - using B25... enable B25 strip pid = 17917 MPlayer SVN-r34707-4.6 (C) 2000-2012 MPlayer Team Playing -. Reading from stdin... Cache fill: 0.00% (0 bytes) C/N = 31.312085dB Cache fill: 0.00% (0 bytes) Recording... Cache fill: 19.68% (1651204 bytes) libavformat version 54.0.0 (internal) TS file format detected. VIDEO MPEG2(pid=273) AUDIO AAC(pid=274) NO SUBS (yet)! PROGRAM N. 61456 VIDEO: MPEG2 1440x1080 (aspect 3) 29.970 fps 20000.0 kbps (2500.0 kbyte/s) Load subtitles in ./ Cache not responding! [performance issue] Cache not responding! [performance issue] ========================================================================== Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family libavcodec version 54.0.0 (internal) Selected video codec: [ffmpeg2] vfm: ffmpeg (FFmpeg MPEG-2) ========================================================================== ========================================================================== Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders AUDIO: 48000 Hz, 2 ch, s16le, 0.0 kbit/0.00% (ratio: 0->192000) Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio)) ========================================================================== AO: [pulse] 48000Hz 2ch s16le (2 bytes per sample) Starting playback... Unsupported PixelFormat 61 Unsupported PixelFormat 53 Unsupported PixelFormat 81 Movie-Aspect is 1.78:1 - prescaling to correct movie aspect. VO: [vdpau] 1440x1080 => 1920x1080 Planar YV12 A:34438.8 V:34438.8 A-V: 0.001 ct: -0.603 277/277 13% 29% 0.4% 1 0 0% Cache empty, consider increasing -cache and/or -cache-min. [performance issue] Cache empty, consider increasing -cache and/or -cache-min. [performance issue] Cache empty, consider increasing -cache and/or -cache-min. [performance issue] Cache empty, consider increasing -cache and/or -cache-min. [performance issue] Recorded 12sec TS_PARSE: COULDN'T SYNC A:34439.0 V:34439.4 A-V: -0.395 ct: -0.625 295/295 13% 29% 19.6% 1 0 0% [aac @ 0xd1a6a0]Input buffer exhausted before END element found A:34439.0 V:34439.4 A-V: -0.395 ct: -0.628 295/295 13% 29% 19.6% 1 0 0% Exiting... (End of file)
The "Cache empty" errors are to be expected, mplayer doesn't like it when a stream suddenly terminates itself, such as on a 10 second timer.

mplayer shows the same codec information for both channels, but I am not sure that it is correct. In particular changing channels to and from OBS will crash vlc and mplayer. There doesn't seem to be anything on in MPEG-4 at the moment. Changing channels between NHK 1 and NHK 2 always works, presumably because they are from the same broadcaster and are encoded in the same way. Changing to and from other channels works sometimes, but not all the time.

Here's a ~20 second sample stream of NHK 1, then OBS, and back to NHK 1. mplayer plays a few seconds of this, then dies (TS Parse sync error), but vlc doesn't play it at all (TS Discontinunity errors and segfault). Obviously, something is going wrong with the transport stream. As before, this sample, provided for research and development, contains copyrighted content that is not owned by me, but is freely broadcast over-the-air.

quequotion
New Cone
New Cone
Posts: 8
Joined: 24 Sep 2012 16:20

Re: Handling codec changes mid-stream

Postby quequotion » 02 Dec 2013 17:27

Any idea what's happening here?

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Handling codec changes mid-stream

Postby Jean-Baptiste Kempf » 09 Dec 2013 14:40

This is fixed for me for 2.2.0
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 10 guests