Opened 4 years ago

Last modified 5 weeks ago

#8349 reopened enhancement

Dolby AC-4 Support

Reported by: Nomis101 Owned by:
Priority: wish Component: avcodec
Version: git-master Keywords: ac4
Cc: wrb2c@riede.org, talkenrain@gmail.com, ffmpeg@tmm1.net, Jim Scarborough, videotranscoder, Romualds Cirsis, Clint, thovo, davygrvy Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

It would be nice to support the detection, muxing and demuxing of Dolby AC-4 audio streams (in MP4 and MKV).

Information: https://dolbyac4.com/
Specs: https://www.dolby.com/us/en/technologies/ac-4/Next-Generation-Entertainment-Services.pdf
Sample files: http://testassets.dashif.org/#testcase/details/586fb3879ae9045678eab64f

MediaInfo 19.09 added support for AC-4, so it would be nice to have support in FFmpeg as well.
https://mediaarea.net/MediaInfo/ChangeLog

Attachments (3)

frame-20-789726256.mpa (24.9 KB ) - added by Santiago Otero 3 years ago.
AC-4 sample from ATSC3.0
atsc3.ts (1.6 MB ) - added by csdesigns 3 years ago.
ATSC 3.0 OTA 5.1
capture5003.ts (2.2 MB ) - added by kenmac999 2 years ago.
recorded from OKC Physical Channel atsc3:503000000:2

Change History (88)

comment:1 by Elon Musk, 4 years ago

Resolution: wontfix
Status: newclosed

comment:2 by Elon Musk, 4 years ago

Component: avcodecundetermined
Priority: normalwish
Resolution: wontfix
Status: closedreopened

comment:4 by Willem Riede, 3 years ago

Cc: wrb2c@riede.org added

ATSC3.0 Broadcast video uses AC-4 sound. Support for AC-4 in ffmpeg appears to be required for Plex TV to be used to play such video streams. I would like to see renewed urgency for this feature. Unfortunately I don't have enough knowledge on the subject to program something like this but I would be happy to help testing if that's of use.

comment:5 by MikeV, 3 years ago

I'd be willing to contribute a bit on money if it would help get AC-4 supported. Is there a preferred mechanism for funding such feature requests?

comment:6 by talkenrain, 3 years ago

Cc: talkenrain@gmail.com added

There is a growing need for Dolby AC4 support within ffmpeg. As ATSC 3.0 broadcast becomes mainstream across the US many applications (like PLEX) depend on ffmpegs support of AC4 to be compatible with this growing format. Hardware that requires support has already hit the market. Please add me to the list of willing beta testers as the lack of AC4 support is now the only obstacle to full support with PLEX.

comment:7 by Bill Mackintosh, 3 years ago

Priority: wishimportant

It is very important to get AC-4 audio processing in ffmpeg for Plex users (such as myself) as ATSC 3.0 expands and hardware such as the HDHomeRun 4K tuner make use of this. Please add me to the list of potential beta testers as I have this setup (Plex & HDHomeRun 4K)

comment:8 by Carl Eugen Hoyos, 3 years ago

Priority: importantwish

comment:9 by netsjtr08, 3 years ago

Priority: wishimportant

Adding to the request for this development as well. no sound on plex with new ATSC 3.0 tuner.

comment:10 by Carl Eugen Hoyos, 3 years ago

Priority: importantwish

comment:11 by Chris_in_Texas, 3 years ago

With more ATSC3.0 channels coming nationwide we really need support for AC3. This will become critical for other systems that use ffmpeg in short time. Please add AC3 support in so we can continue to view 4K ATSC TV.

comment:12 by Elon Musk, 3 years ago

Post short samples of various configurations.

comment:13 by Kyle, 3 years ago

If you want a starting point, check out this series of patches. Someone submitted them back in March to patchwork, but they failed some tests:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=451

comment:14 by Elon Musk, 3 years ago

Looks like nobody cares about AC-4, because if they care they would actually provide AC-4 samples here.

by Santiago Otero, 3 years ago

Attachment: frame-20-789726256.mpa added

AC-4 sample from ATSC3.0

in reply to:  14 comment:15 by Kyle, 3 years ago

Replying to richardpl:

Looks like nobody cares about AC-4, because if they care they would actually provide AC-4 samples here.

siryurian just posted a sample for ATSC 3.0, but links to multiple AC-4 samples were already provided via the "DASH IF" link in the initial bug report. Just click "Accept" on their TOS popup and refresh the page to get a dozen different AC-4 samples for stereo, 5.1 and multitrack audio.

Also it's not that "nobody cares", it's that ATSC 3.0 is brand new and only active in select markets in the USA, the one device that allows the average user to view it on their PC only started shipping in October, and most users affected by this have no idea how to extract the AC-4 track to provide a usable sample. (Heck most of them had no idea that VLC, Kodi and Plex all rely on FFmpeg for audio and video decoding) I would have done it myself, but the 3 markets I have access to over the air, including the biggest market NYC, have not launched ATSC 3.0 services.

Last edited 3 years ago by Kyle (previous) (diff)

