Jump to content

Why transcode h264 video?


mjb2000

Recommended Posts

mjb2000

I have two files which for test purposes I have encoded using FFMPEG:

ffmpeg -t 10 -i bunny.mp4 -map_metadata -1 -codec:v libx264 -profile:v high -level 4.0 -b:v 1000k -c:a aac -b:a 128k -ac 2 Bunny1.mkv
ffmpeg -t 10 -i bunny.mp4 -map_metadata -1 -codec:v libx264 -profile:v high -level 4.0 -b:v 1000k -c:a aac -b:a 128k -ac 2 Bunny2.mp4

Bunny1.mkv seems to require transcoding to playback, where as Bunny2.mp4 does not. I understand there might be some sort of issue with Emby on the AFTVS and MKVs (which is not an issue with Kodi on the AFTVS).

 

I don't  understand why the video would be re-transcoding when transcoding for the stick. Wouldn't it make sense for the Video (and Audio) streams to be copied by ffmpeg (with only the container format being changed)? If we could just change the container format the CPU overhead for the emby server would be MUCH lower. I'm guessing the answer might be that we need some control over keyframes to allow for HLS streaming, but if direct playback of the MP4 is possible, is it not possible to use this container format and not use HLS streaming?

 

The AFTV is set to 40mbps and to play via VLC.

I see Trans/I for Bunny1.mkv and Direct/I for Bunny2.mp4

 

Below is some more info that might be helpful...

 

Mediainfo for Bunny1.mkv

Video
Codec: H264
Profile: High
Level: 40
Resolution: 1920x1080
Aspect ratio: 16:9
Anamorphic: No
Interlaced: No
Framerate: 30
Bitrate: 1573 kbps
Bit depth: 8 bit
Pixel format: yuv420p
Ref frames: 4
Container: mkv

Audio
Codec: AAC
Profile: LC
Layou: tstereo
Channels: 2 ch
Sample rate: 48000 khz
Default: Yes

Bunny1.mkv transcode log

http://10.202.1.5:8096/emby/videos/27c78997bdaa9f76d16ad6632499ecc6/hls1/main/0.ts?DeviceId=700676b0ab0b95df&MediaSourceId=27c78997bdaa9f76d16ad6632499ecc6&VideoCodec=h264&AudioCodec=aac&AudioStreamIndex=1&VideoBitrate=39872000&AudioBitrate=128000&MaxAudioChannels=2&MaxWidth=1920&MaxHeight=1080&Level=40&ClientTime=1451166437827&MaxVideoBitDepth=8&Profile=high&PlaySessionId=d8879b38d70b4cc6aeac64c2df68a869&api_key=5d44663d654347e384cee425560a3629

