Jump to content


Photo

ffmpeg/ffprobe errors with playlist input


  • Please log in to reply
39 replies to this topic

#21 pünktchen OFFLINE  

pünktchen

    Advanced Member

  • Members
  • 2192 posts
  • Local time: 06:01 PM

Posted 09 October 2019 - 06:10 PM

@softworkz to get continous playback i want to use ffmpeg's complex concat filter like this:

ffmpeg.exe -re -i "input1.mkv" -re -i "input2.mkv" -filter_complex "[0:v]scale=w=1920:h=1080:interl=-1:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1/1,setpts=PTS-STARTPTS,yadif=0:-1:0[v0]; [1:v]scale=w=1920:h=1080:interl=-1:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1/1,setpts=PTS-STARTPTS,yadif=0:-1:0[v1]; [v0][0:a][v1][1:a]concat=n=2:v=1:a=1[v][a]" -map "[v]" -map "[a]" -c:v libx265 -crf 26 -preset superfast -c:a aac -ab 256k -ac 6 -r 24 output.mp4

To minimize processor usage i'm using "-re" (read input at native framerate). But there seems to be a bug in ffmpeg, because "-re" is only applied for the first item.

As you are already providing custom ffmpeg buils for Emby, maybe you could fix there?



#22 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 138211 posts
  • Local time: 12:01 PM

Posted 09 October 2019 - 06:23 PM

This approach would never fly with end users because you're going to be forcing content through ffmpeg on the server when it could otherwise potentially direct play. That's why if you instead follow the approach i mentioned earlier, then although it will have quirks, we can gradually help you with core support if you're able to build up users.



#23 pünktchen OFFLINE  

pünktchen

    Advanced Member

  • Members
  • 2192 posts
  • Local time: 06:01 PM

Posted 09 October 2019 - 06:52 PM

This approach would never fly with end users because you're going to be forcing content through ffmpeg on the server when it could otherwise potentially direct play. That's why if you instead follow the approach i mentioned earlier, then although it will have quirks, we can gradually help you with core support if you're able to build up users.

You mean to implement ITunerHost?

What would be the advantages and what are the quirks?

Right now i do not even know where to start with ITunerHost, where should i implement it?



#24 softworkz OFFLINE  

softworkz

    Advanced Member

  • Developers
  • 1795 posts
  • Local time: 06:01 PM

Posted 09 October 2019 - 09:24 PM

@softworkz to get continous playback i want to use ffmpeg's complex concat filter like this:

ffmpeg.exe -re -i "input1.mkv" -re -i "input2.mkv" -filter_complex "[0:v]scale=w=1920:h=1080:interl=-1:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1/1,setpts=PTS-STARTPTS,yadif=0:-1:0[v0]; [1:v]scale=w=1920:h=1080:interl=-1:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1/1,setpts=PTS-STARTPTS,yadif=0:-1:0[v1]; [v0][0:a][v1][1:a]concat=n=2:v=1:a=1[v][a]" -map "[v]" -map "[a]" -c:v libx265 -crf 26 -preset superfast -c:a aac -ab 256k -ac 6 -r 24 output.mp4
To minimize processor usage i'm using "-re" (read input at native framerate). But there seems to be a bug in ffmpeg, because "-re" is only applied for the first item.
As you are already providing custom ffmpeg buils for Emby, maybe you could fix there?

 

There is no bug in ffmpeg.

