[FFmpeg-user] Remux MPEG-TS file fails: Mid-stream changes?

Peter B. pb at das-werkstatt.com
Mon Nov 30 00:09:41 CET 2015


Dear all,

For archiving purposes, TV shows are recorded - coming in as MPEG-TS
stream (H.264/AAC).
I've encountered a problem with a file:

- In some players (e.g. VLC) audio plays fine at the beginning, but is
mute when the actual program starts.
- It "seems" that the audio samplerate changes mid-stream between 48kHz
and 44.1kHz.


I've tried remuxing/retranscoding the file:

- Remuxing to MKV fails with the error message:
   "Could not write header for output file #0 (incorrect codec
parameters ?): Invalid argument"
    (Commandline and complete, uncut console output below: (1))

- Re-encoding audio to "pcm_s16le" fails:
    [quote]
        [aac @ 0x2258720] channel element 2.0 is not allocated
        Error while decoding stream #0:1: Invalid data found when
processing input
        [aac @ 0x2258720] element type mismatch 1 != 0
    [/quote]
    (Commandline and complete, uncut console output below: (2))

I've uploaded a sample to:
http://download.das-werkstatt.com/pb/mthk/examples/mpegts_audio/


How could this MPEG-TS file be normalized in a way that the video is
kept as-is, but the audio is e.g. resampled to a common rate, in order
to play fine on all players?

Thanksalot in advance,
Peter B.


(1)
-----------------
$ ffmpeg -i esdn_audio_problem-20151128.ts -c copy output.mkv
-----------------

ffmpeg version N-76860-g72eaf72 Copyright (c) 2000-2015 the FFmpeg
developers
  built with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --prefix=/usr/local --enable-gpl --enable-nonfree
--enable-version3 --enable-postproc --enable-swscale --enable-avfilter
--enable-pthreads --enable-bzlib --enable-zlib --enable-decoder=png
--enable-encoder=png --samples=../fate-suite --enable-libfreetype
--enable-libschroedinger --enable-libopenjpeg --disable-decoder=jpeg2000
--enable-libvpx --enable-libvorbis --enable-libx264 --enable-libfaac
  libavutil      55.  9.100 / 55.  9.100
  libavcodec     57. 16.100 / 57. 16.100
  libavformat    57. 19.100 / 57. 19.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 15.100 /  6. 15.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mpegts, from 'esdn_audio_problem-20151128.ts':
  Duration: 00:00:29.98, start: 1.410667, bitrate: 4000 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
yuv420p, 1280x720, 30 fps, 59.94 tbr, 90k tbn, 60 tbc
    Stream #0:1[0x101]: Audio: aac (HE-AACv2) ([15][0][0][0] / 0x000F),
48000 Hz, stereo, fltp, 53 kb/s
[matroska @ 0x3844e60] Codec for stream 0 does not use global headers
but container format requires global headers
[matroska @ 0x3844e60] Codec for stream 1 does not use global headers
but container format requires global headers
[matroska @ 0x3844e60] Error parsing AAC extradata, unable to determine
samplerate.
Output #0, matroska, to 'output.mkv':
  Metadata:
    encoder         : Lavf57.19.100
    Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 1280x720,
q=2-31, 30 fps, 59.94 tbr, 1k tbn, 90k tbc
    Stream #0:1: Audio: aac ([255][0][0][0] / 0x00FF), 48000 Hz, stereo,
53 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Could not write header for output file #0 (incorrect codec parameters
?): Invalid argument



(2)
-----------------
$ ffmpeg -i esdn_audio_problem-20151128.ts -c:v copy -c:a pcm_s16le
output.ts
-----------------

ffmpeg version N-76860-g72eaf72 Copyright (c) 2000-2015 the FFmpeg
developers
  built with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --prefix=/usr/local --enable-gpl --enable-nonfree
--enable-version3 --enable-postproc --enable-swscale --enable-avfilter
--enable-pthreads --enable-bzlib --enable-zlib --enable-decoder=png
--enable-encoder=png --samples=../fate-suite --enable-libfreetype
--enable-libschroedinger --enable-libopenjpeg --disable-decoder=jpeg2000
--enable-libvpx --enable-libvorbis --enable-libx264 --enable-libfaac
  libavutil      55.  9.100 / 55.  9.100
  libavcodec     57. 16.100 / 57. 16.100
  libavformat    57. 19.100 / 57. 19.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 15.100 /  6. 15.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mpegts, from 'esdn_audio_problem-20151128.ts':
  Duration: 00:00:29.98, start: 1.410667, bitrate: 4000 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
yuv420p, 1280x720, 30 fps, 59.94 tbr, 90k tbn, 60 tbc
    Stream #0:1[0x101]: Audio: aac (HE-AACv2) ([15][0][0][0] / 0x000F),
48000 Hz, stereo, fltp, 53 kb/s
Output #0, mpegts, to 'output.ts':
  Metadata:
    encoder         : Lavf57.19.100
    Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p,
1280x720, q=2-31, 30 fps, 59.94 tbr, 90k tbn, 90k tbc
    Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
    Metadata:
      encoder         : Lavc57.16.100 pcm_s16le
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[aac @ 0x37a4720] channel element 2.0 is not allocated
Error while decoding stream #0:1: Invalid data found when processing input
[aac @ 0x37a4720] element type mismatch 1 != 0
frame=  897 fps=0.0 q=-1.0 Lsize=   20510kB time=00:00:29.99
bitrate=5601.6kbits/s   
video:13250kB audio:5616kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 8.714312%



More information about the ffmpeg-user mailing list