AC-4 Audio?

ATSC 3.0 Forum
Post Reply
TBR
Posts: 72
Joined: Fri Feb 19, 2021 12:26 pm
x 1

Re: AC-4 Audio?

Post by TBR »

ferrellsl wrote: Wed Mar 10, 2021 12:10 pm Earlier in this thread LostDog and I both created VLC builds for Windows that incorporated richardpl's AC-4 branch of ffmpeg but unbeknownst to us at the time, VLC doesn't use ffmpeg for the audio playback portion of a video stream, so there's no audio when playing back ATSC3.0/AC-4 streams. This was very disappointing because it was a lot of work to get VLC to build against its many dependencies. It took me nearly 5 days to achieve a successful build.

I do about 95% of my coding on Windows and the rest on Linux and MacOS so I don't have a lot of experience to share in regard to Android. But I have used the Termux development environment (root not required) on native and emulated Android to create apps. It should be relatively trivial to create a command-line version of ffmpeg/ffplay for Android if you want to try that first under Termux. See: https://termux.com/ or over at Google Play: https://play.google.com/store/apps/deta ... com.termux
Thanks for the heads-up. If I do try to rework VLC, I'll certainly take into account kyl416's suggestions along with the rest of the remarks.

I was planning on working in Android Studio, but I'll keep Termux in mind depending on the source code. All the current languages are "new-fangled" to me (I said I was old: like pre-Unix old and programming-via-toggle-switch old) so I might as well tackle Java derivatives as C derivatives--or probably both. I am looking for a "lightweight" player source, though, as ffplay needs a lot of CPU processing.

I see there's a HDHR Kodi add-on, and LostDog was working on Kodi with FFmpeg-ac4. Perhaps that's the best alternative if I can do (or use) something similar on the Android Kodi app.
I was able to successfully build an Android x86 version of ffmpeg/ffplay using Termux and an edited build script taken from the Termux packages repo.

Here's the edited build.sh. Notice that the hash check is disabled and that I replaced the Termux curl command with "git clone" and pointed it to richardpl's repo.
Did you get an APK as a result of the build?

ferrellsl
Posts: 39
Joined: Sat Oct 17, 2020 11:57 pm
Location: Mesa, AZ
x 14
Contact:

Re: AC-4 Audio?

Post by ferrellsl »

(;-)
Last edited by ferrellsl on Wed May 05, 2021 9:39 pm, edited 1 time in total.

TBR
Posts: 72
Joined: Fri Feb 19, 2021 12:26 pm
x 1

Re: AC-4 Audio?

Post by TBR »

mooninite wrote: Wed Dec 30, 2020 9:43 pm
peanutbutter71 wrote: Mon Dec 28, 2020 3:09 pm I compiled this fork of ffmpeg on linux:

https://github.com/richardpl/FFmpeg/tree/ac4