{"Protocol":"File","Id":"27c78997bdaa9f76d16ad6632499ecc6","Path":"/mnt/movies/bunny1.mkv","Type":"Default","Container":"mkv","Name":"1080P/H264/AAC","RunTimeTicks":100870000,"ReadAtNativeFramerate":false,"SupportsTranscoding":true,"SupportsDirectStream":true,"SupportsDirectPlay":true,"RequiresOpening":false,"RequiresClosing":false,"VideoType":"VideoFile","MediaStreams":[{"Codec":"h264","IsInterlaced":false,"BitRate":1611488,"BitDepth":8,"RefFrames":4,"IsDefault":true,"IsForced":false,"Height":1080,"Width":1920,"AverageFrameRate":30,"RealFrameRate":30,"Profile":"High","Type":"Video","AspectRatio":"16:9","Index":0,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"PixelFormat":"yuv420p","Level":40,"IsAnamorphic":false},{"Codec":"aac","IsInterlaced":false,"ChannelLayout":"stereo","Channels":2,"SampleRate":48000,"IsDefault":true,"IsForced":false,"Profile":"LC","Type":"Audio","Index":1,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Level":0}],"PlayableStreamFileNames":[],"Formats":[],"Bitrate":1611488,"RequiredHttpHeaders":{}}

/var/lib/emby-server/ffmpeg/20150917/ffmpeg -i file:"/mnt/movies/bunny1.mkv" -map_metadata -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 libx264 -pix_fmt yuv420p -preset superfast -crf 23 -b:v 1611488 -maxrate 1611488 -bufsize 3222976 -vsync vfr -profile:v high -level 40 -force_key_frames "expr:gte(t,n_forced*3)" -vf "scale=min(iw\,1280):trunc(ow/dar/2)*2" -flags -global_header -sc_threshold 0 -codec:a:0 aac -strict experimental -ac 2 -ab 128000 -af "adelay=1,aresample=async=1" -hls_time 3 -start_number 0 -hls_list_size 0 -y "/var/lib/emby-server/transcoding-temp/5e13712ff166da44bb5204c51e4bbe2b.m3u8"


ffmpeg version N-49867-gd36eac6-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.3 (Debian 4.9.3-4)
  configuration: --enable-gpl --enable-version3 --disable-shared --disable-debug --enable-runtime-cpudetect --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --enable-libass --enable-gnutls --enable-libvidstab --enable-libsoxr --enable-frei0r --enable-libfribidi --cc=gcc-4.9
  libavutil      55.  2.100 / 55.  2.100
  libavcodec     57.  2.100 / 57.  2.100
  libavformat    57.  2.100 / 57.  2.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6.  4.100 /  6.  4.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, matroska,webm, from 'file:/mnt/movies/bunny1.mkv':
  Metadata:
    ENCODER         : Lavf57.20.100
  Duration: 00:00:10.09, start: 0.000000, bitrate: 1611 kb/s
    Stream #0:0: Video: h264 (High), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1k tbn, 60 tbc (default)
    Metadata:
      ENCODER         : Lavc57.20.100 libx264
      DURATION        : 00:00:10.087000000
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      ENCODER         : Lavc57.20.100 aac
      DURATION        : 00:00:10.021000000
[libx264 @ 0x382fe60] using SAR=1/1
[libx264 @ 0x382fe60] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0x382fe60] profile High, level 4.0
Output #0, hls, to '/var/lib/emby-server/transcoding-temp/5e13712ff166da44bb5204c51e4bbe2b.m3u8':
  Metadata:
    encoder         : Lavf57.2.100
    Stream #0:0: Video: h264 (libx264), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 1611 kb/s, 30 fps, 90k tbn, 30 tbc (default)
    Metadata:
      encoder         : Lavc57.2.100 libx264
    Stream #0:1: Audio: aac, 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      encoder         : Lavc57.2.100 aac
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
frame=   22 fps=0.0 q=21.0 size=N/A time=00:00:00.91 bitrate=N/A    
frame=   55 fps= 54 q=17.0 size=N/A time=00:00:02.00 bitrate=N/A    
frame=   89 fps= 59 q=19.0 size=N/A time=00:00:03.13 bitrate=N/A    
frame=  122 fps= 60 q=19.0 size=N/A time=00:00:04.24 bitrate=N/A    
frame=  148 fps= 58 q=21.0 size=N/A time=00:00:05.12 bitrate=N/A    
frame=  171 fps= 56 q=21.0 size=N/A time=00:00:05.86 bitrate=N/A    
frame=  200 fps= 56 q=22.0 size=N/A time=00:00:06.84 bitrate=N/A    
frame=  227 fps= 56 q=21.0 size=N/A time=00:00:07.74 bitrate=N/A    
frame=  250 fps= 55 q=25.0 size=N/A time=00:00:08.51 bitrate=N/A    
frame=  276 fps= 55 q=23.0 size=N/A time=00:00:09.38 bitrate=N/A    
frame=  300 fps= 54 q=-1.0 Lsize=N/A time=00:00:10.04 bitrate=N/A    
video:1582kB audio:159kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x382fe60] frame I:4     Avg QP: 9.12  size: 35806
[libx264 @ 0x382fe60] frame P:123   Avg QP:13.53  size:  9351
[libx264 @ 0x382fe60] frame B:173   Avg QP:14.85  size:  1885
[libx264 @ 0x382fe60] consecutive B-frames: 18.7% 13.3%  0.0% 68.0%
[libx264 @ 0x382fe60] mb I  I16..4: 62.2% 25.6% 12.2%
[libx264 @ 0x382fe60] mb P  I16..4: 18.9%  5.1%  0.3%  P16..4: 29.2%  0.0%  0.0%  0.0%  0.0%    skip:46.5%
[libx264 @ 0x382fe60] mb B  I16..4:  0.9%  0.1%  0.0%  B16..8:  7.4%  0.0%  0.0%  direct: 8.5%  skip:83.1%  L0:42.4% L1:49.0% BI: 8.5%
[libx264 @ 0x382fe60] 8x8 transform intra:21.1% inter:24.1%
[libx264 @ 0x382fe60] coded y,uvDC,uvAC intra: 9.0% 32.3% 17.1% inter: 4.5% 11.2% 1.1%
[libx264 @ 0x382fe60] i16 v,h,dc,p: 83% 11%  5%  1%
[libx264 @ 0x382fe60] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 19% 34%  5%  7%  5%  7%  4%  5%
[libx264 @ 0x382fe60] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 21% 21%  6%  6%  5%  7%  4%  7%
[libx264 @ 0x382fe60] i8c dc,h,v,p: 69% 15% 11%  5%
[libx264 @ 0x382fe60] Weighted P-Frames: Y:19.5% UV:17.9%
[libx264 @ 0x382fe60] kb/s:1295.59
  • Like 1
Link to comment
Share on other sites

All HD video is transcoded at the server on the Fire Stick because the processor on that device had trouble decoding direct streams with VLC.

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...