in reply to:  14 comment:16 by Curtisb, 3 years ago

Replying to richardpl:
Looks like nobody cares about AC-4, because if they care they would actually provide AC-4 samples here.

That is false and absurd conclusion for a number of reasons. Here are 100 comments and rising of people starting to realize this show stopping problem. ​https://forum.silicondust.com/forum/viewtopic.php?f=133&t=74323
To any interested devs, please let us non devs know what is needed. How many clips? Does the video content matter (HD, standard def, progressive/interlaced). Do you want it where it transitions into commercials? etc.
Here is two longer HD clips from a progressive and borked interlaced stream (due to bug 4141) for anyone who can use them.
https://1drv.ms/u/s!Ap22nCAxKBS7j-Jr9Q8eX45gp2Uh7w?e=3miW5h

Last edited 3 years ago by Curtisb (previous) (diff)

in reply to:  14 comment:17 by Curtisb, 3 years ago

double post error

Last edited 3 years ago by Curtisb (previous) (diff)

comment:18 by Nomis101, 3 years ago

FYI, with the patches applied from comment 13, the AC-4 streams from the samples of comment 14 are properly detected as AC4. But the files do play with no sound, because the channels are not detected (says "0 channels"). MediaInfo does detect the channels as "5.1 Main" and "Stereo Main".

% ffplay /Users/Nomis101/Downloads/ABC\ Stream\ -\ FFmpeg\ bug\ \#8349.ts
ffplay version N-100421-g1eb751955e Copyright (c) 2003-2020 the FFmpeg developers

built with Apple clang version 12.0.0 (clang-1200.0.32.28)
configuration: --pkg-config-flags=--static --enable-swscale --enable-avfilter --enable-fontconfig --enable-gpl --enable-version3 --enable-libass --enable-libbluray --enable-libfreetype --enable-libsoxr --enable-libaom --enable-libmp3lame --enable-librav1e --enable-encoder=librav1e --enable-libtheora --enable-libvorbis --enable-libvpx --disable-debug --enable-libmysofa --enable-libx264 --enable-libx265 --enable-libxvid --enable-nonfree --enable-libfdk-aac --enable-muxer=mov --enable-muxer=mp4 --enable-muxer=ipod --enable-encoder=eac3 --enable-encoder=ac3 --enable-encoder=flac --enable-ffplay --enable-librtmp --enable-libsmbclient --enable-opencl --enable-libssh --enable-openssl --enable-encoder=truehd --enable-bsf=aac_adtstoasc --enable-encoder=h264_videotoolbox --enable-encoder=hevc_videotoolbox --enable-sdl --extra-ldflags=-L/opt/local/lib
libavutil 56. 62.100 / 56. 62.100
libavcodec 58.115.102 / 58.115.102
libavformat 58. 65.100 / 58. 65.100
libavdevice 58. 11.103 / 58. 11.103
libavfilter 7. 93.100 / 7. 93.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100

[NULL @ 0x7f81b782ce00] Decoder requires channel count but channels not set
[NULL @ 0x7f81b7817000] Decoder requires channel count but channels not set
[NULL @ 0x7f81b782da00] Decoder requires channel count but channels not set
[mpegts @ 0x7f81b7808a00] stream 3 : no PTS found at end of file, duration not set
[mpegts @ 0x7f81b7808a00] Could not find codec parameters for stream 1 (Audio: ac4 (AC-4 / 0x342D4341), 0 channels): unspecified sample rate
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[mpegts @ 0x7f81b7808a00] Could not find codec parameters for stream 2 (Audio: ac4 (AC-4 / 0x342D4341), 0 channels): unspecified sample rate
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[mpegts @ 0x7f81b7808a00] Could not find codec parameters for stream 3 (Audio: ac4 (STPP / 0x50505453), 0 channels): unspecified sample rate
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, mpegts, from '/Users/polysom/Downloads/ABC Stream - FFmpeg bug #8349.ts':

Duration: 00:01:15.34, start: 12951.873511, bitrate: 3690 kb/s
Program 3

Stream #0:0[0x31]: Video: hevc (Main 10) ([36][0][0][0] / 0x0024), yuv420p10le(tv), 1280x720 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc
Stream #0:1[0x32](eng): Audio: ac4 (AC-4 / 0x342D4341), 0 channels
Stream #0:2[0x33](spa): Audio: ac4 (AC-4 / 0x342D4341), 0 channels
Stream #0:3[0x3a](ee`): Audio: ac4 (STPP / 0x50505453), 0 channels

[hevc @ 0x7f81b886d200] Could not find ref with POC 56
[hevc @ 0x7f81b8814e00] Could not find ref with POC 32 0B f=0/0
[hevc @ 0x7f81b8814e00] Could not find ref with POC 24
[hevc @ 0x7f81b8814e00] Could not find ref with POC 16
13006.05 M-V: -0.025 fd= 305 aq= 0KB vq= 370KB sq= 0B f=0/0

Last edited 3 years ago by Nomis101 (previous) (diff)

comment:19 by Nomis101, 3 years ago

