Jump to content

24p video being terribly and unnecessarily transcoded


wintrmute

Recommended Posts

wintrmute

I was doing an (unrelated) test of 24p content on my television, via a number of apps, plus via a laptop and on the TV's own media player.

In the process I discovered that Emby was showing an extremely-degraded image compared to everything else!

 

It appeared to be transcoding the source video, and really screwing it up in the process.

 

Have a look at this photo of the screen:

http://s378.photobucket.com/user/wintrmute/media/Hisense%2024fps%20judder/DSCF0172_zpsvmslmofj.jpg.html

 

From there, click the link back to the album that its part of, and look at the other photos. (Ignore the ones testing motion interpolation)

 

See how in the Emby photo, my "/u/wint_rmute" signature is all blurred? And how the rectangles have gained dark borders? And that the pattern of rectangles is uneven?

What's going on with this?

 

The source video is 1080p 24Hz x264 and everything else can play it directly.

Link to comment
Share on other sites

wintrmute

Hi Luke, here are the relevant server logs.

It confirms a couple of things.

1) "No direct play profiles found"

2) transcoding was used.

 

You can get a copy of the file I was playing here: https://www.dropbox.com/s/g0t85flzavy4d2x/24fps_judder_test.mp4

2016-12-07 18:48:52.0580 Info HttpServer: HTTP POST http://10.23.1.1:8096/emby/Items/a52bc32e50f87f55f9b692c2e1db8a72/PlaybackInfo?format=json. UserAgent: Dalvik/2.1.0 (Linux; U; Android 5.1.1; AFTS Build/LVY48F)
2016-12-07 18:48:52.0657 Info App: Profile: Android-VLC, Path: /filestore/media/Other Videos/24fps_judder_test.mp4, isEligibleForDirectPlay: True, isEligibleForDirectStream: True
2016-12-07 18:48:52.0657 Info App: Profile: Android-VLC, No direct play profiles found for Path: /filestore/media/Other Videos/24fps_judder_test.mp4
2016-12-07 18:48:52.0657 Info App: Profile: Android-VLC, Path: /filestore/media/Other Videos/24fps_judder_test.mp4, isEligibleForDirectPlay: True, isEligibleForDirectStream: True
2016-12-07 18:48:52.0657 Info App: Profile: Android-VLC, No direct play profiles found for Path: /filestore/media/Other Videos/24fps_judder_test.mp4
2016-12-07 18:48:52.0657 Info App: Profile: Android-VLC, Path: /filestore/media/Other Videos/24fps_judder_test.mp4, isEligibleForDirectPlay: True, isEligibleForDirectStream: True
2016-12-07 18:48:52.0657 Info App: Profile: Android-VLC, No direct play profiles found for Path: /filestore/media/Other Videos/24fps_judder_test.mp4
2016-12-07 18:48:52.0669 Info HttpServer: HTTP Response 200 to 10.23.1.11. Time: 9ms. http://10.23.1.1:8096/emby/Items/a52bc32e50f87f55f9b692c2e1db8a72/PlaybackInfo?format=json
2016-12-07 18:48:52.1499 Info HttpServer: HTTP POST http://10.23.1.1:8096/emby/Items/a52bc32e50f87f55f9b692c2e1db8a72/PlaybackInfo?format=json. UserAgent: Dalvik/2.1.0 (Linux; U; Android 5.1.1; AFTS Build/LVY48F)
2016-12-07 18:48:52.1592 Info App: Profile: Android-Exo, Path: /filestore/media/Other Videos/24fps_judder_test.mp4, isEligibleForDirectPlay: True, isEligibleForDirectStream: True
2016-12-07 18:48:52.1592 Info App: Profile: Android-Exo, No direct play profiles found for Path: /filestore/media/Other Videos/24fps_judder_test.mp4
2016-12-07 18:48:52.1592 Info App: Profile: Android-Exo, Path: /filestore/media/Other Videos/24fps_judder_test.mp4, isEligibleForDirectPlay: True, isEligibleForDirectStream: True
2016-12-07 18:48:52.1592 Info App: Profile: Android-Exo, No direct play profiles found for Path: /filestore/media/Other Videos/24fps_judder_test.mp4
2016-12-07 18:48:52.1592 Info App: Profile: Android-Exo, Path: /filestore/media/Other Videos/24fps_judder_test.mp4, isEligibleForDirectPlay: True, isEligibleForDirectStream: True
2016-12-07 18:48:52.1592 Info App: Profile: Android-Exo, No direct play profiles found for Path: /filestore/media/Other Videos/24fps_judder_test.mp4
2016-12-07 18:48:52.1608 Info HttpServer: HTTP Response 200 to 10.23.1.11. Time: 11ms. http://10.23.1.1:8096/emby/Items/a52bc32e50f87f55f9b692c2e1db8a72/PlaybackInfo?format=json
2016-12-07 18:48:52.2101 Info HttpServer: HTTP GET http://10.23.1.1:8096/emby/videos/a52bc32e50f87f55f9b692c2e1db8a72/stream.mkv?DeviceId=c5fc47582dc49907&MediaSourceId=a52bc32e50f87f55f9b692c2e1db8a72&VideoCodec=h264&AudioCodec=ac3,aac,mp3&VideoBitrate=70137670&AudioBitrate=192000&MaxAudioChannels=6&MaxFramerate=60&Level=51&Profile=high&PlaySessionId=6e3c9dd72f5b409a99a8ac0d53d7afe4&CopyTimestamps=true&SubtitleMethod=Encode&TranscodingMaxAudioChannels=6&EnableSubtitlesInManifest=false&Tag=671cfa071a92407153340c6258803622&EnableSplittingOnNonKeyFrames=false&RequireAvc=false. UserAgent: EMVideoView 2.5.6 (25600) / Android 5.1.1 / AFTS
2016-12-07 18:48:52.2189 Info HttpServer: HTTP POST http://10.23.1.1:8096/emby/Sessions/Playing. UserAgent: Dalvik/2.1.0 (Linux; U; Android 5.1.1; AFTS Build/LVY48F)
2016-12-07 18:48:52.2213 Info App: /usr/bin/ffmpeg -fflags +genpts -i file:"/filestore/media/Other Videos/24fps_judder_test.mp4" -map 0:0 -map -0:a -map -0:s -codec:v:0 libx264 -force_key_frames "expr:gte(t,n_forced*5)" -vf "scale=trunc(min(max(iw\,ih*dar)\,426)/2)*2:trunc(ow/dar/2)*2" -copyts -avoid_negative_ts disabled -start_at_zero -pix_fmt yuv420p -preset superfast -crf 23 -tune zerolatency -b:v 46410 -maxrate 46410 -bufsize 92820 -vsync -1 -profile:v high -level 4.1 -map_metadata -1 -threads 0  -y "/home/emby/transcoding-temp/e1e93d16c47f502b700fb9171ae98362.mkv"
2016-12-07 18:48:52.2566 Info HttpServer: HTTP Response 204 to 10.23.1.11. Time: 38ms. http://10.23.1.1:8096/emby/Sessions/Playing
2016-12-07 18:48:53.3549 Info HttpServer: HTTP GET http://10.23.1.1:8096/emby/videos/a52bc32e50f87f55f9b692c2e1db8a72/stream.mkv?DeviceId=c5fc47582dc49907&MediaSourceId=a52bc32e50f87f55f9b692c2e1db8a72&VideoCodec=h264&AudioCodec=ac3,aac,mp3&VideoBitrate=70137670&AudioBitrate=192000&MaxAudioChannels=6&MaxFramerate=60&Level=51&Profile=high&PlaySessionId=6e3c9dd72f5b409a99a8ac0d53d7afe4&CopyTimestamps=true&SubtitleMethod=Encode&TranscodingMaxAudioChannels=6&EnableSubtitlesInManifest=false&Tag=671cfa071a92407153340c6258803622&EnableSplittingOnNonKeyFrames=false&RequireAvc=false. UserAgent: EMVideoView 2.5.6 (25600) / Android 5.1.1 / AFTS
Link to comment
Share on other sites