ffmpeg supports multiple inputs primarily for sequential rather than for simultaneous reading. It (let's say the "input module") cannot know that your second input will only be needed after the first one is completely read.

 

Anyway, the concat filter is not the right approach.

What you would need is the "concat demuxer".

 

Please note, there are three "concat things" in ffmpeg:

  • concat demuxer
  • concat filter
  • concat protocol

Don't spend time with the "concat protocol". It requires all files to be of the same structure.



#25 pünktchen OFFLINE  

pünktchen

    Advanced Member

  • Members
  • 2192 posts
  • Local time: 06:01 PM

Posted 09 October 2019 - 09:37 PM

Anyway, the concat filter is not the right approach.

What you would need is the "concat demuxer".

 

Please note, there are three "concat things" in ffmpeg:

  • concat demuxer
  • concat filter
  • concat protocol

Don't spend time with the "concat protocol". It requires all files to be of the same structure.

 

It's the other way: http://ffmpeg.org/ff...ats.html#concat

"All files must have the same streams (same codecs, same time base, etc.)."



#26 softworkz OFFLINE  

softworkz

    Advanced Member

  • Developers
  • 1795 posts
  • Local time: 06:01 PM

Posted 09 October 2019 - 10:00 PM

I haven't understood the value of your intended solution but I've understood what you want to do.

 

So here's my personal advice for creating an appropriate solution:

  • First, we need to realize and accept that Emby features - as they are available to plugin developers - don't really help you much here
    .
  • You seem to be on the way already to run your own ffmpeg sessions.
    I would do this completely outside of EmbyServer inside a separate "companion application"
    This separate application will mimic an IPTV service - just that it creates streams on demand only instead of continuously.
    .
  • At the side of Emby, you will simply add an M3U tuner with local URLs pointing to your iptv service application
    .
  • Your plugin will only do the things that you need for interaction, but it will not do any media processing at all
    .
  • On the side of your iptv service, you could either use the concat approach, or you could also make your "iptv service" serve via HLS protocol to Emby
    With HLS, you would be able to stop your ffmpeg session at any time and restart another one for a new source file - while continuing at the previous last segment number
    Of course you need to make sure that you are always transcoding to the exact same format.
    .
  • Don't encode to HEVC. That costs too much CPU and Emby will transcode it back to H.264 anyway


#27 softworkz OFFLINE  

softworkz

    Advanced Member

  • Developers
  • 1795 posts
  • Local time: 06:01 PM

Posted 09 October 2019 - 10:03 PM

It's the other way: http://ffmpeg.org/ff...ats.html#concat

"All files must have the same streams (same codecs, same time base, etc.)."

 

Yes, that's why you need to run it on the outputs of your transcodings. There's some explanation here about extending the concat list file in a delayed way: https://trac.ffmpeg....iki/Concatenate

 

I can't say that I've ever tried that, but I've read about it.



#28 pünktchen OFFLINE  

pünktchen

    Advanced Member

  • Members
  • 2192 posts
  • Local time: 06:01 PM

Posted 09 October 2019 - 10:42 PM

  • You seem to be on the way already to run your own ffmpeg sessions.
    I would do this completely outside of EmbyServer inside a separate "companion application"
    This separate application will mimic an IPTV service - just that it creates streams on demand only instead of continuously.

The stream/file is created on demand when a user starts watching a specific live tv channel, not when the Emby server starts.

 

  • At the side of Emby, you will simply add an M3U tuner with local URLs pointing to your iptv service application
    .
  • On the side of your iptv service, you could either use the concat approach, or you could also make your "iptv service" serve via HLS protocol to Emby
    With HLS, you would be able to stop your ffmpeg session at any time and restart another one for a new source file - while continuing at the previous last segment number
    Of course you need to make sure that you are always transcoding to the exact same format.

So you are saying i should create my own streaming server application that delivers streams and guide data?

Mmh, if had known this already some years ago then i had my own "Emby" server right now.

 

  • Don't encode to HEVC. That costs too much CPU and Emby will transcode it back to H.264 anyway

This was just for testing.


Edited by pünktchen, 09 October 2019 - 10:42 PM.


#29 softworkz OFFLINE  

softworkz

    Advanced Member

  • Developers
  • 1795 posts
  • Local time: 06:01 PM

Posted 09 October 2019 - 10:45 PM

So you are saying i should create my own streaming server application that delivers streams and guide data?

Mmh, if had known this already some years ago then i had my own "Emby" server right now.

 

No. Then you would have your own TV channel, not an Emby Server. That's very different.



#30 pünktchen OFFLINE  

pünktchen

    Advanced Member

  • Members
  • 2192 posts
  • Local time: 06:01 PM

Posted 09 October 2019 - 11:19 PM

Another question:
What about tcp is input for a live tv m3u playlist?
Emby accepts file, rtp, udp, rtsp and http but tcp is missing somehow?

#31 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 138211 posts
  • Local time: 12:01 PM

Posted 10 October 2019 - 03:27 PM

So you are saying i should create my own streaming server application that delivers streams and guide data?

 

I think you should implement ITunerHost, and temporarily, an IListingsProvider as well for guide data. I think (in theory), you should be able to use the current api's to at least get it to play single static files. I can commit to quick server-side fixes that might help you move things along. If you're able to get enough interested users, then we can gradually commit more to helping you.

 

With this approach the tradeoff is that you won't be able to seek between different programs, but you'll get to keep your direct play, hd audio passthrough, hdr, etc. You lose all of these things when you try to put them together into one playlist.

 

As you're aware of the private testing threads for new tuner hardware, one of the things we're also looking at is EPG data coming straight from the tuner. That means when all is said and done, you would only need an ITunerHost and not a separate IListingsProvider. But as of today, you'd have to do a listings provider, and users would have to hook them up together in the UI.



#32 softworkz OFFLINE  

softworkz

    Advanced Member

  • Developers
  • 1795 posts
  • Local time: 06:01 PM

Posted 10 October 2019 - 05:53 PM

@Luke - That doesn't make sense. When he is creating a custom program, he will always need to create custom listings because the data from the streams won't match the timings of his own program schedule.

 

@pünktchen - Are you intending to deliver recorded TV only or any kind of videos on Emby server?



#33 softworkz OFFLINE  

softworkz

    Advanced Member

  • Developers
  • 1795 posts
  • Local time: 06:01 PM

Posted 10 October 2019 - 05:56 PM

Also I don't understand what would be the benefit of playing back a single video through the TV feature instead of playing it normally through Emby?



#34 pünktchen OFFLINE  

pünktchen

    Advanced Member

  • Members
  • 2192 posts
  • Local time: 06:01 PM

Posted 10 October 2019 - 06:45 PM

I think you should implement ITunerHost, and temporarily, an IListingsProvider as well for guide data. I think (in theory), you should be able to use the current api's to at least get it to play single static files. I can commit to quick server-side fixes that might help you move things along. If you're able to get enough interested users, then we can gradually commit more to helping you.

With this approach the tradeoff is that you won't be able to seek between different programs, but you'll get to keep your direct play, hd audio passthrough, hdr, etc. You lose all of these things when you try to put them together into one playlist.


It seems the IListingProvider doesn't have all fields that are needed for ListingProviderInfo.
I've already tried that and cannot get further in Emby at the screen where i choose a country and my custom provider.

Anyway when it's all about one static file - the currently running program of a channel - then i already have this within my virtual live tv channel plugin.

Seeking between different programs of the same channel isn't my goal. The problem is when one show ends, the next show should start automatically.

#35 pünktchen OFFLINE  

pünktchen

    Advanced Member

  • Members
  • 2192 posts
  • Local time: 06:01 PM

Posted 10 October 2019 - 06:46 PM

@pünktchen - Are you intending to deliver recorded TV only or any kind of videos on Emby server?

Any kind of video.

#36 pünktchen OFFLINE  

pünktchen

    Advanced Member

  • Members
  • 2192 posts
  • Local time: 06:01 PM

Posted 10 October 2019 - 06:51 PM

Also I don't understand what would be the benefit of playing back a single video through the TV feature instead of playing it normally through Emby?

The reason behind my idea is, my wife and i often find us searching the guide to then watch a movie with commercials on live tv although we have this movie in the library...

#37 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 138211 posts
  • Local time: 12:01 PM

Posted 10 October 2019 - 07:00 PM

It seems the IListingProvider doesn't have all fields that are needed for ListingProviderInfo.
I've already tried that and cannot get further in Emby at the screen where i choose a country and my custom provider.

Anyway when it's all about one static file - the currently running program of a channel - then i already have this within my virtual live tv channel plugin.

Seeking between different programs of the same channel isn't my goal. The problem is when one show ends, the next show should start automatically.

 

 

I need to work out putting the xml provider into a plugin and then that should resolve whatever kinks you're seeing. I think the best way to handle continuous playback would be that whenever live tv ends due to EOF, we'd simply start playing the same channel again and it would move onto the next item. This should be a safe non-disruptive change since it would never happen with regular live tv. That would require updates to apps. It's not something I'd commit to now, but if you get a proof of concept going and there's enough interested users, then we can commit to providing more core support.



#38 softworkz OFFLINE  

softworkz

    Advanced Member

  • Developers
  • 1795 posts
  • Local time: 06:01 PM

Posted 10 October 2019 - 08:11 PM

The reason behind my idea is, my wife and i often find us searching the guide to then watch a movie with commercials on live tv although we have this movie in the library...

 

But why do you want continuous/concatenated playback then? How does that come into play?

 

 

And how is your approach for solving that family situation:

  • Do you want Emby to indicate existing local versions of a video while browsing a regular guide?
    .
  • Or do you want to create your own artificial guide that is made up of existing videos?
    (and browse that instead of looking at a 'real' guide)


#39 pünktchen OFFLINE  

pünktchen

    Advanced Member

  • Members
  • 2192 posts
  • Local time: 06:01 PM

Posted 10 October 2019 - 08:58 PM

But why do you want continuous/concatenated playback then? How does that come into play?

Just imagine a cartoon channel, a comedy channel or crime channel with random tv show episodes.

Or do you want to create your own artificial guide that is made up of existing videos?
(and browse that instead of looking at a 'real' guide)

This one.

#40 pünktchen OFFLINE  

pünktchen

    Advanced Member

  • Members
  • 2192 posts
  • Local time: 06:01 PM

Posted 10 October 2019 - 08:59 PM

I need to work out putting the xml provider into a plugin and then that should resolve whatever kinks you're seeing. I think the best way to handle continuous playback would be that whenever live tv ends due to EOF, we'd simply start playing the same channel again and it would move onto the next item. This should be a safe non-disruptive change since it would never happen with regular live tv. That would require updates to apps. It's not something I'd commit to now, but if you get a proof of concept going and there's enough interested users, then we can commit to providing more core support.

That sounds promising.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users