Ah, sorry, the "0 channel" thing was just because of AV_CODEC_CAP_CHANNEL_CONF. If I add that to ac4dec.c I have sound with the sample files from above. So, it seems with this patch we are on a good way...

ffplay /Users/Nomis101/Downloads/ABC\ Stream\ -\ FFmpeg\ bug\ \#8349.ts
ffplay version N-100421-g1eb751955e Copyright (c) 2003-2020 the FFmpeg developers

built with Apple clang version 12.0.0 (clang-1200.0.32.28)
configuration: --pkg-config-flags=--static --enable-swscale --enable-avfilter --enable-fontconfig --enable-gpl --enable-version3 --enable-libass --enable-libbluray --enable-libfreetype --enable-libsoxr --enable-libaom --enable-libmp3lame --enable-librav1e --enable-encoder=librav1e --enable-libtheora --enable-libvorbis --enable-libvpx --disable-debug --enable-libmysofa --enable-libx264 --enable-libx265 --enable-libxvid --enable-nonfree --enable-libfdk-aac --enable-muxer=mov --enable-muxer=mp4 --enable-muxer=ipod --enable-encoder=eac3 --enable-encoder=ac3 --enable-encoder=flac --enable-ffplay --enable-librtmp --enable-libsmbclient --enable-opencl --enable-libssh --enable-openssl --enable-encoder=truehd --enable-bsf=aac_adtstoasc --enable-encoder=h264_videotoolbox --enable-encoder=hevc_videotoolbox --enable-sdl --extra-ldflags=-L/opt/local/lib
libavutil 56. 62.100 / 56. 62.100
libavcodec 58.115.102 / 58.115.102
libavformat 58. 65.100 / 58. 65.100
libavdevice 58. 11.103 / 58. 11.103
libavfilter 7. 93.100 / 7. 93.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100

[mpegts @ 0x7fd2f082ac00] stream 3 : no PTS found at end of file, duration not set
Input #0, mpegts, from '/Users/Nomis101/Downloads/ABC Stream - FFmpeg bug #8349.ts':

Duration: 00:01:15.34, start: 12951.873511, bitrate: 3690 kb/s
Program 3

Stream #0:0[0x31]: Video: hevc (Main 10) ([36][0][0][0] / 0x0024), yuv420p10le(tv), 1280x720 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc
Stream #0:1[0x32](eng): Audio: ac4 (AC-4 / 0x342D4341), 48000 Hz, 5.1(side), fltp
Stream #0:2[0x33](spa): Audio: ac4 (AC-4 / 0x342D4341), 48000 Hz, stereo, fltp
Stream #0:3[0x3a](ee`): Audio: ac4 (STPP / 0x50505453), 48000 Hz, 3.0, fltp

[hevc @ 0x7fd308885c00] Could not find ref with POC 56
13030.02 A-V: 0.019 fd= 174 aq= 0KB vq= 0KB sq= 0B f=0/0

comment:20 by Aman, 3 years ago

Cc: ffmpeg@tmm1.net added

I have a patch that fixed some issues with a few stations: https://github.com/FFmpeg/FFmpeg/commit/1b9ae54caf9d1b038583ee9d1e94f130b42b5f7d

comment:21 by Elon Musk, 3 years ago

Do you have samples to reproduce this, as that patch contradicts with specifications.

comment:22 by Elon Musk, 3 years ago

comment:23 by Yourgos Papanikolaou, 3 years ago

All i know is all the main stations in seattle have switched to ATSC 3.0 so I upgraded to a new HDHomeRun 4k for my Plex DVR. All I can see is really clear video with no audio stream found. So no football for me or anyone else in the same situation. Happy to help however I can and willing to chip in if needed.

in reply to:  23 ; comment:24 by Carl Eugen Hoyos, 3 years ago

Replying to georgeP:

Happy to help however I can

Did you see comment:14 and comment:21?

in reply to:  24 comment:26 by Yourgos Papanikolaou, 3 years ago

Replying to cehoyos:

Replying to georgeP:

Happy to help however I can

Did you see comment:14 and comment:21?

I have no idea how to do that. If you can provide instructions I will try.

comment:27 by MikeV, 3 years ago

I've uploaded a TS file from an OKC OTA station with AC-4 audio here:
https://drive.google.com/file/d/1xpEyd59cD4NgLtfYsWuBOrMjovzCO7xj/view?usp=sharing

Unfortunately I can't figure out how to demux the TS file and just upload the audio portion. If anyone has instructions for that, please let me know. I could record multiple samples.

comment:28 by phroenips, 3 years ago

Two more samples. These are 30 second extracts from a HDHomerun Quatro 4K. I'm also not sure how to demux just the audio, so these are video and audio

https://1drv.ms/v/s!ArfvDX-zLpfP9XamL2kwsu2JnpKR?e=TBE0XE
https://1drv.ms/v/s!ArfvDX-zLpfP9XVdkW4CMgI5EIKd?e=XvsCgN

in reply to:  22 ; comment:29 by mooninite, 3 years ago

Replying to richardpl:

