I would like to losslessly convert a a .ts file to a more usable file format, e.g. .mpeg. Unfortunately, the converted file seems to lack audio. At least I don't hear anything when playing it in VLC (Video works, though), and some other media player (Audience) doesn't open it at all. Can you tell my why FFmpeg failed, and how to do it right?


The command I used:

privat@manuel-Inspiron-3721:~/Downloads$ ffmpeg -i hls-720p.ts -codec copy hls-720p.mpeg

FFmpegs output:

ffmpeg version 2.8.10-0ubuntu0.16.04.1 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
  configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mpegts, from 'hls-720p.ts':
  Duration: 00:06:31.86, start: 1.400000, bitrate: 1432 kb/s
  Program 1 
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 139 kb/s
[mpeg @ 0x1c7b680] VBV buffer size not set, using default size of 130KB
If you want the mpeg file to be compliant to some specification
Like DVD, VCD or others, make sure you set the correct buffer size
Output #0, mpeg, to 'hls-720p.mpeg':
    encoder         : Lavf56.40.101
    Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbr, 90k tbn, 25 tbc
    Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, 139 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 9796 fps=0.0 q=-1.0 Lsize=   62752kB time=00:06:31.86 bitrate=1311.8kbits/s    
video:57506kB audio:4853kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.631245%

VLCs codec information

Original .ts-file: Original .ts file

Converted .mpeg-file: Converted .mpeg file


If you are using -c copy you are not encoding the video, just changing the "envelope", which does not support neither h264 nor aac.

.mpeg files must contain mpeg1 o mpeg2 video and mpeg1 layer 1,2 or 3 audio. H264 is mpeg4 and aac is an extension of mpeg2.

VLC might play since it can almost play anything, but your "encoded" output is now less compatible than ever.

Try encoding it to .mp4 to make it more compatible. I think that you can mantain the copy flag in this case.

Note: .mpeg is a very old format and the output removing the copy flag would render a low quality video.

  • When choosing .mp4 as output file, I got following error: [mp4 @ 0x901680] Malformed AAC bitstream detected: use the audio bitstream filter 'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc' option with ffmpeg). I could fix it by using the proposed -bsf:a aac_adtstoasc option and it works now. Is the conversion still lossless? I'm very concerned with not introducing any conversion losses. – Multisync Jan 23 '17 at 4:50
  • 1
    This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4 ADTS header and removes the ADTS header. If you were not requested to remove the copy flag to use the filter, it is safe to assume that there were no re-coding and no quality loss. – NuTTyX Jan 23 '17 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.