AC-4 Audio?

ATSC 3.0 Forum
Post Reply
Christian
Posts: 4
Joined: Wed Jan 20, 2021 1:29 pm

Re: AC-4 Audio?

Post by Christian »

ferrellsl wrote: Tue Jan 26, 2021 3:35 pm
Here's a Win64 build with the shared libraries. https://www.dropbox.com/s/bze1a5nrhq63u ... d.zip?dl=1

Here's a list of files in the archive:
avcodec-58.dll
avcodec.dll
avdevice-58.dll
avdevice.dll
avfilter-7.dll
avfilter.dll
avformat-58.dll
avformat.dll
avutil-56.dll
avutil.dll
ffmpeg.exe
ffplay.exe
ffprobe.exe
libbz2-1.dll
libiconv-2.dll
libintl-8.dll
liblzma-5.dll
libstdc++-6.dll
libwinpthread-1.dll
libzstd.dll
SDL2.dll
swresample-3.dll
swresample.dll
swscale-5.dll
swscale.dll
zlib1.dll
Awesome thanks, is it possible that you can also compile the 32bit version?

Christian
Posts: 4
Joined: Wed Jan 20, 2021 1:29 pm

Re: AC-4 Audio?

Post by Christian »

Christian wrote: Fri Jan 29, 2021 3:12 am
ferrellsl wrote: Tue Jan 26, 2021 3:35 pm
Here's a Win64 build with the shared libraries. https://www.dropbox.com/s/bze1a5nrhq63u ... d.zip?dl=1

Here's a list of files in the archive:
avcodec-58.dll
avcodec.dll
avdevice-58.dll
avdevice.dll
avfilter-7.dll
avfilter.dll
avformat-58.dll
avformat.dll
avutil-56.dll
avutil.dll
ffmpeg.exe
ffplay.exe
ffprobe.exe
libbz2-1.dll
libiconv-2.dll
libintl-8.dll
liblzma-5.dll
libstdc++-6.dll
libwinpthread-1.dll
libzstd.dll
SDL2.dll
swresample-3.dll
swresample.dll
swscale-5.dll
swscale.dll
zlib1.dll
Awesome thanks, is it possible that you can also compile the 32bit version?

My configure command looks like this:
./configure --prefix=${WORKSPACE} --extra-cflags="-I$WORKSPACE/include" --extra-ldflags="-L$WORKSPACE/lib" --libdir="@loader_path" --arch=x86 --target-os=mingw32 --cross-prefix=i686-w64-mingw32- --enable-cross-compile --disable-static --enable-shared --disable-debug --disable-doc --disable-gpl

Unluckily ffplay is not build, probably I have to create a windows binary too.

Lost Dog
Posts: 137
Joined: Tue Jul 03, 2007 11:46 pm
x 5

Re: AC-4 Audio?

Post by Lost Dog »