This is latest AC4 WIP code: https://github.com/richardpl/FFmpeg/tree/ac4

I tested these patches against a 4.3 branch (Fedora/RPMFusion) and could successfully play live streaming data in the Dallas, TX market from a SiliconDust CONNECT 4K and Kodi. Audio is working. Thanks!

in reply to:  22 comment:30 by Nomis101, 3 years ago

Replying to richardpl:

This is latest AC4 WIP code: https://github.com/richardpl/FFmpeg/tree/ac4

Playback does also work nicely for me. But if I try to convert the audio stream in e.g. AAC, I see different errors with the provided samples.

Sample from comment 24 gives me:
[ac4 @ 0x7fef1480a200] substream audio data overread: 1153
Error while decoding stream #0:0: Invalid data found when processing input
[ac4 @ 0x7fef1480a200] substream audio data overread: 598
Error while decoding stream #0:0: Invalid data found when processing input
[ac4 @ 0x7fef1480a200] substream audio data underread: 8
[ac4 @ 0x7fef1480a200] substream audio data underread: 10eed= 229x
[ac4 @ 0x7fef1480a200] sect_cb[0][0] > 11
Error while decoding stream #0:0: Invalid data found when processing input
[ac4 @ 0x7fef1480a200] substream audio data underread: 257
[ac4 @ 0x7fef1480a200] substream audio data underread: 131
[ac4 @ 0x7fef1480a200] substream audio data overread: 1217
Error while decoding stream #0:0: Invalid data found when processing input
[ac4 @ 0x7fef1480a200] substream audio data underread: 104
[ac4 @ 0x7fef1480a200] substream audio data underread: 119
[ac4 @ 0x7fef1480a200] sect_cb[0][0] > 11
Error while decoding stream #0:0: Invalid data found when processing input
[ac4 @ 0x7fef1480a200] sect_cb[0][3] > 11
Error while decoding stream #0:0: Invalid data found when processing input
[ac4 @ 0x7fef1480a200] substream audio data underread: 106
[ac4 @ 0x7fef1480a200] substream audio data underread: 122
[ac4 @ 0x7fef1480a200] sect_cb[0][0] > 11
Error while decoding stream #0:0: Invalid data found when processing input

Sample from comment 27 gives me:
[ac4 @ 0x7fe01f008c00] substream audio data overread: 2
Error while decoding stream #0:1: Invalid data found when processing input
[mpegts @ 0x7fe020809a00] Packet corrupt (stream = 0, dts = 1229347550).
[ac4 @ 0x7fe01f008c00] invalid aspx num env: 7 (class 3)
Error while decoding stream #0:1: Invalid data found when processing input

Sample (first one) from comment 28 gives me:
[ac4 @ 0x7ff98980f600] substream audio data overread: 6
Error while decoding stream #0:2: Invalid data found when processing input

by csdesigns, 3 years ago

Attachment: atsc3.ts added

ATSC 3.0 OTA 5.1

in reply to:  22 comment:31 by Stephen Ferrell, 3 years ago

Last edited 3 years ago by Stephen Ferrell (previous) (diff)

comment:32 by LostDog, 3 years ago

I compiled the ac4 branch at https://github.com/richardpl/FFmpeg/tree/ac4 using Linux Mint 20.1. It built successfully and I was able to play the atsc3.ts samples with AC-4 audio using ffplay.

I've not been able to compile VLC or Kodi against this branch but I'm suspecting it's due to my own lack of understanding rather than the branch code.

in reply to:  32 ; comment:33 by Stephen Ferrell, 3 years ago

Status: reopenedopen
Last edited 3 years ago by Stephen Ferrell (previous) (diff)

in reply to:  33 ; comment:34 by LostDog, 3 years ago

Replying to ferrellsl:

Let us know if you're successful. I'd really like to have a PVR that records and plays ATSC3.0 streams without using a bunch of scripts and hacks. Over at the NextPVR forums there's a guy who has written some python scripts that use the binaries from this tree to transcode the ATSC3.0/AC4 audio stream into AC3 on-the-fly but I'm hoping for a cleaner solution.

For now, I can still record my ATSC3.0 channels using NextPVR and use the binaries from this tree for playback of those ATSC3.0 recordings without transcoding, and of course all the 4K channels in the Phoenix area are mirrored in 1080p/ATSC1.0 channels. I'm quite pleased with richardpl's progress. I was expecting things to move much slower than they have, or not at all. At least now I have a poor-man's PVR using scripts for playback. Having AC4 integrated natively into VLC, Kodi, or NextPVR would be very welcome from my standpoint.

I have successfully built Kodi v18.9 against the AC-4 branch of ffmpeg. ATSC3.0 captures work seemingly flawlessly with audio. I cannot verify if it's 5.1 and the channels are correct but on my computer with stereo headphones the audio sounds great.

Tuning live ATSC3.0 is really buggy using the HDHomerun plugins but it will occasionally play and when it does there is audio. I don't think this has anything to do with ffmpeg but rather the plugins themselves.

in reply to:  34 comment:35 by Stephen Ferrell, 3 years ago

