Error transcoding to FLAC

server-linux

#1

Error transcoding to FLAC

When I set the transcoder to flac/flac it creates invalid output.

When I set my music profile output to container="flac" audioCodec="flac" the transcoder works but the .ts files generated are invalid.
I tested one of them with ffplay and the output is:
`
luismarcilio@luismarcilio-VirtualBox:/mnt/Multimedia$ ffplay media-00001.ts
ffplay version 3.3.4-2 Copyright (c) 2003-2017 the FFmpeg developers
built with gcc 7 (Ubuntu 7.2.0-8ubuntu2)
configuration: --prefix=/usr --extra-version=2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, mpegts, from 'media-00001.ts':q= 0KB sq= 0B f=0/0

Duration: 00:00:00.84, start: 11.021678, bitrate: 16442 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Data: bin_data ([6][0][0][0] / 0x0006)
Failed to open file 'media-00001.ts' or configure filtergraph

`

Find below the configuration I used for TranscodeTargets.

<TranscodeTargets>
<VideoProfile container="mp4" codec="h264" audioCodec="aac" subtitleCodec="mov_text"
context="static"/>
<VideoProfile protocol="hls" container="mpegts" codec="h264" audioCodec="aac,mp3"
context="streaming">
<Setting name="HlsExtraMultiChannelAudioStream" value="ac3"/>
</VideoProfile>
<MusicProfile protocol="hls" container="flac" audioCodec="flac" context="streaming"/>
<PhotoProfile container="jpeg"/>
<SubtitleProfile protocol="hls" container="webvtt" subtitleCodec="webvtt"/>
</TranscodeTargets>

Thanks.


#2

Logfiles which capture the entire sequence are helpful. Settings - Server - Help - Download Logs. Attach the ZIP with your next post.
I do not see any PMS error in what you posted above.

FWIW, you do not transcode to flac. Flac is on the decoder side.

If the device can natively accept flac and flac is present, it will be passed through. transcoding AAC (lossy) -> flac (lossless) serves no purpose


#3

Thank you @ChuckPA for the quick response.
I’m running the player on an iPhone 6 plus with IOS 11, version 4.20.1
I direct play flac files on it, so I don’t think is an unsupported format.

I don’t transcode AAC to FLAC. I transcode only unsupported formats (I have lossless .ape and .dsf).

Please find attached the logs for a tentative of playing an album from Tracy Chapman.
I have attached also my ios.xml

Here is the Plex Transcoder command line:

root@raspberrypi:~# ps -ef | grep Trans plex 2503 1125 91 08:03 ? 00:01:03 /usr/lib/plexmediaserver/Plex Transcoder -codec:0 ape -i /srv/dev-disk-by-label-Multimedia/MM/Musicas/Outros Formatos/Tracy_Chapman[torrents.ru]/Tracy Chapman - Tracy Chapman.ape -map 0:0 -codec:0 flac -ar:0 44100 -channel_layout:0 stereo -b:0 4096k -segment_format mpegts -f ssegment -individual_header_trailer 0 -segment_time 1 -segment_start_number 0 -segment_copyts 1 -segment_time_delta 0.0625 -segment_list http://127.0.0.1:32400/video/:/transcode/session/4901AD3D-F505-48C8-AD75-675D85FEC022/43ac2511-5e7a-443f-9385-6b0e0351eeb4/seglist -segment_list_type csv -segment_list_size 2147483647 -max_delay 5000000 -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 media-%05d.ts -start_at_zero -copyts -vsync cfr -y -nostats -loglevel quiet -loglevel_plex error -progressurl http://127.0.0.1:32400/video/:/transcode/session/4901AD3D-F505-48C8-AD75-675D85FEC022/43ac2511-5e7a-443f-9385-6b0e0351eeb4/progress


#4

Since you are using a Pi, can you capture the output file (from Syncing) as well?

If the transcoder is calling for flac output, if not generating it then the team will want to figure out why.


#5

I quickly chatted with the transcoder team.
Modifying the profile into an unsupported configuration is just that… 'unsupported;.
FLAC is not intended to be stored in a TS file


#6

Thank you @ChuckPA
I tried also Alac and PCM, unsuccessfully.
Is there any configuration I can use to transcode my files using a losselss codec? (or change the mpegts container?)

For me it’s still a bug because we specify clearly
container=“flac” audioCodec=“flac”
and it creates a file with container mpegts


#7

Please read here. https://en.wikipedia.org/wiki/Comparison_of_video_container_formats