wintrmute

Apologies. ffmpeg log attached.

 

Note that I think the flaw is that transcoding was being done at all, rather than the nature of the transcoding.

That said -- the transcoded quality was terrible.

 

I note from the logs that ffmpeg is using crf=23 and preset=superfast.

 

My original video was encoded with crf=18 and profile=medium. It's just flickering grey squares (to test whether 3:2 pulldown is applied), so maybe ffmpeg is just particularly poor at encoding it well on the superfast preset level? I've adjusted emby server to use 'fast' instead, and crf=18, and will see how that looks.

 

 

But.. I don't think it should have been transcoded at all. It's an Amazon Fire TV 2.. it supports x264 pretty well.

 

Thanks for looking at my report!

ffmpeg-log.txt

Edited by wintrmute
Link to comment
Share on other sites

The transcoding quality was terrible due to the very low content bitrate. We don't increase bitrate when we re-encode, so having to re-encode a 47kb bitrate source will generally not turn out too well.

 

I'm looking into why it's transcoding in the first place though.

Link to comment
Share on other sites

Ah yes, good catch. The high number of ref frames. We have removed this limitation in the beta version.

Link to comment
Share on other sites

wintrmute

You're a genius for figuring that out!

I'm surprised the ref frames are so high as well; turns out that x264 doubles the number of them when you select the animation tune, taking it from 5 to 10 on the 'slow' preset.

I thought the -profile high should have constrained it to 4 though, but.. I guess not.

I'll update my encoding script.

# Original ffmpeg line to encode judder video:
ffmpeg -framerate 24000/1001 -i frame%04d.png \ 
   -crf 18 -c:v libx264 -r 24000/1001 -pix_fmt yuv420p -tune animation -profile:v high \
   -preset slow out.mp4
Edited by wintrmute
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...