Last edited 3 years ago by Stephen Ferrell (previous) (diff)

comment:36 by Stephen Ferrell, 3 years ago

Last edited 3 years ago by Stephen Ferrell (previous) (diff)

comment:37 by Moe Sparkman, 3 years ago

Priority: wishimportant

So I'm new to this. I'm on Plex installed on Ubuntu. I cloned this: https://github.com/richardpl/FFmpeg/tree/ac4. Configured it, but I'm unsure how to get plex use it. I appreciate any advice.

in reply to:  37 comment:38 by Stephen Ferrell, 3 years ago

Last edited 3 years ago by Stephen Ferrell (previous) (diff)

comment:39 by Carl Eugen Hoyos, 3 years ago

Priority: importantwish

in reply to:  39 ; comment:40 by Moe Sparkman, 3 years ago

Replying to cehoyos:

I did as you said. Unfortunately, no luck. I even tried both copying the binary to the PMS folder and creating a symbolic link, with no success. I'm a noob, sorry.

Thank you for your time.

in reply to:  40 comment:41 by Stephen Ferrell, 3 years ago

Last edited 3 years ago by Stephen Ferrell (previous) (diff)

in reply to:  40 comment:42 by Carl Eugen Hoyos, 3 years ago

Replying to Moe247:

Replying to cehoyos:

I'm a noob, sorry.

I don't know your exact task, but in this case, you should probably wait for a package made by somebody else.

comment:43 by Nomis101, 3 years ago

Instead of using an incomplete WIP patch in various customized builds, would somebody be able to finish this patch and submit it to the list?

in reply to:  21 comment:44 by Aman, 3 years ago

Replying to richardpl:

Do you have samples to reproduce this, as that patch contradicts with specifications.

The sample in comment:27 reproduces, as does this one: https://tmm1.s3.amazonaws.com/atsc3-aspx-num-env.ts

Where in the spec does it state that aspx_num_env is capped at 5?

comment:45 by Stephen Ferrell, 3 years ago

Last edited 3 years ago by Stephen Ferrell (previous) (diff)

in reply to:  45 comment:46 by Stephen Ferrell, 3 years ago

Last edited 3 years ago by Stephen Ferrell (previous) (diff)

comment:47 by Elon Musk, 3 years ago

Is this open source or what kind of endorsement is this at all?

in reply to:  47 comment:48 by Stephen Ferrell, 3 years ago

Last edited 3 years ago by Stephen Ferrell (previous) (diff)

comment:49 by prldm, 3 years ago

I compiled the ac4 branch of richardpl's fork and it looks like it can not decode AC4 which is inside an mp4 container.
https://www107.zippyshare.com/v/zsCHrWop/file.html

https://i.kek.sh/5APayCpR5HN.png

comment:50 by dotjoel, 3 years ago

I just wanted to point out that there is a bounty on this feature.
https://www.bountysource.com/issues/83125729-dolby-ac-4-support

comment:52 by Jim Scarborough, 3 years ago

Cc: Jim Scarborough added

in reply to:  49 comment:53 by Nicholas S Jenkins, 3 years ago

Replying to prldm:

I compiled the ac4 branch of richardpl's fork and it looks like it can not decode AC4 which is inside an mp4 container.

I also compiled that fork, and I downloaded various .ts and .mp4 samples from the web, and I noticed that it does just fine on some, and not others.
Specifically, I noticed that adjusting for Endian-ness:
0x342D4341 is 0x34(4) 2D(-) 43(C) 41(A) = "AC-4"
0x342D6361 is "ac-4", and does not work well.
2nd Update:
I made some edits and tested in trace mode, and the 4CC code (AC-4, or ac-4) made no difference... I'm now thinking this is probably that the AC-4 samples are .ts format, and the ac-4 samples are another file format, like .mov/.mp4, and that the de-muxing code needs to be written to detect AC-4 within those non-.ts formats, which will take me a long time to implement. ... I'm still going to work on this, but it seems no quick fixes for universal ac-4 support in ffmpeg.

Last edited 3 years ago by Nicholas S Jenkins (previous) (diff)

in reply to:  14 comment:54 by Nicholas S Jenkins, 3 years ago

Replying to Elon Musk:

Looks like nobody cares about AC-4, because if they care they would actually provide AC-4 samples here.

