How does OpenPHT use ffmpeg?

I thought oPHT (and PHT) was just a way to navigate and launch the movies and the OS did the playback (or the server transcoded). In the 1.7.1 release notes it says that ffmpeg was updated. This surprised me. How is ffmpeg used by oPHT?

Justin

for the second part, no the OS isnt doing it, openpht is (same as kodi)

From a very high level, FFMPEG is a great tool for de/muxing media streams, decoding and encoding media types, transcoding, streaming, and even playing media. It can also be compiled for many different OSes so it makes it highly flexible.

Just look at the description on their website:

FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge. No matter if they were designed by some standards committee, the community or a corporation. It is also highly portable: FFmpeg compiles, runs, and passes our testing infrastructure FATE across Linux, Mac OS X, Microsoft Windows, the BSDs, Solaris, etc. under a wide variety of build environments, machine architectures, and configurations.

One of the things it’s used for is audio that cannot be passed through to a receiver. Look at the log excerpt below where an mp3 audio stream cannot be passed through, so it’s processed by ffmpeg:

12:30:59 T:545435676992 DEBUG: Open - probing detected format
12:30:59 T:545435676992 DEBUG: Open - setting usetoc to 0 for accurate VBR MP3 seek
12:30:59 T:545435676992 INFO: ffmpeg[7EFE7FF140]: Skipping 0 bytes of junk at 33.
12:30:59 T:545435676992 DEBUG: Open - avformat_find_stream_info starting
12:30:59 T:546568139072 DEBUG: DoWork - took 184 ms to load special://masterprofile/Thumbnails/9/9347418d.jpg
12:30:59 T:545427288384 DEBUG: DoWork - took 179 ms to load special://masterprofile/Thumbnails/2/27feeecf.jpg
12:30:59 T:544880202048 DEBUG: DoWork - took 269 ms to load special://masterprofile/Thumbnails/f/fa79f140.jpg
12:30:59 T:545435676992 DEBUG: ffmpeg[7EFE7FF140]: Estimating duration from bitrate, this may be inaccurate
12:30:59 T:545435676992 DEBUG: Open - av_find_stream_info finished
12:30:59 T:545435676992 INFO: ffmpeg[7EFE7FF140]: Input #0, mp3, from ‘special://masterprofile/ThemeMusicCache/4b990e03.mp3’:
12:30:59 T:545435676992 INFO: ffmpeg[7EFE7FF140]: Metadata:
12:30:59 T:545435676992 INFO: ffmpeg[7EFE7FF140]: encoder : Lavf52.54.0
12:30:59 T:545435676992 INFO: ffmpeg[7EFE7FF140]: Duration: 00:00:30.07, start: 0.000000, bitrate: 256 kb/s
12:30:59 T:545435676992 INFO: ffmpeg[7EFE7FF140]: Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 256 kb/s
12:30:59 T:545435676992 DEBUG: CDVDDemuxFFmpeg::AddStream(0, …) → 0
12:30:59 T:545435676992 DEBUG: FactoryCodec - Audio: passthrough - Opening
12:30:59 T:545435676992 DEBUG: FactoryCodec - Audio: passthrough - Failed
12:30:59 T:545435676992 DEBUG: FactoryCodec - Audio: FFmpeg - Opening
12:30:59 T:545435676992 DEBUG: FactoryCodec - Audio: FFmpeg - Opened

Thanks. So does the Plex PHT also process media client-side? My understanding was that play/render support was dependent on the client OS, so that if the client could not natively render in the source format Plex would transcode into something it could play.

Does oPHT remove the need for the Plex server to ever transcode?

@JustinHPlex said:
Thanks. So does the Plex PHT also process media client-side?

Yes. As far as the hardware, where it runs on allows, that is.
If you run OpenPHT on a Raspberry Pi (which is what Rasplex really is), then it won’t be able to decode a 1080p HEVC video. But it has enough power to transcode a DTS-HD MA 5.1 stream to AC3 so your soundbar makes some noise :wink:

My understanding was that play/render support was dependent on the client OS, so that if the client could not natively render in the source format Plex would transcode into something it could play.

Yes, this is the normal mode of operation with all the other Plex clients. Each one of these supports a different set of formats.

OpenPHT (and PMP) are special in this regard. They are what I call ‘grown up’ Plex clients.

Does oPHT remove the need for the Plex server to ever transcode?

OpenPHT (and PMP) play what ever you throw at them (with the hardware-dependent exceptions as noted above).
They are the clients of choice if your Plex server runs on a NAS which is unable to transcode.

I have a question which related to what you are discussing. I hope you do not mind.

I have movies with have several audio tracks, specifically: 1: AAC stereo: english; 2: AC3 5.1: english; 3: AAC stereo: german; 4: AC3 5.1: german

I see that the audio is transcoded on the server.

/opt/plex/Plex Transcoder -codec:#0x01 h264 -codec:#0x03 ac3 -codec:#0x05 ac3 -noaccurate_seek -i /media/movies/Good Will Hunting - USA 1997.m4v -map 0:#0x01 -codec:0 copy -map 0:#0x02 -metadata:s:1 language=eng -codec:1 copy -copypriorss:1 0 -map 0:#0x03 -metadata:s:2 language=eng -codec:2 aac -ar:2 48000 -channel_layout:2 stereo -b:2 241k -map 0:#0x04 -metadata:s:3 language=ger -codec:3 copy -copypriorss:3 0 -map 0:#0x05 -metadata:s:4 language=ger -codec:4 aac -ar:4 48000 -channel_layout:4 stereo -b:4 241k -f mp4 -map_metadata -1 -map_chapters -1 -movflags +faststart /var/lib/plexmediaserver/Library/Caches/PlexMediaServer/Transcode/Sync+/12580071/e0/143621.mp4.temp -y -nostats -loglevel quiet -loglevel_plex error -progressurl http://127.0.0.1:32400/video/:/transcode/session/0680b097-68c9-45df-998d-7bbc3635e6e0/progress