Are you referring to this section?

<?xml version="1.0" encoding="utf-8"?>
<Client name="iOS">
    <!-- Author: Plex Inc. -->
    <!-- This profile is used by A5 and higher devices (starting with iPhone 4S and iPad 3) -->
    <Settings>
        <Setting name="DirectPlayStreamSelection" value="true"/>
        <Setting name="StreamUnselectedIncompatibleAudioStreams" value="true"/>
    </Settings>
    <TranscodeTargets>
        <VideoProfile container="mp4" codec="h264" audioCodec="aac" subtitleCodec="mov_text"
            context="static"/>
        <VideoProfile protocol="hls" container="mpegts" codec="h264" audioCodec="aac,mp3"
            context="streaming">
            <Setting name="HlsExtraMultiChannelAudioStream" value="ac3"/>
        </VideoProfile>
        <MusicProfile protocol="hls" container="flac" audioCodec="flac" context="streaming"/>
        <PhotoProfile container="jpeg"/>
        <SubtitleProfile protocol="hls" container="webvtt" subtitleCodec="webvtt"/>
    </TranscodeTargets>

If you examine the header of the file, please see it includes support for iPhone 4S and iPad 3. These devices do not support FLAC due to their frozen iOS version .

If you wish to customize (as example).

        <VideoProfile protocol="hls" container="mpegts" codec="h264" audioCodec="aac,mp3"
            context="streaming">

change container="mpegts" to container="mp4" for compliance

If you’re going to modify a profile, make certain to control the output container


#8

Sorry for the delay, @ChuckPA
It doesn’t work for MusicProfile.
The Transcoder always use -segment_format mpegts.

IMO it’s a bug because the system doesn’t use the configuration of container="mp4" for music profile, what would make it possible to, at least, encode as ALAC.
Its also a pity that we cannot convert lossless formats to lossless formats.


#9

According to: https://en.wikipedia.org/wiki/Comparison_of_video_container_formats
and http://www.mp4ra.org/codecs.html

You can’t put FLAC in an MP4

MPEG-2/4 (HE)-AAC, MPEG-1/2 Layers I, II, III (MP3), AC-3, Apple Lossless, ALS, SLS, Vorbis(with private objectTypeIndication)

This is not a bug.


#10

@ChuckPA Sorry. I didn’t mention. I tried ALAC, following the details you shared.

My will here is to convert .ape and .dsf to another lossless high-res format, either FLAC or ALAC. Doesn’t matter.
It doesn’t work.

I found some other users that can’t do it as well but they say “Plex cannot convert lossless to lossless”, I think the limitation is that the container configuration for Plex Transcoder is not being used and it always transcode to mpegts.

If you can send an example that works (as an IOS developer you probably have how to test it) it would help not me but many people.

I just want to be able to convert lossless (any .ape is good for testing) to FLAC or ALAC and play it in my iPhone.


#11

If you can help me demonstrate a valid configuration lossless->lossless, I can make a case for it.
We must be 100% certain everything is per allowed specification and actually has broader need and not a ‘nice to have’.


#12

Thank you @ChuckPA
I’m not expert on this matter but by the information you provided, I would say that this is valid:

<?xml version="1.0" encoding="UTF-8"?>
<Client name="iOS">
    <!-- Author: Plex Inc. -->
    <!-- This profile is used by A5 and higher devices (starting with iPhone 4S and iPad 3) -->
    <Settings>
        <Setting name="DirectPlayStreamSelection" value="true"/>
        <Setting name="StreamUnselectedIncompatibleAudioStreams" value="true"/>
    </Settings>
    <TranscodeTargets>
        <VideoProfile container="mp4" codec="h264" audioCodec="aac" subtitleCodec="mov_text"
            context="static"/>
        <VideoProfile protocol="hls" container="mpegts" codec="h264" audioCodec="aac,mp3"
            context="streaming">
            <Setting name="HlsExtraMultiChannelAudioStream" value="ac3"/>
        </VideoProfile>
        <MusicProfile protocol="hls" container="mp4" audioCodec="alac" context="streaming"/>
        <PhotoProfile container="jpeg"/>
        <SubtitleProfile protocol="hls" container="webvtt" subtitleCodec="webvtt"/>
    </TranscodeTargets>
    <DirectPlayProfiles>
        <VideoProfile container="mp4,mov" codec="h264,mpeg4" audioCodec="aac"
            subtitleCodec="mov_text,tx3g,ttxt,text"/>
        <!-- Allow Direct Play of HLS content  -->
        <VideoProfile protocol="hls" container="mpegts" codec="h264" audioCodec="aac"/>
        <MusicProfile container="mp3" codec="mp3"/>
        <MusicProfile container="mp4" codec="aac"/>
        <MusicProfile container="mp4" codec="alac"/>
        <MusicProfile container="flac" codec="flac"/>
        <MusicProfile container="alac" codec="alac"/>
        <PhotoProfile container="jpeg"/>
    </DirectPlayProfiles>
    <CodecProfiles>
        <VideoCodec name="h264">
            <Limitations>
                <UpperBound name="video.width" value="1920" isRequired="true"/>
                <UpperBound name="video.height" value="1080" isRequired="true"/>
                <UpperBound name="video.bitDepth" value="8"/>
            </Limitations>
        </VideoCodec>
        <VideoAudioCodec name="alac">
            <Limitations>
                <UpperBound name="audio.channels" value="2"/>
                <UpperBound name="audio.samplerate" value="96000"/>
            </Limitations>
        </VideoAudioCodec>
        <VideoAudioCodec name="flac,pcm">
            <Limitations>
                <UpperBound name="audio.channels" value="2"/>
                <UpperBound name="audio.samplerate" value="96000"/>
            </Limitations>
        </VideoAudioCodec>
        <VideoAudioCodec name="aac,mp3">
            <Limitations>
                <UpperBound name="audio.channels" value="2"/>
                <UpperBound name="audio.samplerate" value="48000"/>
            </Limitations>
        </VideoAudioCodec>
        <MusicCodec name="alac">
            <Limitations>
                <UpperBound name="audio.channels" value="2"/>
                <UpperBound name="audio.samplerate" value="88200"/>
            </Limitations>
        </MusicCodec>
        <MusicCodec name="aac">
            <Limitations>
                <UpperBound name="audio.channels" value="2"/>
                <UpperBound name="audio.bitrate" value="256"/>
            </Limitations>
        </MusicCodec>
    </CodecProfiles>
</Client>

Nevertheless the transcoder still uses -segment_format mpegts, the bit rate is not what I defined (-ar:0 352800), it’s not downmixing to stereo (-channel_layout:0 5.1)

root@raspberrypi:~# ps -ef | grep Trans

plex 1955 1207 94 08:40 ? 00:00:07 /usr/lib/plexmediaserver/Plex Transcoder -codec:0 dsd_lsbf_planar -i /srv/dev-disk-by-label-Multimedia/MM/Musicas/DSF/Diana Krall - The Girl In The Other Room/01 - Diana Krall - Stop This World.dsf -map 0:0 -codec:0 alac -ar:0 352800 -channel_layout:0 5.1 -b:0 4096k -segment_format mpegts -f ssegment -individual_header_trailer 0 -segment_time 1 -segment_start_number 0 -segment_copyts 1 -segment_time_delta 0.0625 -segment_list http://127.0.0.1:32400/video/:/transcode/session/6877F7DB-8A59-40AD-B268-AFBD7031D9C1/0e2eb01e-5299-4eb1-b861-00c8097264d1/seglist -segment_list_type csv -segment_list_size 2147483647 -segment_list_separate_stream_times 1 -max_delay 5000000 -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 -movflags +faststart media-%05d.ts -start_at_zero -copyts -vsync cfr -y -nostats -loglevel quiet -loglevel_plex error -progressurl http://127.0.0.1:32400/video/:/transcode/session/6877F7DB-8A59-40AD-B268-AFBD7031D9C1/0e2eb01e-5299-4eb1-b861-00c8097264d1/progress

I kindly ask you to help me if I’m doing something wrong with this configuration.

Update

I found that it’s not allowed to have two MusicCodec tags in CodecProfiles.
I removed

        <MusicCodec name="aac">
            <Limitations>
                <UpperBound name="audio.channels" value="2"/>
                <UpperBound name="audio.bitrate" value="256"/>
            </Limitations>
        </MusicCodec>

And now it downmixes to stereo, but the sample rate is still 352800.

Update 2

I found that the tag is misspelled.
I updated to:

        <MusicCodec name="alac">
            <Limitations>
                <UpperBound name="audio.channels" value="2"/>
                <UpperBound name="audio.samplingRate" value="88200"/>
            </Limitations>
        </MusicCodec>

And now it’s working with a sample rate of 88.2 kHz