ferrellsl wrote: Tue Jan 26, 2021 3:35 pm [

Here's a Win64 build with the shared libraries. https://www.dropbox.com/s/bze1a5nrhq63u ... d.zip?dl=1
Is this with the modified source to have it recognize the AC-4 codec?

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

Re: AC-4 Audio?

Post by ferrellsl »

Christian wrote: Fri Jan 29, 2021 3:12 am

Awesome thanks, is it possible that you can also compile the 32bit version?
No, I won't be compiling a 32-bit version.

If you're using MSVC for your build you won't get ffplay.exe. You need to switch to an msys2 or cygwin environment if you want ffplay.exe. My configure script for shared libraries was this: ./configure --arch=x86_64 --enable-shared --disable-static

Next type: make
Last edited by ferrellsl on Fri Jan 29, 2021 9:14 am, edited 1 time in total.

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

Re: AC-4 Audio?

Post by ferrellsl »

Lost Dog wrote: Fri Jan 29, 2021 8:30 am
ferrellsl wrote: Tue Jan 26, 2021 3:35 pm [

Here's a Win64 build with the shared libraries. https://www.dropbox.com/s/bze1a5nrhq63u ... d.zip?dl=1
Is this with the modified source to have it recognize the AC-4 codec?
Yes

Christian
Posts: 4
Joined: Wed Jan 20, 2021 1:29 pm

Re: AC-4 Audio?

Post by Christian »

Yes I saw it, thanks - I just wonder why I am unable to compile it without the requirement for those msys shared libraries. It still complains that I have to have a libgcc_s_sjlj-1.dll. I thought static linking should prevent this.

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

Re: AC-4 Audio?

Post by ferrellsl »

Christian wrote: Fri Jan 29, 2021 9:11 am Yes I saw it, thanks - I just wonder why I am unable to compile it without the requirement for those msys shared libraries. It still complains that I have to have a libgcc_s_sjlj-1.dll. I thought static linking should prevent this.
If you want a static build of ffmpeg without any of the msys2 DLL's, you have to switch to a MSVC build. Here's the script I use for that but remember you won't get an ffplay.exe even with the --enable-ffplay as ffplay.c uses c99 code and the MSVC cl compiler doesn't support c99, only c89:

#first, open msys2_shell.cmd with a text editor and remove the REM in front of the line that says: set MSYS2_PATH_TYPE=inherit
#It's located in your c:\msys264 folder and the CMD file is called msys2_shell.cmd. Next, open an msys2 shell from within your Visual Studio x64 command prompt by typing c:\msys64\msys2_shell.cmd
# rename the link.exe in your /usr/bin folder to link.exe.bak
#check to see which link.exe is being used by typing: which link, and which cl. You should see MSVC versions
#if you see /usr/bin/link you need to rename the link in that folder to link.exe.bak
#Next, in your msys2 shell, cd to your ffmpeg folder
#next, run this shell script
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export CC=cl
./configure \
--toolchain=msvc \
--arch=x86_64 \
--enable-yasm \
--enable-asm\
--enable-static \
--enable-ffplay \
--disable-shared
#next, run the make command
Last edited by ferrellsl on Fri Jan 29, 2021 10:46 am, edited 2 times in total.

Lost Dog
Posts: 137
Joined: Tue Jul 03, 2007 11:46 pm
x 5

Re: AC-4 Audio?

Post by Lost Dog »

ferrellsl wrote: Fri Jan 29, 2021 9:08 am
Lost Dog wrote: Fri Jan 29, 2021 8:30 am

Is this with the modified source to have it recognize the AC-4 codec?
Yes
Fantastic! Great job! Do you have a list of the files you edited?

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

Re: AC-4 Audio?

Post by ferrellsl »

Lost Dog wrote: Fri Jan 29, 2021 9:40 am
ferrellsl wrote: Fri Jan 29, 2021 9:08 am
Lost Dog wrote: Fri Jan 29, 2021 8:30 am

Is this with the modified source to have it recognize the AC-4 codec?
Yes
Fantastic! Great job! Do you have a list of the files you edited?
I didn't edit any of the files. I just did a regular build with msys2 64 on richardpl's branch.

My configure looked like this: ./configure --arch=x86_64 --enable-shared --disable-static
Then I just ran the make command.

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

Re: AC-4 Audio?

Post by ferrellsl »

Christian wrote: Fri Jan 29, 2021 9:11 am Yes I saw it, thanks - I just wonder why I am unable to compile it without the requirement for those msys shared libraries. It still complains that I have to have a libgcc_s_sjlj-1.dll. I thought static linking should prevent this.
When using the static build switch with msys2 or cygwin, your exe will still require the msys2 or cygwin DLL files. Using the static switch when compiling will only generate ffmpeg exe's that don't require the ffmpeg DLLs such as avcodec.dll and avcodec-58.dll, etc. The exe's will always rely on the DLLs of their build environment, such as libwinpthread-1.dll, libstdc++-6.dll, etc., for an msys2 build.

Even if you switch to a MSVC build environment and use static linking, you will have standalone exe files but even they rely on DLL files such as Microsoft's msvcrt.dll. You just don't see the DLLs because they are hiding in your Windows folder by default.

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

Re: AC-4 Audio?

Post by ferrellsl »

I decided to build an AC-4 capable video player based on the code found here: https://github.com/itisyang/playerdemo

It only has 3 dependencies, SDL2, QT, and ffmpeg so I set about updating it to support richardpl's ffmpeg/AC4 branch. I normally avoid github projects that depend on QT for several reasons but this project is very well-written and modular so it was very easy to compile it against the ffmpeg/AC4 branch. The majority of my time was spent Anglicizing all the dialogs and menus because the author is Chinese and had hardcoded most of the menus and dialogs. I also added the ability to read mpeg TS files directly as that was missing. I've tested it on MKV files and TS files containing AC-4 audio streams and it works great so I suspect it will read any format supported by ffmpeg.

My build environment is Visual Studio 2015 and QT5.6 and the binary is 64-bit. My apologies to those who want 32-bit builds but I have no desire to re-tool my developer system which is entirely 64-bit.
I'm an applications developer, not a video (encode/decode) - (mux/demux) developer, so I will only be able to help you squash bugs in the UI and possibly add more file types.

You can download the Player here: https://www.dropbox.com/s/uuf16gxqs2s4b ... 4.zip?dl=1

Just unzip the files to the folder of your choice and run the playerdemo.exe file. It has all the playback controls that one would expect from a modern video player.

If you want to test it, here's a 40MB TS file with HEVC video encoding and AC-4 audio: https://www.dropbox.com/s/vzv66pz54phfs ... .1.ts?dl=1

Anyway, I hope somebody will get some use out of this player. It was actually a pleasure to update and build, unlike VLC which is a total dumpster fire.

Edit: Almost forgot, the keyboard shortcuts can be found under the About dialog, just right-click on the screen to bring up the context menu.

Link to screenshot of player: https://ibb.co/tZ3Zf05
Last edited by ferrellsl on Wed Feb 03, 2021 1:18 am, edited 2 times in total.

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

Re: AC-4 Audio?

Post by ferrellsl »

Just a quick follow-up on my previous post.

If want to use this player to view your tuner's media streams, you can do so with the ffmpeg.exe in the archive that I linked in my earlier posts. For example, to stream channel 161.1 here in Phoenix which uses HEVC and AC4 audio, open a command prompt and type:
ffmpeg -i http://x.x.x.x:5004/auto/v161.1 -b 900k -vcodec copy -r 60 -y test.mkv

Just change the X's to your tuner's IP address.

This will create an ever growing video file named test.mkv in the same folder as your ffmpeg.exe file. Now just run the playerdemo.exe and open the test.mkv file.

You can also just use wget to get the raw TS stream:

wget -O test.ts http://x.x.x.x:5004/auto/v161.1

Then use the player to open the TS file.

This also works for RTSP camera streams as well. For password protected cameras substitute your user ID and password, your camera's IP address and stream path I.e: ffmpeg -i rtsp://admin:password@x.x.x.x:554/x -b 900k -vcodec copy -r 60 -y test.mkv

For cameras not using a password: ffmpeg -i rtsp://x.x.x.x:554/x -b 900k -vcodec copy -r 60 -y test.mkv

KeeterJ
Posts: 2
Joined: Sun Jan 31, 2021 2:58 pm
Location: Vancouver, WA, US
x 2

Re: AC-4 Audio?

Post by KeeterJ »

I want to thank ferrellsl for building an ffmpeg.exe that supports AC-4. You inspired me this weekend to try it. I grabbed an HDHR .mpg file from a DVR server on a Win10 PC and converted it to a traditional .ts transport stream file using

ffmpeg -i "<my input file>.mpg" -y -map 0:0 -vcodec mpeg2video -map 0:1 -acodec ac3 "<my output file>.ts"

To my amazement it worked the first time. I don't need live viewing and this technique will let me save playable video files. This will work until ATSC 3.x "grows up" and becomes the norm for everything.

Here are a few details if somebody else wants to try it:

I tried playing it on several devices and it worked well (except of course there are no subtitles). The resulting mpeg video stream was just a bit fuzzy but tolerable. I'm not very experienced with ffmpeg's multitude of options but I could probably improve the video quality with some experimenting. The AC-4 to AC-3 conversion was good. I save and watch videos using a variety a players (my favorite is JRiver Media Center) and they all were happy with my ATSC 3.0 conversion. Even my 10-year old Beyond TV played it without complaining. For me this helps since I often travel in an RV that is "off the grid" and don't always have a network connection. I carry a large disk drive filled with recorded TV shows.

ffprobe.exe shows my input file as
Input #0, mpegts, from '<my input file>.mpg':
Duration: 01:00:57.94, start: 69849.064389, bitrate: 3134 kb/s
Program 3
Stream #0:0[0x31]: Video: hevc (Main 10) ([36][0][0][0] / 0x0024), yuv420p10le(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 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[0x39](eng): Audio: ac4 (STPP / 0x50505453), 0 channels, fltp

and my output file as
Input #0, mpegts, from '<my converted file>.ts':
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 49152 vbv_delay: N/A
Stream #0:1[0x101](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 448 kb/s

This is important to me since I live in a fringe reception area and my ATSC 1.x PBS and NBC signals are weak. Using my HDHR 4K tuner to record ATSC 3.0 from an alternate RF signal lets me watch programs I can't normally see.

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

Re: AC-4 Audio?

Post by ferrellsl »

KeeterJ wrote: Sun Jan 31, 2021 3:45 pm I want to thank ferrellsl for building an ffmpeg.exe that supports AC-4. You inspired me this weekend to try it. I grabbed an HDHR .mpg file from a DVR server on a Win10 PC and converted it to a traditional .ts transport stream file using

ffmpeg -i "<my input file>.mpg" -y -map 0:0 -vcodec mpeg2video -map 0:1 -acodec ac3 "<my output file>.ts"

To my amazement it worked the first time. I don't need live viewing and this technique will let me save playable video files. This will work until ATSC 3.x "grows up" and becomes the norm for everything.

Here are a few details if somebody else wants to try it:

I tried playing it on several devices and it worked well (except of course there are no subtitles). The resulting mpeg video stream was just a bit fuzzy but tolerable.
No need to thank me. The guy who did all the real work is Paul B Mahol aka richardpl. I simply compiled his code for Windows.

You should get better video quality with your stream captures by using a command similar to this one:

ffmpeg -i http://x.x.x.x:5004/auto/v"<your channel number>" -c:v copy "<your output file>.ts"
or
ffmpeg -i "<your input file>" -c:v copy "<your output file>.ts"

This will create a TS file without any transcoding or down sampling, so original video quality is retained and the audio will be in MP2 format so playable on just about anything that can play h.265.

When I stream an ATSC3.0 HEVC/AC-4 channel to a TS file in this manner, here's what ffprobe tells me about the resulting TS file:

Output #0, mpegts, to 'test.ts':
Metadata:
encoder : Lavf58.65.100
Stream #0:0: Video: hevc (Main 10) ([36][0][0][0] / 0x0024), yuv420p10le(tv), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 59.94 fps, 59.94 tbr, 90k tbn, 90k tbc
Stream #0:1(eng): Audio: mp2, 48000 Hz, stereo, s16, 384 kb/s
Metadata:
encoder : Lavc58.115.102 mp2
frame= 3118 fps= 80 q=-1.0 Lsize= 26092kB time=00:00:52.37 bitrate=4081.0kbits/s speed=1.34x

I'll be really happy when I see that 1920x1080 resolution on my stream captures go to 3840x2160. Currently the broadcasters in the Phoenix area are not broadcasting any 4K content. They're still broadcasting 1080p across their ATSC3.0 channels.

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

Re: AC-4 Audio?

Post by ferrellsl »

Here's an updated player with streaming support so there's no longer a need for ffmpeg, wget or other app to capture streams to a file before playback. I've tested this player with http:// streams from my HDHomeRun tuner as well as an rtsp:// security camera at my home. It still supports AC-4 and HEVC.

To play an HEVC/AC-4 stream, or any other type of stream from your tuner, enter the channel's URL as found in your channel lineup (Ex: http://x.x.x.x:5004/auto/v161.1 ) into the video selection dialog box or select a local file for videos stored locally.

Download link: https://www.dropbox.com/s/eft7u6d0ajp2t ... t.zip?dl=1

This player is based on code found here: https://github.com/yundiantech/VideoPlayer

It took me several hours to track down an annoying audio bug/crackle but it works great now.

Post Reply