Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#13025 closed Bug Report - General (fixed)

Regression: No sound for some HD recordings in recent master

Reported by: dag@… Owned by: Peter Bennett
Priority: major Milestone: 29.0
Component: MythTV - Audio Output Version: Master Head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

Some of my HD recordings in the recent master have no sound. Reverting to an older version (from about January) will produce sound

2017-04-01 11:24:39.853754 I TV::HandleStateChange(): Changing from None to WatchingVideo
2017-04-01 11:24:39.854871 I AFD: streams_changed 0xebc4a80 -- stream count 6
2017-04-01 11:24:39.854911 I AFD: SeekReset(0, 0, do flush, do discard)
2017-04-01 11:24:39.854932 I AFD: SeekReset() flushing
2017-04-01 11:24:39.854949 I VidOutVDPAU: DiscardFrames(1)
2017-04-01 11:24:39.855013 I VideoBuffers::DiscardFrames(1): AAAAAAAAAAAAAA
2017-04-01 11:24:39.855051 I VideoBuffers::DiscardFrames(1): AAAAAAAAAAAAAA -- done
2017-04-01 11:24:39.855100 I VidOutVDPAU: DiscardFrames() 3: AAAAAAAAAAAAAA -- done()
2017-04-01 11:24:39.855140 I AFD: Stream #0, has id 0x13a codec id NONE, type Unknown, bitrate 0 at 0x7fafba1625e0
2017-04-01 11:24:39.855156 E AFD: Unknown codec type (Unknown)
2017-04-01 11:24:39.855184 I AFD: Stream #1, has id 0x366 codec id NONE, type Unknown, bitrate 0 at 0x7fafba163440
2017-04-01 11:24:39.855206 E AFD: Unknown codec type (Unknown)
2017-04-01 11:24:39.855241 I AFD: Stream #2, has id 0x369 codec id NONE, type Unknown, bitrate 0 at 0x7fafba164640
2017-04-01 11:24:39.855259 E AFD: Unknown codec type (Unknown)
2017-04-01 11:24:39.855285 I AFD: Stream #3, has id 0xc37 codec id NONE, type Unknown, bitrate 0 at 0x7fafba165840
2017-04-01 11:24:39.855301 E AFD: Unknown codec type (Unknown)
2017-04-01 11:24:39.855448 I AFD: Stream #4, has id 0xc38 codec id NONE, type Unknown, bitrate 0 at 0x7fafba166a40
2017-04-01 11:24:39.855487 E AFD: Unknown codec type (Unknown)
2017-04-01 11:24:39.855515 I AFD: Stream #5, has id 0x13ed codec id NONE, type Unknown, bitrate 0 at 0x7fafba167c40
2017-04-01 11:24:39.855533 E AFD: Unknown codec type (Unknown)
2017-04-01 11:24:39.855545 I AFD: Trying to select best video track
2017-04-01 11:24:39.855607 I AFD: Selected track #0 (id 0x13a codec id NONE, type Unknown, bitrate 0 at 0x7fafba1625e0)
2017-04-01 11:24:39.855823 I VDP: Accepting: cmp(> 0 0) dec(vdpau) cpus(4) skiploop(enabled) rend(vdpau) osd(vdpau) osdfade(enabled) deint(vdpaubasicdoublerate,vdpaubasic) filt(vdpaucolorspace=auto,vdpausharpen=1.0,vdpauhqscaling=yes)

Attachments (2)

20170413_streamchange.patch (5.4 KB) - added by Peter Bennett 7 years ago.
Fix for #13025 and #12955
20170414_streamchange.patch (5.5 KB) - added by Peter Bennett 7 years ago.
Updated patch for #13025 and #12955, with safety improvement.

Download all attachments as: .zip

Change History (28)

comment:1 Changed 7 years ago by dag@…

This is a short extract of the file with broken audio: https://www.dropbox.com/s/5utxrihykmhysmh/1025_20170330175900-part.ts?dl=0

comment:2 Changed 7 years ago by dag@…

Thought I filled it in in the header..

I am using selfcompiled master at the backend.