Still not working because the transcoder is still using mpegts container, despite I’m setting

        <MusicProfile protocol="hls" container="mp4" audioCodec="alac" context="streaming"/>

#13

I hate to say this but your output just tied my hands.

root@raspberrypi:~#

PMS isn’t supported on a Pi. That is a user-supported distro


#14

@ChuckPA Sorry, I didn’t know it wasn’t supported.
So I think I can’t get what I want with your product.

I removed the tag [BUG REPORT] as it can’t be taken as a bug, because the distro isn’t supported.

Thanks!


#15

@ChuckPA
Hi!

I’ve been messing around with the profiles, but I still face the same problem.
Despite I set

<MusicProfile protocol="hls" container="mp4" audioCodec="aac"/>

it still transcodes to mpegts:

plex      6591  4509  0 11:06 ?        00:00:00 /usr/lib/plexmediaserver/Plex Transcoder -codec:0 dsd_lsbf_planar -i /srv/dev-disk-by-label-Multimedia/MM/Musicas/DSF/Diana Krall - When I Look In Your Eyes/01 - Diana Krall - Let's Face The Music And Dance.dsf -filter_complex [0:0] aresample=async=1:ocl='stereo':osr=88200[0] -map [0] -codec:0 aac -b:0 256k -segment_format mpegts -f ssegment -individual_header_trailer 0 -segment_time 1 -segment_start_number 0 -segment_copyts 1 -segment_time_delta 0.0625 -segment_list http://127.0.0.1:32400/video/:/transcode/session/A4FF27BF-4068-4644-8E6A-FDFEE334F237/06caaaea-f918-4838-9708-2bab19e5bc53/seglist -segment_list_type csv -segment_list_size 2147483647 -segment_list_separate_stream_times 1 -max_delay 5000000 -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 -movflags +faststart media-%05d.ts -start_at_zero -copyts -vsync cfr -y -nostats -loglevel quiet -loglevel_plex error -progressurl http://127.0.0.1:32400/video/:/transcode/session/A4FF27BF-4068-4644-8E6A-FDFEE334F237/06caaaea-f918-4838-9708-2bab19e5bc53/progress

If I could set the container to mp4 I would be able to transcode to ALAC.

I noticed that the server downloads extra profiles from the client:

Feb 21, 2018 11:06:47.755 [0x665ff400] VERBOSE -  * X-Plex-Client-Profile-Extra => add-transcode-target(type=musicProfile&context=streaming&protocol=hls&container=mpegts&audioCodec=aac)+add-direct-play-profile(type=musicProfile&container=mp4&audioCodec=alac)+add-direct-play-profile(type=musicProfile&container=flac&audioCodec=flac)+add-transcode-target(type=videoProfile&context=streaming&protocol=hls&container=mpegts&videoCodec=h264&audioCodec=aac,mp3,ac3)+add-direct-play-profile(type=videoProfile&container=mp4,mov&videoCodec=h264,mpeg4&audioCodec=aac,ac3,eac3&subtitleCodec=mov_text,tx3g,ttxt,text)
F

These profiles don’t seem to override my settings.
But it doesn’t transcode to mp4 either way…

Is there any hope for me?


#16

Profiles must be modified before PMS starts. Once referenced (loaded into memory), the profile remains active and independent of any file changes.

If you invoke the transcoder at the command prompt and look in the Codecs directory, you can see what it’s capable of decoding and encoding.

export LD_LIBRARY_PATH=`pwd`
 ./Plex\ Transcoder --codecs 

#17

Thanks for the answer @ChuckPA
The profile I wrote is working.
I can change the aac settings like bitrate or sample frequency. But what I really want to do is to transcode to ALAC.
If I set the audioCodec to alac like this:

<MusicProfile protocol="hls" container="mp4" audioCodec="alac"/>

It does transcode to alac but it keeps segment_format mpegts what I believe is incompatible to alac. It seems to ignore my request of container="mp4"

As a result, my application in IOS doesn’t play any sound.


#18

Isn’t ALAC in MP4 an apple-only extension to MP4? MP4 predates ALAC.


#19

It’s a profile for IOS.
But the problem is that even if I put MP4 as the container, the transcoder doesn’t seem to encode it into MP4 but into mpegts.


#20

I can ask for a change.

what is the source codec ? Flac or WAV? If it’s a lossy codec, I will get immediate push back and it will be rejected because going from lossly -> lossless serves no purpose.