• The forum software that supports hummy.tv will be upgraded to XenForo 2.3 on Wednesday the 20th of November 2024 starting at 7pm

    There will be some periods where the forum is unavailable, please bear with us. More details can be found in the upgrade thread.

MPG conversion issue

I've just discovered that on-box conversion of recordings from PBS America (LCN 94, moving soon to 91) produces MPG files with no audio. Conversion works properly on all other channels.
The affected TS files play OK on both the box and my computer, as do conversions to MP4 done on the computer.
 
I tried it and can confirm.

Input:
Stream #0:0[0x8a3]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg, top first), 544x576 [SAR 64:33 DAR 544:297], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x8a4](eng): Audio: aac_latm (LC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Output:
Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg, top first), 544x576 [SAR 64:33 DAR 544:297], q=2-31, 25 fps, 25 tbr, 90k tbn, 25 tbc
Stream #0:1(eng): Audio: aac_latm (LC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
video:4520kB audio:526kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.765299%
Result:
Stream #0:0[0x1c0]: Audio: mp2, 0 channels, s16p
Stream #0:1[0x1e2]: Video: h264 (High), yuv420p(tv, bt470bg, top first), 544x576 [SAR 64:33 DAR 544:297], 25 fps, 25 tbr, 90k tbn, 50 tbc
I don't think it can cope with aac_latm. Fails with the latest beta ffmpeg 4.1 as well.
You can re-code manually with aac audio codec into a .mp4, but not on the WebIf.
 
You can re-code manually with aac audio codec into a .mp4, but not on the WebIf.
And of course it takes ages on the T2.
You've tested it on all other "channels"
The Convert to MPG option is disabled on stuff recorded from BBC One HD and such like, which has the same audio format. Presumably the WebIf looks at the video format to decide this, and in the PBS America case it's sub SD resolution so it thinks it's OK to enable the option.
 
I tried it and can confirm.

[...]

I don't think it can cope with aac_latm. Fails with the latest beta ffmpeg 4.1 as well.
You can re-code manually with aac audio codec into a .mp4, but not on the WebIf.

Thanks for confirming it. I converted the last batch on the computer, but sadly have lost a few older recordings where the .ts file is no longer available. But the chances are they'll repeat them, so there's still hope...
 
So the problem is that the Webif 'Opt+>Extract to MPG' conversion tries to copy the DVB-T2/SD audio (AAC LATM) and video (H.264) streams from the MPEG-TS container, but the resulting file doesn't play even though, despite Wikipedia,these formats are notcan be valid in the MPEG video container[/url]. But as the strictly invalid MPEG/H.264+MP2 combination turns out to be supported by the Humax codecs and presumably some external media players, a possible solution is to test the source file and selectively copy or re-encode the audio, which tests at "ages", or <0.5 x length of programme (result plays on box with play/pause/stop only), something like this (/mod/webif/lib/ts.class lines 423 ff.):
Code:
-ts method mkmpg {{tmp ""}} {
+ts method mkmpg {{tmp ""}{mpg "mpg"}} {
      set rfile [file rootname $file]

+      if {$mpg eq mpg} {      
+          set cmd [list /mod/bin/ffprobe -hide_banner \
+              -select_streams a:0 -show_entries stream=codec_name \
+              -of flat $file 2>/dev/null]
+
+          set output [exec {*}$cmd]
+
+          if {[lsearch -glob -bool $output "*=\"mp2\""]} {
+              set acodec copy
+          } else {
+              set acodec mp2
+          }
+      }
+
      set cmd [list /mod/bin/ffmpeg \
          -y -benchmark -v 0 \
          -i $file \
          -map 0:0 -map 0:1 \
-          -vcodec copy -acodec copy]
+          -vcodec copy -acodec $acodec]

      if {$tmp eq ""} {
-              lappend cmd "${rfile}.mpg"
+              lappend cmd "${rfile}.${mpg}"
      } else {
-              lappend cmd "$tmp.mpg"
+              lappend cmd "$tmp.${mpg}"
      }

      set output [exec {*}$cmd]

      if {$tmp ne ""} {
-              file rename "$tmp.mpg" "${rfile}.mpg"
+              file rename "$tmp.mpg" "${rfile}.${mpg}"
      }

      return $output
}
Or there could be an 'Opt+>Extract to MP4' option in the WebIf, whose implementation would be the above method called with $tsobj mkmpg $tmpfile mp4; maybe even 'Opt+>Extract to MKV', with the above method called with $tsobj mkmpg $tmpfile mkv (for export only: MKV is not playable on box)? I suppose it depends on why people want this on-box conversion.
...
Presumably the WebIf looks at the video format to decide this, and in the PBS America case it's sub SD resolution so it thinks it's OK to enable the option.
The ts class uses hmt -p to determine the definition of the file. Instance variables, say acodec and vcodec, could be added to the class and set in the exec method by invoking ffprobe, as webif already depends on ffmpeg. In that case such instance variables could be used instead of calling ffprobe in the above proposal.

