Xbox One Media Player && ffmpeg

    Today we are going to look at ways to encode videos so that they playback properly on the player. Testing will be done on a USB3 SanDisk flash drive and or an external SSD/HDD drive. I am assuming you have ffmpeg and youtube-dl in a working folder somewhere. Thanks to the folks at Mystery Box(Jacob + Katie Schwarz) for their source content(Youtube — PHANTOM FLEX 4K 1000FPS (ULTRAHD)).
    Let us grab a small file from youtube, ~572MB, using youtube-dl.
Listing info on file location.
youtube-dl -F
We are after the line below:
266 mp4 3840x2160 DASH video 22210k , avc1.640033, 24fps, video only, 572.44MiB

Pull the video file into the local folder:
youtube-dl -f 266
[[ Verbose ]]
[youtube] 13wt6cmCRK0: Downloading webpage
[youtube] 13wt6cmCRK0: Downloading video info webpage
[youtube] 13wt6cmCRK0: Extracting video information
[youtube] 13wt6cmCRK0: Downloading DASH manifest
[youtube] 13wt6cmCRK0: Downloading DASH manifest
[download] Destination: PHANTOM FLEX 4K 1000FPS (ULTRAHD)-13wt6cmCRK0.mp4
[download] 100% of 572.44MiB in 07:15

Grab the audio file as well. We want format code 141
youtube-dl -f 141
You should have the following files locally:

Rename the files to PhantomVideo.mp4 and PhantomAudio.m4a for simplicity.

Use ffmpeg to copy video and audio together into a single file.
ffmpeg -i PhantomVideo.mp4 -i PhantomAudio.m4a -c:v copy -c:a copy -flags global_header PhantomFinal.mp4
The file generated, PhantomFinal.mp4, will be ~598MB in size. Try it out using VideoLan.
Or mux both video and audio together at once. 🙂
youtube-dl -f 266+141

Now we have our fully cooked source file. It’s at 3840×2160 MPEG-4 AVC (Part 10) and MPEG AAC Audio.
Time to get to work.
It’s obvious the file will not play at its current resolution, so let’s bring it down to full HD instead.
ffmpeg -i PhantomFinal.mp4 -vf scale=1920:1080 PhantomFinal_FullHD.mp4
Copy the file to a flash drive, test it out on the xbox one. Playback should be flawless, scrubbing should be clean too.

Here are the possible combos to test on the media player:

—————————————FOR XVID—————————————————————————-

Xvid @ 1920×1080 using audio codec ac3 to output AVI/ac3 file.
ffmpeg -i PhantomFinal.mp4 -vf scale=1920:1080 -c:v libxvid -c:a ac3 PhantomFinalXVID_AC3.avi

Xvid @ 1920×1080 using audio codec aac to output AVI/aac file.
ffmpeg -i PhantomFinal.mp4 -vf scale=1920:1080 -c:v libxvid -c:a aac PhantomFinalXVID_AAC.avi

Xvid @ 1920×1080 using audio codec libmp3lame to output AVI/mp3 file.
ffmpeg -i PhantomFinal.mp4 -vf scale=1920:1080 -c:v libxvid -c:a libmp3lame PhantomFinalXVID_MP3.avi
Xvid with AAC is supported.
Xvid with AC3 is supported.
Xvid with MP3 is unsupported. Error 0xc00d36c4
—————————————FOR H264—————————————————————————-

H264(x264) @1920×1080 using audio codec aac to output h264/aac file.
We already did this version. PhantomFinal.mp4(UHD) or PhantomFinal_FullHD.mp4(1080p) is it.

H264(x264) @1920×1080 using audio codec ac3 to output h264/ac3 file.
ffmpeg -i PhantomFinal.mp4 -vf scale=1920:1080 -c:v libx264 -c:a ac3 PhantomFinalX264_AC3.mp4
H264(x264) @1920×1080 using audio codec mp3 to output h264/mp3 file.
ffmpeg -i PhantomFinal.mp4 -vf scale=1920:1080 -c:v libx264 -c:a libmp3lame PhantomFinalX264_MP3.mp4

Results? You should know that .mp4 or .mkv are just containers.
They should both work just fine with a catch, .mkv extension gets no preview icon but .mp4 does.
H264/x264 with AAC is supported.
H264/x264 with AC3 is supported.
H264/x264 with MP3 is supported.
—————————————FOR HEVC/x265————————————————————————–

HEVC(x265) @1920×1080 using audio codec aac to output hevc/aac file.
ffmpeg -i PhantomFinal.mp4 -vf scale=1920:1080 -c:v libx265 -c:a aac PhantomFinalX265_AAC.mp4
HEVC(x265) @1920×1080 using audio codec ac3 to output hevc/ac3 file.
ffmpeg -i PhantomFinal.mp4 -vf scale=1920:1080 -c:v libx265 -c:a ac3 PhantomFinalX265_AC3.mp4
HEVC(x265) @1920×1080 using audio codec mp3 to output hevc/mp3 file.
ffmpeg -i PhantomFinal.mp4 -vf scale=1920:1080 -c:v libx265 -c:a libmp3lame PhantomFinalX265_MP3.mp4

Results? You should know that .mp4 or .mkv can be switched seemlessly.
Once again video icon preview is disabled for .mkv but .mp4 shows preview.
H265/x265 with AAC is supported
H265/x265 with AC3 is supported
H265/x265 with MP3 is supported
I don’t know why you would be needing this really. DVD & Broadcast stuff such as DVR/Set top boxes?
Here is a sample that plays back properly. Assuming we’re using original PhantomFinal.mp4
ffmpeg -i PhantomFinal.mp4 -vf scale=1920:1080 -c:v mpeg2video -f mpegts Phantom_FullHD_TS.ts

Based on the subtitles below, it appears there is a 1sec display delay using mpeg2 format.

Earlier we generated a 1080p file called PhantomFinal_FullHD.mp4.
Let’s draw subtitles on top of video input with file

ffmpeg -i PhantomFinal_FullHD.mp4 -vf PhantomFullHD_Subs.mp4
Copy that file to the USB flash drive and test it out. It should work nicely.

ffmpeg -i PhantomFinal.mp4 -vf scale=1920:1080 -c:v libx264 -crf 16 -c:a aac -b:a 255k PhantomFULL_HD_AAC_12MB.mp4

Scale video input to full hd
-vf scale=1920:1080
Video encoding to libx264
-c:v libx264
Constant Rate factor to achieve certain output quality when file size is of no importance.
-crf 16
Audio encoding to aac
-c:a aac
Audio bitrate of 255Kb
-b:a 255k

Here is how to add subs to the file generated above.
ffmpeg -i PhantomFULL_HD_AAC_12MB.mp4 -vf -crf 16 PhantomFULL_HD_AAC_12MB_SUBS.mp4

The above should get you started in the right direction on video encoding for xbox one/media player.
In a normal world, you would just grab the 1080p version from youtube and not reencode it.
Sometimes you start with a weird format and want to make it compatible for the console, this should help.
Questions? Ask in comment area. Thanks for viewing.

Leave a Reply

Your email address will not be published. Required fields are marked *