I interpret this to say that track 2 and 4, which are both AC3 5.1, are converted to AAC 4 channel.

I have no need for this as the TV connected to my RasPlex thing only does stereo.

Question:
Why is this happening at all?
Why is happening on the server
How can I suppress this?

Server: PMS 1.2.7 on a bananapi
Client: Rasplex 1.6.2 on a Odroid C2

@eckarth said:
I interpret this to say that track 2 and 4, which are both AC3 5.1, are converted to AAC 4 channel.

I am no expert in ffmpeg, but I think the 4 that appears everywhere refers to the track index number. Which would be the german 5.1 AC3 track you have selected for playback.
It clearly says channel layout : stereo

I am no ffmpeg expert either. You may be right that track 4 is converted to AAC stereo.

But why that? There is already a track 3 which is AAC stereo.

My question is: What is the purpose of this transcoding?

I would be happy if either the file would be simply streamed to the RasPlex client or alternatively would be remuxed to have only one video and one audio channel, namely the one I selected.

Btw, where in the command do read that I selected the german 5.1 AC3 track for playback?

@eckarth said:
My question is: What is the purpose of this transcoding?

It adapts what ever audio track is selected to the abilities of your playback system. Which is stereo only in this case.

Btw, where in the command do read that I selected the german 5.1 AC3 track for playback?

Open Plex Web and go to the preplay page of this movie. Which audio track is shown as selected?

These track selections are made per user account and get stored. All clients which are signed into this user account are using this stored selection.

@OttoKerner said:

@eckarth said:
My question is: What is the purpose of this transcoding?

It adapts what ever audio track is selected to the abilities of your playback system. Which is stereo only in this case.

From the reading this thread I inferred that this would happen on the RasPlex client. Can RasPlex (on Ondroid) not do AC3 to AAC conversion?

And secondly, why do both AC3 tracks get transcoded? Only one can be selected at any time.

Btw, where in the command do read that I selected the german 5.1 AC3 track for playback?

Open Plex Web and go to the preplay page of this movie. Which audio track is shown as selected?

These track selections are made per user account and get stored. All clients which are signed into this user account are using this stored selection.

Ok, the preplay page says “English (AAC stereo),” which would be the 1st audio track. Which makes?

@eckarth said:
From the reading this thread I inferred that this would happen on the RasPlex client. Can RasPlex (on Ondroid) not do AC3 to AAC conversion?

Of course it can do this.

And secondly, why do both AC3 tracks get transcoded? Only one can be selected at any time.
Ok, the preplay page says “English (AAC stereo),” which would be the 1st audio track. Which makes?

Perhaps we were both reading this wrong? :-"
The player of course only plays one audio track of the 4 available.
If the AAC stereo track is shown as ‘selected’ in Plex Web, then this is what OpenPHT plays, unless you switch it later to a different track.

There seems to be some confusion here.

@eckarth said:
I have a question which related to what you are discussing. I hope you do not mind.

I have movies with have several audio tracks, specifically: 1: AAC stereo: english; 2: AC3 5.1: english; 3: AAC stereo: german; 4: AC3 5.1: german

I see that the audio is transcoded on the server.

/opt/plex/Plex Transcoder -codec:#0x01 h264 -codec:#0x03 ac3 -codec:#0x05 ac3 -noaccurate_seek -i /media/movies/Good Will Hunting - USA 1997.m4v -map 0:#0x01 -codec:0 copy -map 0:#0x02 -metadata:s:1 language=eng -codec:1 copy -copypriorss:1 0 -map 0:#0x03 -metadata:s:2 language=eng -codec:2 aac -ar:2 48000 -channel_layout:2 stereo -b:2 241k -map 0:#0x04 -metadata:s:3 language=ger -codec:3 copy -copypriorss:3 0 -map 0:#0x05 -metadata:s:4 language=ger -codec:4 aac -ar:4 48000 -channel_layout:4 stereo -b:4 241k -f mp4 -map_metadata -1 -map_chapters -1 -movflags +faststart /var/lib/plexmediaserver/Library/Caches/PlexMediaServer/Transcode/Sync+/12580071/e0/143621.mp4.temp -y -nostats -loglevel quiet -loglevel_plex error -progressurl http://127.0.0.1:32400/video/:/transcode/session/0680b097-68c9-45df-998d-7bbc3635e6e0/progress

I interpret this to say that track 2 and 4, which are both AC3 5.1, are converted to AAC 4 channel.

I have no need for this as the TV connected to my RasPlex thing only does stereo.

Question:
Why is this happening at all?

This is happening because this is a SYNC transcode, and not a stream to OpenPHT transcode. See this part where it copies the transcode into a sync folder?

/var/lib/plexmediaserver/Library/Caches/PlexMediaServer/Transcode/Sync+/12580071/e0/143621.mp4.temp

PMS transcodes all the language tracks so they are available on a sync’d device. OpenPHT does not support Plex sync-ing, so this has nothing to do with OpenPHT.

Why is happening on the server

Because you’re syncing to a client device. PMS will transcode to whatever format it has listed as optimized for that client requesting the sync.

How can I suppress this?

You can’t. It’s a function of the PMS sync feature.

@OttoKerner said:
Perhaps we were both reading this wrong? :-"

Mistakes were made. But I think everything is going to be alright in the end. :slight_smile:

Oh! I am now not sure anymore what I did.

I will do the dishes the rest of the week.