Page 1 of 1

Audio stream is missing when transcoding .mp4 file

PostPosted: Fri Jan 06, 2023 6:05 pm
by flavius
Usually .mp4 transcoding works fine for me, but there are some videos that lose their audio stream when being transcoded.
I couldn't figure out why this happens - please help!

ffmpeg info on input file:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'M:\Videos\Quellmaterial\2015\07\14 P und Philipp Sandlers spielen zur Zeugnis├╝bergabe der 6. Klassen\P1010059.MP4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp42avc1
creation_time : 2015-07-14T18:08:54.000000Z
Duration: 00:01:32.64, start: 0.000000, bitrate: 95970 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 95821 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
Metadata:
creation_time : 2015-07-14T18:08:54.000000Z
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
creation_time : 2015-07-14T18:08:54.000000Z

ffmpeg info on output file:
Input #0, mpegts, from 'C:\Windows\Temp\Serviio\transcoding-temp-d10e2244bca2653f372d0313b5187692.stf':
Duration: 00:01:32.64, start: 1.440000, bitrate: 32360 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc

According to the log file (attached) the aac audio stream should have been transcoded to ac3:
2023-01-06T18:22:07,294 DEBUG [VideoDeliveryEngine] Delivering file 'P1010059.MP4' using transcoding (profile: 7 > quality: ORIGINAL > Transcoding > [MPEG2TS/MPEG2/AC3] > matcher: 2)

But the ffmpeg command doesn't contain any audio transcoding (if I'm interpreting the command correctly). The effective ffmpeg command was
F:/Programme/Streaming/Serviio/lib/ffmpeg_original.exe "-threads" "0" "-i" "M:\Videos\Quellmaterial\2015\07\14 P und Philipp Sandlers spielen zur Zeugnisübergabe der 6. Klassen\P1010059.MP4" "-y" "-threads" "0" "-c:v" "mpeg2video" "-pix_fmt" "yuv420p" "-b:v" "30000k" "-maxrate:v" "30000k" "-bufsize:v" "30000k" "-filter_complex" "[0:v]scale=1920:1080[v]" "-r" "25" "-g" "15" "-map" "[v]" "-sn" "-f" "mpegts" "C:\Windows\TEMP\Serviio\transcoding-temp-d10e2244bca2653f372d0313b5187692.stf"

Please note that I have installed a wrapper exe in front of ffmpeg.exe that has removed the "-an" argument from the ffmpeg command that can be found in the attached serviio.log file.

Find profiles.xml and serviio.log attached.

Re: Audio stream is missing when transcoding .mp4 file

PostPosted: Sat Jan 07, 2023 12:13 am
by atc98092
I'm not certain why you are transcoding that file. Usually, an MP4 container with H264 video and AAC audio can be played by virtually any device. What profile are you using, and what is your player?

Re: Audio stream is missing when transcoding .mp4 file

PostPosted: Sat Jan 07, 2023 12:18 pm
by flavius
Profile=Samsung TV / player (C/D-series), Name=UE55D8000

This TV isn't able to play aac audio and needs a transcoding, e.g. to ac3.

The log file shows matcher 2:
2023-01-06T18:22:07,294 DEBUG [VideoDeliveryEngine] Delivering file 'P1010059.MP4' using transcoding (profile: 7 > quality: ORIGINAL > Transcoding > [MPEG2TS/MPEG2/AC3] > matcher: 2)

The related transcoding section of profiles.xml is:
<Video targetContainer="mpegts" targetVCodec="mpeg2video" maxVBitrate="30000" maxHeight="1080" DAR="16:9" targetACodec="ac3" >
<Matches container="*" vCodec="h264" profile="high_10" />
<Matches container="*" vCodec="h264" profile="high" />
<Matches container="*" vCodec="h264" profile="main" levelGreaterThan="4.1" />
<Matches container="mpegts" vCodec="h264" profile="high" />
</Video>

I expected that 'targetACodec="ac3"' would take effect, but the ffmpeg command doesn't contain any audio transcoding.
Any idea what I could change in profiles.xml to force transcoding to ac3?

Re: Audio stream is missing when transcoding .mp4 file

PostPosted: Sun Jan 08, 2023 3:20 am
by atc98092
I'm surprised the TV can't play AAC audio. As for a workaround, you might try some different profiles, such as a Roku TV or even the LG TV profile. I'd have to look more closely at the different profiles to see what might capture AAC. I believe the DirecTV profile transcodes almost everything, so that would at least show if you can get an acceptable audio transcoding, and then work from there.