I don't think this is in the main trunk for ffmpeg, but this is at least promising.
That branch is against the main trunk. I compiled a 4.3.x version and Kodi now plays audio for ATSC 3.0 Dallas, TX stations (H.265 + AC-4).
I have VERY limited knowledge of Kodi but it does seem to directly play from the tuner (with no audio on ATSC 3.0 channels) without the lagging problems of ffplay and it is open-source (python, if I'm not confused). If there isn't already code I could download, any hints on how to combine richardpl's ffmpeg-ac4 with Kodi?

ferrellsl
Posts: 39
Joined: Sat Oct 17, 2020 11:57 pm
Location: Mesa, AZ
x 14
Contact:

Re: AC-4 Audio?

Post by ferrellsl »

(;-)
Last edited by ferrellsl on Wed May 05, 2021 9:40 pm, edited 1 time in total.

TBR
Posts: 72
Joined: Fri Feb 19, 2021 12:26 pm
x 1

Re: AC-4 Audio?

Post by TBR »

ferrellsl wrote: Thu Mar 11, 2021 9:35 am
TBR wrote: Thu Mar 11, 2021 8:42 am
mooninite wrote: Wed Dec 30, 2020 9:43 pm
That branch is against the main trunk. I compiled a 4.3.x version and Kodi now plays audio for ATSC 3.0 Dallas, TX stations (H.265 + AC-4).
I have VERY limited knowledge of Kodi but it does seem to directly play from the tuner
Lost Dog was able to compile Kodi with AC-4 support. You should probably ask him for a download link. See the last post on page 12 of this thread.
So at least two people have accomplished this feat. Perhaps somebody has the code on GitHub.

The Kodi 18.3 Chinese derivative ("KDPlayer") on the T95 Mini Android TV box crashes intermittently with my weak ATSC 3 signal. Hopefully Kodi 19 will do that less often. If I have to make an app myself, I may try to push an interim app to the Google Play Store for Android devices without AC-4 hardware support.

Meanwhile, another approach: since my Galaxy S9 with Android 10 plays the HDHR app so well, for $20 I ordered both an HDMI adapter and an HDMI-to-RCA converter to tie into my AV network. I don't expect great resolution, but less eyestrain.

It's only been 3 weeks since I got the Connect 4K, expecting it to be plug-n-play. No wonder I have a headache. :lol:

ferrellsl
Posts: 39
Joined: Sat Oct 17, 2020 11:57 pm
Location: Mesa, AZ
x 14
Contact:

Re: AC-4 Audio?

Post by ferrellsl »

(;-)
Last edited by ferrellsl on Wed May 05, 2021 9:40 pm, edited 1 time in total.

TBR
Posts: 72
Joined: Fri Feb 19, 2021 12:26 pm
x 1

Re: AC-4 Audio?

Post by TBR »

ferrellsl wrote: Thu Mar 11, 2021 2:20 pm
TBR wrote: Thu Mar 11, 2021 12:13 pm The Kodi 18.3 Chinese derivative ("KDPlayer") on the T95 Mini Android TV box crashes intermittently with my weak ATSC 3 signal.
Does your T95 not support the HDHomeRun app?
The T95 plays the HDHR app, but without audio on the ATSC 3 channels. The app apparently does not have software support for AC-4 decoding.

The logical thing would be to add the software support to the app, but SiliconeDust apparently does not want to be involved in adding codecs. The source code also appears to be private, which prevents me from offering modifications.

ferrellsl
Posts: 39
Joined: Sat Oct 17, 2020 11:57 pm
Location: Mesa, AZ
x 14
Contact:

Re: AC-4 Audio?

Post by ferrellsl »

(;-)
Last edited by ferrellsl on Wed May 05, 2021 9:41 pm, edited 1 time in total.

TBR
Posts: 72
Joined: Fri Feb 19, 2021 12:26 pm
x 1

Re: AC-4 Audio?

Post by TBR »

ferrellsl wrote: Thu Mar 11, 2021 3:04 pm That's odd because all my Android devices, even the oldest ones running Android 7 and LineageOS, (pre-AC-4 audio), play the audio for every ATSC3.0/AC-4 channel in the Phoenix area using the HDHomeRun app. It's my understanding that the audio decoding is baked into the HDHomeRun app. AC-4 audio decoding isn't something built into the OS itself.

EDIT: Well, I take back what I said about the audio on one of my devices. I have a MiPad running LineageOS that won't play the audio OR video on the ATSC3.0 channels so apparently there is something missing in the OS that prevents HEVC and AC-4 playback. I get a black screen that has the words "Audio Only" dead centered on the screen with no audio and no video. Not sure if I should be amused or annoyed.

I guess it could also be CPU/GPU related as well. My old tablet may not support the necessary CPU/GPU instructions for decoding h.265/AC-4.
Android devices vary both by OS levels and by hardware capabilities. My S9 is much more powerful than the T95 (and much more expensive). And the HDHR app itself undoubtedly varies between Android and Windows.

Audio decoding may well be baked into the Windows app: it works on one machine, breaks on another machine, and refuses to play HEVC on two other machines (perhaps it's waiting for an "initial frame" in the video stream that never comes). That's another thread.

As an interim transcoding measure, I'm playing with turning the AC-4 audio into AC-3 (without decoding the video) using richardpl's FFmpeg-ac4 and passing it on to another device. Not something I've done before, so I have yet to work out the output format, but it should go something like this:

Code: Select all

ffmpeg -i http://192.168.x.xx:5004/auto/v1xx.x -c:v copy -c:a:1 ac3 -f mpegts http://192.168.x.xx:5444
That last >> http://192.168.x.xx:5444 << has me confused, both the address I should use and the protocol. The -c:v copy switch tells ffmpeg not to mess with the video stream, the -c:a switch tells it to select audio stream 1 and encode it in AC-3, and the -f mpegts switch says to put the output in an MpegTS wrapper.

Another issue is the audio channel selection. v102.1 in Detroit carries the main audio in stereo on audio stream 1 but the side channels are 5.1 on audio stream 0. I assume to get 7.1 audio the side channels are added to the stereo stream. By default FFmpeg chooses the audio stream with the most channels, which means it misses the main audio stream. I expect this could be remixed properly during the transcoding (or using ffplayer). However, this may or may not be a "standard" audio format for ATSC 3.0 so it may vary from station to station.

ferrellsl
Posts: 39
Joined: Sat Oct 17, 2020 11:57 pm
Location: Mesa, AZ
x 14
Contact:

Re: AC-4 Audio?

Post by ferrellsl »

(;-)
Last edited by ferrellsl on Wed May 05, 2021 9:41 pm, edited 1 time in total.

TBR
Posts: 72
Joined: Fri Feb 19, 2021 12:26 pm
x 1

Re: AC-4 Audio?

Post by TBR »

Windows App Black Blank Screen Fix

Turn OFF >> Use AC3 passthrough when possible << in settings

The Android app (which plays the HEVC video regardless) does not have this switch, unfortunately.

TBR
Posts: 72
Joined: Fri Feb 19, 2021 12:26 pm
x 1

Re: AC-4 Audio?

Post by TBR »

TBR wrote: Thu Mar 11, 2021 12:13 pm Meanwhile, another approach: since my Galaxy S9 with Android 10 plays the HDHR app so well, for $20 I ordered both an HDMI adapter and an HDMI-to-RCA converter to tie into my AV network. I don't expect great resolution, but less eyestrain.
An update for anyone tempted to try a similar method:

The HDMI adapter outputs well (perhaps 4K well), but the Samsung HDMI interface has drastically changed since my old S3. Instead of duplicating the display, the HDMI output is similar to a desktop. But I could run the HDHR app and it looked great on the big screen. The adapter does heat up, so durability is questionable.

The HDMI-to-RCA converter: not so much. It outputs at 480i which makes navigation quite difficult on the Samsung DeX HDMI interface. I can pipe to it via the Acer desktop, though, for low-resolution distribution throughout the house.

hdhruser
Posts: 12
Joined: Mon Dec 31, 2012 6:32 pm

Re: AC-4 Audio?

Post by hdhruser »

TBR wrote: Fri Mar 12, 2021 9:53 pm As an interim transcoding measure, I'm playing with turning the AC-4 audio into AC-3 (without decoding the video) using richardpl's FFmpeg-ac4 and passing it on to another device. Not something I've done before, so I have yet to work out the output format, but it should go something like this:

Code: Select all

ffmpeg -i http://192.168.x.xx:5004/auto/v1xx.x -c:v copy -c:a:1 ac3 -f mpegts http://192.168.x.xx:5444
That last >> http://192.168.x.xx:5444 << has me confused, both the address I should use and the protocol. The -c:v copy switch tells ffmpeg not to mess with the video stream, the -c:a switch tells it to select audio stream 1 and encode it in AC-3, and the -f mpegts switch says to put the output in an MpegTS wrapper.
I don't know if this will help you at all, but it looks somewhat similar to what you are trying to do. It is decoding the audio in real time from a satellite TV channel from a big old C-band satellite dish, that sends six channels of audio (5.1 format) in three discrete 2-channel streams. You should not need the complex filter but the rest might be useful. I just thought perhaps looking at the ffmpeg command they use might help you in some way, though since you are not using Tvheadend you'll probably have to make some adjustments.

https://freetoairamerica.wordpress.com/ ... -nameless/

The one thing I would really like to see is a static build of richardpl's ffmpeg for LINUX, similar to the ones at https://johnvansickle.com/ffmpeg/ for the master branch. Not everyone uses Windows, and at the same time not everyone that uses Linux (particularly as a home theatre system) is a programmer or is capable of compiling from source code. So a static build of richardpl's ffmpeg for Linux would be very helpful.

Since I mentioned Tvheadend, has anyone been successful in using a HDHR ATSC 3.0 capable unit with Tvheadend, and if so does Tvheadend record correctly and reliably, in a way that can be played back using Kodi or VLC (with good audio)? If it all works other than the audio then a variation of the technique shown in the above linked article would probably work, assuming you can install a build of ffmpeg that can convert audio from AC4 to AC3 or EAC3 in real time. And as I said, for that it would be very helpful to have a static build of richardpl's ffmpeg, at least until his code gets implemented in the main version (assuming that will happen sooner or later?).

ferrellsl
Posts: 39
Joined: Sat Oct 17, 2020 11:57 pm
Location: Mesa, AZ
x 14
Contact:

Re: AC-4 Audio?

Post by ferrellsl »

(;-)
Last edited by ferrellsl on Wed May 05, 2021 9:42 pm, edited 1 time in total.

TBR
Posts: 72
Joined: Fri Feb 19, 2021 12:26 pm
x 1

Re: AC-4 Audio?

Post by TBR »

ferrellsl wrote: Tue May 04, 2021 9:56 pm You're also making things appear to be way too difficult for an average Linux user. Building the binaries from richarpl's source tree is as simple as typing in the following command in a terminal window where you've downloaded his code: ./configure & make

If you're not able to unzip some files, open a terminal window and type: ./configure & make, then you probably shouldn't be using Linux in the first place.
Er, not really that simple. ;) Once you have all the requisite libraries, then you can "./configure & make." Otherwise you won't get components such as ffplay.

FFmpeg has a page detailing most of the preparatory installs (seems to me there is one more that throws an error, but I found the answer online). It took me a bit, but I fumbled my way through it. You may not need all the libraries, depending on your application, but you can always "./configure & make" again if you don't have enough additional resources installed.

One other tip: if you use sudo elevation and actually install your build, put an update "hold" on FFmpeg after it's built or it will be automatically "updated" to the latest standard version and the ac-4 decoding will be lost.

Post Reply