1

I'm trying to downsample a HD video recorded by TVheadend to SD size using the following command:

avconv -i infile.ts -map 0:v -map 0:a:0 -map 0:a:1 -c copy -c:v mpeg2video -r 25 -qscale:v 2 -s:v 720x576 -f mpeg outfile.mpeg

The output of avconv looks good so far:

Input #0, mpegts, from 'infile.ts':
  Duration: 02:44:44.69, start: 68943.055278, bitrate: 7408 kb/s
  Program 9036 
    Metadata:
      service_provider: upc
    Stream #0.0[0x50]: Video: h264 (High), yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc
    Stream #0.1[0x52](eng): Audio: mp2, 48000 Hz, stereo, s16p, 192 kb/s
    Stream #0.2[0x5b](ger): Audio: ac3, 48000 Hz, 5.1, fltp, 448 kb/s
  No Program
    Stream #0.3[0x6e]: Audio: mp1, 0 channels, s16p
[h264 @ 0x1bd9aa0] Ignoring NAL unit 9 during extradata parsing
[mpeg @ 0x1ab4d60] VBV buffer size not set, muxing may fail
Output #0, mpeg, to 'outfile.mpeg':
  Metadata:
    encoder         : Lavf54.20.4
    Stream #0.0: Video: mpeg2video, yuv420p, 720x576 [PAR 64:45 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 25 tbc
    Stream #0.1(eng): Audio: mp2, 48000 Hz, stereo, 192 kb/s
    Stream #0.2(ger): Audio: ac3, 48000 Hz, 5.1, 448 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mpeg2video)
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
Press ctrl-c to stop encoding

And the quality is also good. But when I play it in VLC and try to change the audio channel, I see a increasing list of audio tracks, and only the first one is usable. And also in the Code information I see a list which permanently adds new lines, after a few seconds, I already see 100+ streams of different formats (subtitles, audio of different formats etc): VLC Codec information dialog

Does anyone know where's the mistake?

I would say the container format is messed up due to a bug, but it happens in different versions: I tried using ffmpeg version 2.7.6-0ubuntu0.15.10.1 on ubuntu wily and avconv version 9.18-6:9.18-0ubuntu0.14.04.1 on trusty. on wily, ffmpeg additionally prints Invalid UE golomb code every ~25 frames

Update:

Here is a short sequence of the input file for testing: infile.ts

0

Try a simpler command with modern choices:

ffmpeg -i infile.ts -map v -map a -c:a copy -c:v libx264 -crf 18 -s 768x432 outfile.mkv
  • This command didn't include the second audio stream. This was the last command which I used which worked. avconv -i infile.ts -map 0:v -map 0:a:0 -map 0:a:1 -c:a copy -c:v libx264 -crf 18 -s 768x432 outfile.ts or the same with mpeg2video as codec. Personally I prefer mpeg2video because then it has the same format as all the other recordings which I have - Should have, because dvbcut can't handle it... – Daniel Alder Feb 17 '16 at 23:35
  • -map v -map a to map all video and audio streams, or -map 0 to map all streams from the first (and only in this case) input file should work too. The shorter the command, the better. I will update my answer. – Not Important Feb 18 '16 at 1:47
  • No, I already tried what you wrote in your last command. Problem is the 3rd audio stream which is outside the program which you can see in the question. I guess it is only for padding/alignment of the data. pastebin.com/wSaEckiP – Daniel Alder Feb 19 '16 at 22:26
0

On Xubuntu 16.04 xenial, I tried again and the problems didn't show up anymore.

The final command line is:

infile=something.ts
outfile=something.mpeg
quality=3.5  # best between small file and good quality
dims=720x576

ffmpeg -i "$infile" -map 0:v -map 0:a:0 -map 0:a:1 -f mpegts -s "$dims" -r 25 -vcodec mpeg2video -qscale:v $quality -acodec copy "$outfile"

The resulting file size is roughly 20% of the original. DVBcut can open and cut it.

I published the full script on gist

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.