minimyth2(http://minimyth2.homenet.org/) for master as frontend

The one that works is marked as mythtv r132 (from 20160804) The failing one is r356 (from 20170316)

The packager of minimyth2 suggested I create a ticket as there had been changes in ffmpeg between these two.

comment:3 Changed 7 years ago by J.Pilk@…

I get the same with this clip. Sound works with v0.29-pre-189, not with pre-380. ffmpeg -i and mythffmpeg -i give essentially identical output, ac3 stereo fltp at 448 kb/s. Typical in UK is aac_latm(LC).

'frontend -v playback' reports AFD: No codec for streams 1,2, id(AC3:86019), and hitting the + key yields a blank ident OSD.

This change mirrors that seen for DVD audio playback, ticket #12955

comment:4 Changed 7 years ago by Peter Bennett

Run the frontend with -v playback option

Playing back this video I see hundreds of error messages:

2017-04-11 15:57:18.865659 E  AFD: No codec for stream index 2, type(Audio) id(AC3:86019)
2017-04-11 15:57:18.865663 E  AFD: No codec for stream index 2, type(Audio) id(AC3:86019)
2017-04-11 15:57:18.865665 E  AFD: No codec for stream index 2, type(Audio) id(AC3:86019)
2017-04-11 15:57:18.871906 E  AFD: No codec for stream index 1, type(Audio) id(AC3:86019)
2017-04-11 15:57:18.871912 E  AFD: No codec for stream index 1, type(Audio) id(AC3:86019)
2017-04-11 15:57:18.871925 E  AFD: No codec for stream index 1, type(Audio) id(AC3:86019)

There are similar messages for the subtitles, but fewer:

2017-04-11 15:59:17.888159 E  AFD: No codec for stream index 5, type(Subtitle) id(DVB_SUBTITLE:94209)

mythffprobe does recognize the streams, but does show some error messages:

[h264 @ 0x2c0f060] SPS unavailable in decode_picture_timing
[h264 @ 0x2c0f060] non-existing PPS 0 referenced
[h264 @ 0x2c0f060] SPS unavailable in decode_picture_timing
[h264 @ 0x2c0f060] non-existing PPS 0 referenced
[h264 @ 0x2c0f060] decode_slice_header error
[h264 @ 0x2c0f060] no frame!
[mpegts @ 0x1ceaca0] start time for stream 5 is not set in estimate_timings_from_pts
[mpegts @ 0x1ceaca0] PES packet size mismatch
Input #0, mpegts, from 'ticket-13025.ts':
  Duration: 00:00:15.48, start: 73247.924156, bitrate: 5420 kb/s
    Stream #0:0[0x13a]: Video: h264 (High), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x366](swe): Audio: ac3, 48000 Hz, stereo, fltp, 448 kb/s
    Stream #0:2[0x369](dut): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:3[0xc37](fin): Subtitle: dvb_subtitle
    Stream #0:4[0xc38](swe): Subtitle: dvb_subtitle
    Stream #0:5[0xc4f](swe): Subtitle: dvb_subtitle
    Stream #0:6[0x13ed](fin): Subtitle: dvb_teletext
Unsupported codec with id 94215 for input stream 6

Some more digging is needed to see why it cannot find the codec for AC3 or for DVB subtitles.

comment:5 Changed 7 years ago by J.Pilk@…

After running 'mythcommflag --rebuild' on the clip the editor sees keyframes at 75,90,120,135,...

Cut to beginning from frame 75; quit editor. Playback gives audio.

comment:6 Changed 7 years ago by dag@…

That would explan why some of the HD recordings from the same channel had sound, some not.

Shouldn't the player resync that by itself?

comment:7 Changed 7 years ago by J.Pilk@…

The problem might not have been foreseen. Does adding a short initial cut work for all your affected recordings? They should already have seektables, so only the cutlist-editing step would be needed.

comment:8 Changed 7 years ago by dag@…

Unfortunately I had to revert back to a working version as the rest of family was all over me... I will see if I can test it somehow, but that would be later...

Will you try to do something to the code?

comment:9 Changed 7 years ago by J.Pilk@…

I hope someone will; but there has always been scope for confusion when the signal format changes after a recording begins, or even before it ends. Perhaps it's easier for a TV.

comment:10 Changed 7 years ago by Peter Bennett

On this video it is initially scanning the streams and interpreting them all correctly and finding the correct codecs. Then, before the first frame is played, it gets a "streams changed" notification. Upon scanning the streams again, they are now all unknown with codec NONE. The only reason the Video is actually played is because there is code that says for unknown video assume MPEG2 and start playing. This video is not MPEG2 but it seems that ffmpeg manages to sort that out and play it. There is no such default action for audio or subtitles so they are not played.

Sometime later on the code seems to realize the type of streams, but by then it is too late, MythTV already has them as unknown.

It seems to be an ffmpeg bug with scanning the streams after a "streams changed" notification.

I tried a few tweaks trying to get it to rescan the streams but with no success, there are complex interactions involved and all I succeeded in doing was causing a core dump.

comment:11 Changed 7 years ago by Peter Bennett

Owner: changed from JYA to Peter Bennett
Status: newaccepted

I have a patch that works and gives both audio and subtitles with the sample provided. I will clean it up and do some more testing then post it here for review.

Changed 7 years ago by Peter Bennett

Attachment: 20170413_streamchange.patch added

Fix for #13025 and #12955

comment:12 Changed 7 years ago by Peter Bennett

Please test the attached patch with Master and let me know the results.

Changed 7 years ago by Peter Bennett

Attachment: 20170414_streamchange.patch added

Updated patch for #13025 and #12955, with safety improvement.

comment:13 Changed 7 years ago by dag@…

I thank you so much for the fix, but cannot unfortunately test it until it is incorporated into MiniMyth2. According to the other people's reports it seems to be right on the spot though. Thanks again!

comment:14 Changed 7 years ago by Peter Bennett

I plan to test it and sleep on it for a couple of days. I want to be sure that the fix does not break anything else. After that I will commit it to the MythTV repository.

comment:15 Changed 7 years ago by Peter Bennett <pbennett@…>

Resolution: fixed
Status: acceptedclosed

In ae81146402f86410fddb04f08776de955e14593c/mythtv:

Fix stream change handling in playback

In some cases, stream changes occurring in the video cause sound
and subtitles to be lost. This started with ffmpeg version 3.2.
This fixes the problem by changing the way stream changes are handled.

Fixes #13025
Fixes #12955

comment:16 Changed 7 years ago by J.Pilk@…

After applying the fix I've just seen another aspect of the problem I referred to in Comment 9. My recording today of BBC Four News was mute. BBC Four (SD) is a part-time channel, and the News is its first item. My recordings have a 2-minute pre-roll, so the possibility of bad behaviour clearly exists. Somehow, ISTR, my earlier version avoided it.

I found that I had sound and picture in the editor, and MythDVBcut has created a good copy, so I'm not much worried. There are obvious workarounds.

comment:17 in reply to:  16 Changed 7 years ago by Karl Egly

Replying to J.Pilk@…:

BBC Four (SD) is a part-time channel, and the News is its first item. My recordings have a 2-minute pre-roll, so the possibility of bad behaviour clearly exists. Somehow, ISTR, my earlier version avoided it.

I found that I had sound and picture in the editor, and MythDVBcut has created a good copy, so I'm not much worried. There are obvious workarounds.

It all depends on how they fiddle with SDT/PMT when stopping/starting the service. The service should be signalled as present, but not running, when this recording starts. Then on top of the hour it should switch to running in the SDT.

I'm not sure what the PMT is supposed to contain while the service is not running. But if we record everything on PMT update / stream start that is good and issues can be fixed after the recording was made.

Your description sounds as if the stream may be present but not running, too. So there is no addition of a stream and no automatic stream selection is kicked when the service starts. Can you verify that the audio can be selected by manually cycling through the audio streams without fiddling with the file? (A test file would be nice to add to the collecting, too)

comment:18 Changed 7 years ago by J.Pilk@…

I deleted the original, but will try for another - and the end-of-service on CBeebies at 7:00pm.

qam_64:698000000:BBC ONE E Mid:1:12323:9018:4166:4166=4166:dvb  1001:cnt(pnum:1,channum:1)
qam_64:698000000:BBC TWO:2:12323:9018:4287:4166=4166:dvb        1002:cnt(pnum:1,channum:1)
qam_64:698000000:BBC FOUR:9:12323:9018:4544:4166=4166:dvb       1009:cnt(pnum:1,channum:1)
qam_64:698000000:CBeebies:121:12323:9018:4672:4166=4166:dvb     1121:cnt(pnum:1,channum:1)

26 channels listed in this mux, of which 16 are radio.

comment:19 Changed 7 years ago by J.Pilk@…

This box is now running 29-pre-386 with the updated (20170414) patch.
Previously it was 29-pre-189; ie, before the ffmpeg resync.

I set up two recordings:

CBeebies 18:56 - 19:04 BST    displayed length 2:07.880, 3197 frames
Playback normal, with sound; goes to black screen at 02:00.600.  Probably 18:58 BST

Audio streams shown as
1. English MP 0 ?ch
2. English (Audio Description) 
-----------

BBC Four 18:58 - 19:34 BST    displayed length 35:09.720. 52743 frames
 
Playback starts at the 'Mythical' bookmark, 02:00 or 3000 frames.  That will be 19:00:00 BST.
There's no sound, but the Audio streams identify as above.

If playback is started with the edit cursor at the start of the recording, I see a static 
ident screen for 12s, then BBC programme ads, with sound, until the spoken intro at 01:01.040

When I started compiling this, I could get sound while editing.  Then it disappeared. 
Very confusing.  Eventually... playback and editing seem to be almost normal if playback was 
started from the beginning.  But the log has a selection of repeated warnings, probably mainly 
from jump tests.  I haven't tried correlating them with my commands.

comment:20 Changed 7 years ago by J.Pilk@…

I've put a 40 MiB dd clip from the BBC Four startup recording here:

https://www.mediafire.com/?uduiiwv30sg4v31

comment:21 Changed 7 years ago by Peter Bennett

That clip plays OK when I try it. The audio is fine. It selects the audio track 1 (English MPO ?ch) by default and that plays successfully. If I select the second audio track (English (Audio Description)) there is no audio and playback is affected by hundreds of error messages that the audio and video are out of sync. There seems to be a problem with that audio track. Subtitles also work fine.

So I don't see any problem here.

comment:22 Changed 7 years ago by J.Pilk@…

Have you tried playing it as a recording with a bookmark set? I wasn't sure how easy it would be to demonstrate the 'feature' on someone else's box, but that does it for me. I have another recording set for today.

comment:23 Changed 7 years ago by J.Pilk@…

Here's a mini-sample of 'mythfrontend -v playback' on attempting to play today's recording from its default 'Mythical' bookmark. The last three lines repeat fast and continuously - I stopped it with ctrl/C. No sound.

As before, playback is OK after skipping to start of file, then forward.

2017-04-19 19:40:33.455525 I  PreviewQueue: Requested preview for '1009_20170419175700.ts_0x0_-1s'
2017-04-19 19:40:33.478581 E  AFD: Unsupported sample format with 0 bits
2017-04-19 19:40:33.478592 I  AFD: Audio stream changed
2017-04-19 19:40:33.478597 I  AFD: Number of audio channels changed from 0 to 2

I am using a patched version of AudioOutputGraph?, still not doing what I had hoped, and I suppose it's possible that that might not like this file header. It doesn't give problems with normal recordings.

comment:24 Changed 7 years ago by Peter Bennett

The extract is 42 seconds long. I tried setting a bookmark at many points during it, from the start to the finish, and then playing from bookmark. It worked fine each time. I did not see your problem occurring.

comment:25 Changed 7 years ago by J.Pilk@…

OK. I'm still seeing it in new recordings, and with that sample when I have renamed or linked it as the video file of some other existing recording - but unless anyone else sees it and finds it a real problem there's no point in pursuing the matter. Thanks again for the patch, and apologies for diverting you from more general problems.

comment:26 Changed 6 years ago by Peter Bennett

Owner: changed from Peter Bennett to Peter Bennett
Note: See TracTickets for help on using tickets.