Not relevant to the OP's problem, but when it started on Freeview PBS America was notable for apparently random audio-video sync, a problem not seen with eg Film4+1 when it used to be transmitted as DVB-T2/SD. Maybe the Humax codecs had trouble with the transmission from the PBS America playout system? PBS America may have fixed this now: I haven't noticed it recently, and Dan Snow's lips were in good enough sync when I checked. The diagnostics for this recording dating from the bad AV sync era are typical (and similar for v2.8):
Code:
ffprobe Ancient\ Worlds_20180519_1014.ts
ffprobe version 4.1 Copyright (c) 2007-2018 the FFmpeg developers
...
[h264 @ 0x45fd10] SPS unavailable in decode_picture_timing
[h264 @ 0x45fd10] non-existing PPS 0 referenced
[h264 @ 0x45fd10] SPS unavailable in decode_picture_timing
[h264 @ 0x45fd10] non-existing PPS 0 referenced
[h264 @ 0x45fd10] decode_slice_header error
[h264 @ 0x45fd10] no frame!
...
[h264 @ 0x45fd10] mmco: unref short failure
    Last message repeated 1 times
[mpegts @ 0x4428c0] PES packet size mismatch
Input #0, mpegts, from 'Ancient Worlds_20180519_1014.ts':
  Duration: 01:04:55.78, start: 85146.370600, bitrate: 1572 kb/s
...
    Stream #0:0[0x8a3]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg, top first), 544x576 [SAR 64:33 DAR 544:297], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x8a4](eng): Audio: aac_latm (LC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
It looks as though ffmpeg developers disagreed with the PBS America playout codec developers, or perhaps the Humax recording function mangled the format for that channel only? Off-air recordings from other channels don't show these diagnostics (others, but not these).
 
Last edited:
I've just discovered that on-box conversion of recordings from PBS America (LCN 94, moving soon to 91) produces MPG files with no audio. Conversion works properly on all other channels.
The affected TS files play OK on both the box and my computer, as do conversions to MP4 done on the computer.

This issue has disappeared since the recent changes to PBS America. A recording converted to .mpf by the custom software plays with sound both on the box and the computer.
 
But presumably it's still the same with PBS America+1 on LCN 94, still a DVB-T2 mux, while PBS America(+0) is now on DVB-T?
 
But presumably it's still the same with PBS America+1 on LCN 94, still a DVB-T2 mux, while PBS America(+0) is now on DVB-T?

I've just checked by converting recordings from each of the PBS channels. The .mpg files played correctly in both cases.
 
As far as I can see the current PBS America+1 H.264 SD+AAC LTM m2ts streams have just the same content formats as the PBS America ones from last May (eg). Only the stream IDs differ. I distrust the source I quoted previously and have modified the post accordingly.

Perhaps it's ffmpeg that's improved, in the new package from last February? But that doesn't agree with @prpr's post (which on reflection I don't really understand - where did mp2 come from?).
 
Last edited:
that doesn't agree with @prpr's post (which on reflection I don't really understand - where did mp2 come from?)
Not sure I totally understand what you mean, but I think the default audio in a .mpg file is mp2. And it can't convert aac_latm to mp2.
It probably can convert aac_latm to aac, but that has to go in a .mp4 file, not a .mpg file. And you can't currently do that on the WebIf.
Does that help? Or is this a load of bo...cks testicles.
 
In various posts, my bold:
JoeBloggs911 said:
... on-box conversion of recordings from PBS America (LCN 94, moving soon to 91) produces MPG files with no audio. Conversion works properly on all other channels.
The affected TS files play OK on both the box and my computer, as do conversions to MP4 done on the computer.
...
This issue has disappeared since the recent changes to PBS America. A recording converted to .mpf by the custom software plays with sound both on the box and the computer.

I've just checked by converting recordings from each of the PBS channels. The .mpg files played correctly in both cases.

It seems that OP is now able to use the Webif MPG conversion (which is just ffmpeg copying the audio and video streams to a .mpg, ts::mkmpg) to make playable MPG files out of PBS America+1's H.264 SD+AAC LTM m2ts streams recorded (and decrypted) on his HD/R.

These playable files must therefore be MPEG-PS containing H.264 and AAC LTM, though the same operation last February made silent MPGs.

In the earlier test an MP2 audio stream with 0 channels appeared. So that must have been a test of copying the H.264 and re-encoding the audio as MP2, whose failure would have shown my proposed code mod to be broken as well as (now) redundant?

Anyhow the current ffmpeg can make one of last May's PBS America H.264 SD+AAC LTM m2ts files into a playable-on-box MPG containing H.264 and MP2.
 
Indeed, as I highlighted in bold when quoting JB911. Do keep up, BH.

As the forum will apparently never acquire a TaRDiS (or it could have come back to us), the issue with the original files, and whether the converted audio was absent, incompatibly marked, or whatever, is going to remain an enigma.

We can declare a success anyway since not only has the problem gone away, but, had it not, the work-around of re-encoding the audio also succeeds.

Regarding content types in MPEG-PS containers, my reading of the ISO standard is that any content type defined in other ISO MPEG specifications is allowed, even things like AAC that are normally associated with MP4. Demux implementations may vary.
 
Back
Top