I realize this post is quite dated now; but I wanted to highlight that for people with HDHomeRun Connect 4K devices (and I assume successor Flex devices) that there is a trivially easy way for people in ATSC3.0 broadcast areas to capture raw feeds for testing with:
https://info.hdhomerun.com/info/troubleshooting:creating_a_sample
remember that ATSC3.0 stations are presented by HDHR as 100+channel number, so for me (picking up Cincinnati), 105.1, 109.1, 112.1, etc.
Example curl command:
curl http://192.168.0.37:5004/auto/v112.1?duration=120 > ../test_capture_of_112_1.ts
This capture avoids automatic transcoding by ffmpeg/ffmpeg-derived tools that will otherwise try to demux/remux and decode/encode broadcast formats (e.g. HEVC/AC-4) into assumed-preferred formats (e.g. MP2/H.264).
Since I'm now able to record off-air, I hope to help in testing + probably code integration into head branch of ffmpeg.
On a related note... do you know why?:
1) The Richardpl fork indicates it's from an ffmpeg branch 3 years old, and that can't be readily updated to current ffmpeg version (no big deal, only ~dozen sources look related to AC-4, but just curious)
2) but this thread would suggest the code is only 10 months old? ... and is there a separate discussion / real effort underway to integrate the code into ffmpeg head? (I wouldn't want to duplicate effort, but rather assist)

comment:55 by kenmac999, 2 years ago

Attached file as identified by mediainfo

General
ID : 1 (0x1)
Complete name : capture5003.ts
Format : MPEG-TS
File size : 2.15 MiB
Duration : 10 s 777 ms
Overall bit rate mode : Variable
Overall bit rate : 1 649 kb/s

Video
ID : 49 (0x31)
Menu ID : 3 (0x3)
Format : HEVC
Format/Info : High Efficiency Video Coding
Format profile : Main 10@L4@Main
Codec ID : 36
Duration : 10 s 794 ms
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate : 59.940 (60000/1001) FPS
Standard : Component
Color space : YUV
Chroma subsampling : 4:2:0 (Type 0)
Bit depth : 10 bits
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709

Audio #1
ID : 50 (0x32)
Menu ID : 3 (0x3)
Format : AC-4
Format/Info : Audio Coding 4
Commercial name : Dolby AC-4
Format version : Version 2
Codec ID : 6
Duration : 11 s 177 ms
Sampling rate : 48.0 kHz
Frame rate : 29.970 FPS (1601.6 SPF)
Compression mode : Lossy
Delay relative to video : 124 ms
Language : Spanish
I-Frame interval : 8 frames
Number of presentations : 1
NumberOfGroups : 1
Number of substreams : 1
Presentation #1 : Mono Main

Dialogue normalization : -24.00
Loudness : Yes

Integrated loudness (speech gated) : -28.4 LKFS (Automated C or L+R)
Integrated loudness (level gated) : -22.4 LKFS
Audio Loudness Standard : Manual
Realtime loudness corrected : Yes
Dialogue corrected : Yes (Automated C or L+R)

Dynamic Range Control : Yes
Group #s : 1

Group #1 : Main

Content classifier : Main
Channel coded : Yes
Number of substreams : 1
Substream #s : 1

Substream #1 : Mono

Channel mode : Mono
Channel layout : C
Dialogue enhancement : Yes

Enabled : Yes
Max gain : 9 dB

Audio #2
ID : 51 (0x33)
Menu ID : 3 (0x3)
Format : AC-4
Format/Info : Audio Coding 4
Commercial name : Dolby AC-4
Format version : Version 2
Codec ID : 6
Duration : 11 s 144 ms
Sampling rate : 48.0 kHz
Frame rate : 29.970 FPS (1601.6 SPF)
Compression mode : Lossy
Delay relative to video : 213 ms
Language : English
I-Frame interval : 8 frames
Number of presentations : 1
NumberOfGroups : 1
Number of substreams : 1
Presentation #1 : 5.1 Main

Dialogue normalization : -24.00
Loudness : Yes

Integrated loudness (speech gated) : -28.4 LKFS (Automated individual front channels)
Integrated loudness (level gated) : -22.1 LKFS
Audio Loudness Standard : Manual
Realtime loudness corrected : Yes
Dialogue corrected : Yes (Automated individual front channels)

Dynamic Range Control : Yes
Downmix : Yes

LoRo center mix gain : -3.0 dB
LoRo surround mix gain : -3.0 dB
LtRt center mix gain : -3.0 dB
LtRt surround mix gain : -3.0 dB
LFE mix gain : -3 dB

Group #s : 1

Group #1 : Main

Content classifier : Main
Channel coded : Yes
Number of substreams : 1
Substream #s : 1

Substream #1 : 5.1

Channel mode : 5.1
Channel layout : L R C LFE Ls Rs
Preprocessing : Yes

Phase 90 filter info : Not applied
Surround attenuation known : No
LFE attenuation known : No

Dialogue enhancement : Yes

Enabled : Yes
Max gain : 9 dB

Menu
ID : 48 (0x30)
Menu ID : 3 (0x3)
Duration : 10 s 777 ms
List : 49 (0x31) (HEVC) / 50 (0x32) (AC-4, Spanish) / 51 (0x33) (AC-4, English) / 57 (0x39) ()
Language : / Spanish / English

Last edited 2 years ago by kenmac999 (previous) (diff)

by kenmac999, 2 years ago

Attachment: capture5003.ts added

recorded from OKC Physical Channel atsc3:503000000:2

comment:56 by madas, 2 years ago

I have plenty of sample files also but they are too big to upload. If someone needs them feel free to shoot me a msg and I will upload them somewhere.

in reply to:  29 comment:57 by Bo Xu, 2 years ago

Replying to mooninite:

Replying to richardpl:

This is latest AC4 WIP code: https://github.com/richardpl/FFmpeg/tree/ac4

I tested these patches against a 4.3 branch (Fedora/RPMFusion) and could successfully play live streaming data in the Dallas, TX market from a SiliconDust CONNECT 4K and Kodi. Audio is working. Thanks!

Thanks for the ac4-branch! I cloned it (https://github.com/richardpl/FFmpeg/tree/ac4) and also checkout ac4-branch, but after I built it (in macOS with M1-cpu), I can ffplay atsc3.ts and got the video, but cannot hear audio. could you let me know how do you configure ac4-branch when building it or could you copy your configure-parameters to me? Thanks!

(the following is my configure parameters):

./configure --prefix=/Users/boxu/LIBs/ffmpeg-ac4/FFmpeg/build --enable-swscale --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-librsvg --enable-libtheora --enable-libopenjpeg --enable-libmodplug --enable-libsoxr --enable-libspeex --enable-libass --enable-libbluray --enable-lzma --enable-gnutls --enable-fontconfig --enable-libfreetype --enable-libfribidi --disable-libjack --disable-libopencore-amrnb --disable-libopencore-amrwb --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-indev=jack --enable-opencl --disable-outdev=xv --enable-audiotoolbox --enable-videotoolbox --enable-sdl2 --disable-securetransport --mandir=/opt/local/share/man --enable-static --enable-pthreads --cc=/usr/bin/clang --enable-libx265 --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-nonfree --enable-libfdk-aac --extra-ldflags=-L/opt/local/lib --disable-x86asm --enable-shared --enable-static --enable-encoder=eac3 --enable-encoder=ac3 --enable-decoder=ac4 --disable-avfilter

Last edited 2 years ago by Bo Xu (previous) (diff)

in reply to:  22 ; comment:58 by Mark Bumiller, 2 years ago

Replying to Elon Musk:

This is latest AC4 WIP code: https://github.com/richardpl/FFmpeg/tree/ac4

Thank you for your work! I was able to build and run ffplay via your branch. I took the commits, made some minor changes to pass fate, and rebased to be merged without conflict. Code has been published on my personal fork https://github.com/makrsmark/FFmpeg/tree/ac4

It looks like the commits line up with existing patches https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=451 What is there a way the patches can be updated or should new patches be submitted?

Last edited 2 years ago by Mark Bumiller (previous) (diff)

comment:59 by skyler, 21 months ago

What I would like to know is whether there is a static build of ffmpeg similar to John VanSickle's build at https://johnvansickle.com/ffmpeg/ that include the AC4 support.

In case anyone wonders why people are wanting this, I refer you to the thread at https://forum.silicondust.com/forum/viewtopic.php?t=77067&sid=0446c9341c1db6d3f24a2db24a5dd059 which in a series of posts pretty much explains the current situation. But the short version is that if you purchase a HDHomeRun tuner capable of receiving ATSC3 signals, by default you probably won't get a usable audio signal unless all your equipment is very new (basically it must have Dolby Atmos support, as I understand it). This also means you don't get audio on things like computer desktop systems or HTPC's, since none of them that I'm aware of have AC4 audio support.

Silicon Dust's current solution is to have their devices send the AC4 audio to a cloud server where the audio is turned around and sent back to the device as a two channel STEREO stream. So instead of getting 5.1 audio as is usual with current ATSC1, you get 1970's era stereo. And there are other disadvantages as well - if you lose your internet connection or it gets very congested (as might happen when hundreds of users are all sending streams to be decoded during prime time), you would lose the audio and possibly would not be able to view or record live TV. If you record a show using backend software (Tvheadend, MythTV, etc.) you will either record the AC4 audio (which still can't be played on most devices) or the stereo from the cloud server, depending I suppose on how you have configured the HDHomeRun device. And also, for those who care about such things, it gives Silicon Dust a way to track what you are watching (which is a big NOPE as far as I'm concerned, although some people don't seem to care if their viewing habits are tracked).

A version of ffmpeg with AC4 support, on the other hand, should be able to convert the AC4 audio to AC3 or AAC or even MP2, whatever would be compatible with a user's receiver or computer or HTPC in almost real time, or on a previously recorded program if that is desired. And this would not be in any way dependent on Silicon Dust's servers, nor would it limit you to only two audio channels.

I might have purchased a new HDHomeRun device with ATSC3 support almost a year ago, when stations in my area first started offering ATSC3 programming, if it weren't for the stupid way they are handling the audio. Now, I think the U.S. FCC made a big mistake by allowing the use of AC4 in the first place, but that's another discussion for another forum. In the meantime, it would be really helpful if support for AC4 decoding could be included in either the main ffmpeg distribution, or failing that, in a static build that will run on Linux systems so it can be used with server-based backends like Tvheadend or MythTV or similar software (similar to the John Van Sickle build). Really, I would think that only AC4 decoding is needed at the present time; I can't think of a single situation where anyone would want to encode using AC4 and would not already have access to a hardware-based encoder.

I know some of you guys are conversant enough in Linux to be able to build your own custom builds of ffmpeg and that is great, but I haven't the foggiest idea how to do something like that and unless someone publishes "cookbook" type instructions (or better yet, a video walkthough of how to do it) on a Linux system, that will probably forever be beyond my skill set. That's why I would really like to see this in the main ffmpeg distribution, or at least in a separate static build at some point in the not too distant future. Right now all ATSC3 signals are still available as ATSC1 (though not always with the exact same coverage areas) but that will not be the case forever.

comment:60 by no_one, 20 months ago

Priority: wishimportant

+1 for AC4 decoding. It looks like a solution is in our grasp, and I am excited to see this get mainlined.

comment:61 by Carl Eugen Hoyos, 20 months ago

Priority: importantwish

in reply to:  61 comment:62 by Mark Bumiller, 20 months ago

Replying to Carl Eugen Hoyos:

What's the reason for the drop in priority? (I see why now) It seems like the feature has been implemented for almost 2 years. What is needed to get this merged?

Last edited 20 months ago by Mark Bumiller (previous) (diff)

in reply to:  58 comment:63 by skyler, 19 months ago

Replying to Mark Bumiller:

Thank you for your work! I was able to build and run ffplay via your branch. I took the commits, made some minor changes to pass fate, and rebased to be merged without conflict. Code has been published on my personal fork https://github.com/makrsmark/FFmpeg/tree/ac4

Thank you for posting that. After a lot of trial and error we were able to get it to compile, including one false start where it appeared to have compiled correctly but did not convert the audio. Finally got it working only to discover the only local ATSC3 channel we could receive is only sending mono audio (not even stereo!). :(

Last edited 19 months ago by skyler (previous) (diff)

comment:65 by videotranscoder, 15 months ago

Cc: videotranscoder added

comment:66 by blah420, 14 months ago

Priority: wishcritical
Last edited 14 months ago by blah420 (previous) (diff)

comment:67 by Nik, 12 months ago

Keywords: ac4 added

comment:68 by Nik, 12 months ago

Component: undeterminedavcodec

comment:70 by Balling, 10 months ago

I think decoding should be merged.

in reply to:  70 comment:71 by Nomis101, 10 months ago

Resolution: fixed
Status: closedreopened

Replying to Balling:

I think decoding should be merged.

Yes, you are right. I guess I spoke too soon. It still does not work. It now detects the AC-4 steam properly, but FFmpeg is unable to decode or recode it.

comment:72 by Balling, 10 months ago

The bug is only about muxing though.

in reply to:  72 comment:73 by Robert Houghton, 9 months ago

Replying to Balling:

The bug is only about muxing though.

I tried to open #10450 to specifically address decoding of AC-4 audio and was shut down for being a duplicate ticket.

Is there any current progress or effort on decoding?

comment:74 by Elon Musk, 9 months ago

No any progress.

in reply to:  description comment:75 by Romualds Cirsis, 8 months ago

Cc: Romualds Cirsis added

comment:76 by Leo Izen, 8 months ago

Priority: criticalwish

comment:77 by Leo Izen, 8 months ago

Stop changing the priority to critical. It won't make anything happen faster.

comment:78 by Clint, 8 months ago

Cc: Clint added

comment:79 by thovo, 7 months ago

Cc: thovo added

comment:80 by davygrvy, 6 months ago

I can't watch ATSC 3.0 television without this feature. Thank you for working on it

comment:81 by davygrvy, 6 months ago

Cc: davygrvy added

in reply to:  58 comment:82 by mooninite, 6 months ago

Replying to Mark Bumiller:

Thank you for your work! I was able to build and run ffplay via your branch. I took the commits, made some minor changes to pass fate, and rebased to be merged without conflict. Code has been published on my personal fork https://github.com/makrsmark/FFmpeg/tree/ac4

These patches no longer function against FFmpeg 6.0. It detects the AC-4 codec, but it is not parsing the stream. FFmpeg shows 0 channels and unspecified sample rate and apps like mpv cannot play the stream.

comment:83 by P Liu, 5 months ago

I was able to make it work (with the latest ffmpeg version) by rebasing the patches and fixing a few issues.
https://github.com/pliu6/FFmpeg

I can play "atsc3.ts" with my local build.

Last edited 5 months ago by P Liu (previous) (diff)

comment:84 by Carlton, 4 months ago

I have a github repo based on an ffmpeg building script that combines the patches from the post above and the 6.1 release that can build a static FFmpeg executable with the AC4 decode. I've used this to stream from my HDHR an ATSC 3.0 channel to mediamtx and convert the audio to AAC and watched on my phone with no issues with audio. The repo is below:

https://github.com/funnymanva/ffmpeg-with-ac4

If you want to do a quick test I have a container image built, repo address below, with all libraries in the script enabled available and the AC4 patch. This is from my private gitlab repo so use sparingly just for testing, please. Only supports vaapi hardware encoding.

registry.home.oriley.net/apps/ffmpeg:v6.1

comment:85 by Hoof, 5 weeks ago

Also here because because I cannot hear ATSC 3.0 audio. Any chance this gets supported?

Note: See TracTickets for help on using tickets.