Homebrew MPEG4 Player for DS and DSi

Gericom

Well-Known Member
OP
Member
Joined
Jun 30, 2011
Messages
1,359
Trophies
0
Age
23
XP
3,867
Country
Netherlands
Lately I've been working to make a spinoff from my YoutubeDS project from a couple of years ago, to make it into a useable video player. After a lot of bugfixes and improvements I've managed to get pretty nice results. Mainly on DSi it works very well. It plays mpeg4 video and aac audio in a mp4 container. Note that the code is pretty shitty as it is a modified version of youtube ds. This project might be incorporated in some general purpose media player for ds(i) at some point, but concrete plans have not been made yet. The code can be build with the latest version of devkitpro.

How to convert
Use a recent version of ffmpeg. The player plays 176x144 stretched to widescreen with a little filtering and 256x144. Instead of the normal YUV color space, YCoCg is used because it is faster to convert to rgb. Ignore any warnings you get about it. On a pc the colors will look wrong, but it's fine in the player.
Recommend settings for DS:
Code:
ffmpeg -i %1 -f mp4 -s 176x144 -vf "colorspace=space=ycgco:primaries=bt709:trc=bt709:range=pc:iprimaries=bt709:iall=bt709" -dst_range 1 -color_range 2 -vcodec mpeg4 -profile:v 0 -level 8 -b:v 350000 -acodec aac -ar 22050 -b:a 64000 -ac 1 -slices 1 -g 50 %2
Recommend settings for DSi:
Code:
ffmpeg -i %1 -f mp4 -s 256x144 -vf "colorspace=space=ycgco:primaries=bt709:trc=bt709:range=pc:iprimaries=bt709:iall=bt709" -dst_range 1 -color_range 2 -vcodec mpeg4 -profile:v 0 -level 8 -b:v 500000 -acodec aac -ar 32000 -b:a 128000 -ac 1 -slices 1 -g 50 %2

In both cases replace %1 with your input video and %2 with your output video. Higher bitrates and such may work, depending on the video. Supported framerates are 23.976 fps and 29.97 fps, although on ds 23.976 will likely give the best results. Other framerates are not properly supported, as currently the rate is not completely correctly read from the mp4 container. It also seems that the bitstream changes a bit with some rates, which make the decoding fail. If your input video doesn't have the right rate, add fps=24000/1001, before colorspace in the commands above. Note that with long videos audio issues may appear after playing for a while. This is related to the precision of the audio timers on arm7. I still have to adjust the video rate so that it matches the amount of increase/decrease in audio rate to fix that (something smaller than 1%, won't be noticable).

Pressing B while playing a video will return to the file browser.

Github: https://github.com/Gericom/YoutubeDS/tree/mpeg4player

Special thanks to @Pk11 for helping with testing and adding the file browser.
 

Attachments

  • MPEG4Player.zip
    172.8 KB · Views: 1,533
P

pasc

Guest
How does this fare in comparison to tunavids ?

How come the colors look garbled on the pc ? Is this a codec problem ?
 

Gericom

Well-Known Member
OP
Member
Joined
Jun 30, 2011
Messages
1,359
Trophies
0
Age
23
XP
3,867
Country
Netherlands
How does this fare in comparison to tunavids ?

How come the colors look garbled on the pc ? Is this a codec problem ?
I've not compared it with tunavids, so maybe you could do some comparison? The colors look wrong on pc, because mpeg4 does not officially support the color format. So your player on pc does not know that anything's different about the videos (that's why ffmpeg gives a warning).

Edit: According to this page (https://www.chishm.com/tuna-vids/index.html) it supports up to 12fps, so mine supports a higher frame rate at least and also higher bitrates as it seems. Furthermore gives aac better audio quality at low bitrates than mp3.
 
Last edited by Gericom,
  • Like
Reactions: Tarmfot

Pk11

A catgirl with a DSi
Member
Joined
Jun 26, 2019
Messages
429
Trophies
1
Age
20
Location
米国
Website
pk11.us
XP
1,977
Country
United States
From the videos I've tried I've found that ↓ works really well on DSi with the current build.
Code:
ffmpeg -i %1 -f mp4 -vf "fps=24000/1001, colorspace=space=ycgco:primaries=bt709:trc=bt709:range=pc:iprimaries=bt709:iall=bt709, scale=256:144" -dst_range 1 -color_range 2 -vcodec mpeg4 -profile:v 0 -level 8 -q:v 2 -maxrate 1200k -acodec aac -ar 32k -b:a 128000 -ac 1 -slices 1 -g 50 %2
(as with Gericom's commands above %1 is input and %2 is output)
If you want to add black bars to non-widescreen video so it doesn't stretch you can do ↓ for the scale filter
Code:
scale=256:144:force_original_aspect_ratio=decrease,pad=256:144:(ow-iw)/2:(oh-ih)/2"
 

Merith

Member
Newcomer
Joined
Sep 12, 2019
Messages
14
Trophies
0
Age
21
XP
62
Country
United States
I am having troubles making it work

I have ffmpeg installed on windows 10, and i converted the file using FFMpeg Batch Converter AND the command line
https://i.imgur.com/Y3r5wEI.png
^ Current settings

The arguments i used are
`ffmpeg -i %1 -f mp4 -vf "fps=24000/1001, colorspace=space=ycgco:Primaries=bt709:trc=bt709:range=pc:iprimaries=bt709:iall=bt709, scale=256:144" -dst_range 1 -color_range 2 -vcodec mpeg4 -profile:v 0 -level 8 -q:v 2 -maxrate 1200k -acodec aac -ar 32k -b:a 128000 -ac 1 -slices 1 -g 50 %2`

Please ignore the smily, I hate this auto syntax crap that forums has (I am a heavy markdown user


I have tried launching with Twilight++ and Unlaucher on a DSi (Using Camera PIT Exploit)

Both give just about the same error

Is it possible for you to provide a test file we can use (litterally anything from a Free to use Source) to test stuff?

Because when i use the reccomended settings for DSi you gave, `in.avi`>`out.mp4` as my file args
it spams this in my terminal
```
[scaler_out_0_0 @ 000001eaf37f2600] Detected unsupported YCgCo colorspace.bits/s dup=1 drop=0 speed=0.616x
Last message repeated 9 times
```
with the speed and last message being different each line

Is this normaL
 
Last edited by Merith,

tomrev

Well-Known Member
Member
Joined
Oct 19, 2009
Messages
365
Trophies
0
Website
www.buycheapipodshop.com
XP
323
Country
United States
I am having troubles making it work

I have ffmpeg installed on windows 10, and i converted the file using FFMpeg Batch Converter AND the command line
https://i.imgur.com/Y3r5wEI.png
^ Current settings

The arguments i used are
`ffmpeg -i %1 -f mp4 -vf "fps=24000/1001, colorspace=space=ycgco:Primaries=bt709:trc=bt709:range=pc:iprimaries=bt709:iall=bt709, scale=256:144" -dst_range 1 -color_range 2 -vcodec mpeg4 -profile:v 0 -level 8 -q:v 2 -maxrate 1200k -acodec aac -ar 32k -b:a 128000 -ac 1 -slices 1 -g 50 %2`

Please ignore the smily, I hate this auto syntax crap that forums has (I am a heavy markdown user


I have tried launching with Twilight++ and Unlaucher on a DSi (Using Camera PIT Exploit)

Both give just about the same error

Is it possible for you to provide a test file we can use (litterally anything from a Free to use Source) to test stuff?

Because when i use the reccomended settings for DSi you gave, `in.avi`>`out.mp4` as my file args
it spams this in my terminal
```
[scaler_out_0_0 @ 000001eaf37f2600] Detected unsupported YCgCo colorspace.bits/s dup=1 drop=0 speed=0.616x
Last message repeated 9 times
```
with the speed and last message being different each line

Is this normaL

That terminal output is normal. Do you test your out.mp4 with MP4 player?
 

Merith

Member
Newcomer
Joined
Sep 12, 2019
Messages
14
Trophies
0
Age
21
XP
62
Country
United States
What do you mean by `MP4 Player`? Like one on my PC? Windows Media Player works just fine on my Windows 7 PC with the out.mp4
 
Last edited by Merith,

Pk11

A catgirl with a DSi
Member
Joined
Jun 26, 2019
Messages
429
Trophies
1
Age
20
Location
米国
Website
pk11.us
XP
1,977
Country
United States
Thank you for your mavelous app for DS. Could you expand vertical resolution to 192 pixel?

@tomrev I just made a new Pull Request on the GitHub that add support for stretching to full screen. (and a couple other things)
The video file still 144p and it's not specially filtered or anything so it doesn't look super great, but it at least lets you have 4:3 videos in the right aspect ratio, I'll attach a build if you want it

Edit 2019/10/20 2:25 CST: Updated to a build of 1181da1
Edit 2019/10/20 15:54 CST: Updated to a build of 9a42ae5, this adds automatic aspect ratio detection instead of needing to press Select
 

Attachments

  • MPEG4Player.nds.zip
    176 KB · Views: 290
Last edited by Pk11,

Pk11

A catgirl with a DSi
Member
Joined
Jun 26, 2019
Messages
429
Trophies
1
Age
20
Location
米国
Website
pk11.us
XP
1,977
Country
United States
I've got another branch I'm working on now that adds a fancier UI and proper 256x192 support:
https://github.com/Epicpkmn11/YoutubeDS/tree/mpeg4player-graphics-instead-of-console

This is what I've found works best for 256x192 videos on DSi: (350Kbps and lower quality audio)
Code:
ffmpeg -i %1 -f mp4 -s 256x192 -vf "fps=24000/1001, colorspace=space=ycgco:primaries=bt709:trc=bt709:range=pc:iprimaries=bt709:iall=bt709" -dst_range 1 -color_range 2 -vcodec mpeg4 -profile:v 0 -level 8 -b:v 350k -maxrate 500k -acodec aac -ar 22050 -b:a 64000 -ac 1 -slices 1 -g 50 %2

Attached is a build of 3d4815d

Edit: Removed subtitles filter with bash variable
Edit 2: Added -maxrate 500k since without it you can get frameskips
 

Attachments

  • MPEG4Player.nds.zip
    260.7 KB · Views: 315
Last edited by Pk11,

Gekoh

New Member
Newbie
Joined
Oct 28, 2019
Messages
2
Trophies
0
Age
22
XP
15
Country
Canada
Code:
ffmpeg -i video.mp4 -f mp4 -s 256x192 -vf "subtitles='$item', fps=24000/1001, colorspace=space=ycgco:primaries=bt709:trc=bt709:range=pc:iprimaries=bt709:iall=bt709" -dst_range 1 -color_range 2 -vcodec mpeg4 -profile:v 0 -level 8 -b:v 350000 -acodec aac -ar 22050 -b:a 64000 -ac 1 -slices 1 -g 50 output.mp4
I have the batch file & video in the same directory where ffmpeg is, could someone tell me why it's creating an empty mp4 file?
 

Pk11

A catgirl with a DSi
Member
Joined
Jun 26, 2019
Messages
429
Trophies
1
Age
20
Location
米国
Website
pk11.us
XP
1,977
Country
United States
Code:
ffmpeg -i video.mp4 -f mp4 -s 256x192 -vf "subtitles='$item', fps=24000/1001, colorspace=space=ycgco:primaries=bt709:trc=bt709:range=pc:iprimaries=bt709:iall=bt709" -dst_range 1 -color_range 2 -vcodec mpeg4 -profile:v 0 -level 8 -b:v 350000 -acodec aac -ar 22050 -b:a 64000 -ac 1 -slices 1 -g 50 output.mp4
I have the batch file & video in the same directory where ffmpeg is, could someone tell me why it's creating an empty mp4 file?
Oh, I left the subtitles filter in my command and it was using a bash variable not a windows variable ($item), try it without that (How it is in my edit).
 

Gekoh

New Member
Newbie
Joined
Oct 28, 2019
Messages
2
Trophies
0
Age
22
XP
15
Country
Canada
Oh, I left the subtitles filter in my command and it was using a bash variable not a windows variable ($item), try it without that (How it is in my edit).
Thanks for the reply, I tried the edited version but it still makes an empty mp4.
 

Pk11

A catgirl with a DSi
Member
Joined
Jun 26, 2019
Messages
429
Trophies
1
Age
20
Location
米国
Website
pk11.us
XP
1,977
Country
United States
In my latest commit I added jumping forward/backward by 5 seconds with right/left and scrubbing on the touch screen
(Note: I don't have it jumping to keyframes or so yet so the video'll be kinda messed up for a second or so after the jump usually)

Build attached:
 

Attachments

  • MPEG4Player.nds.zip
    261.2 KB · Views: 424

RocketRobz

Stylish TWiLight Hero
Developer
Joined
Oct 1, 2010
Messages
14,894
Trophies
2
Age
22
XP
17,156
Country
United States
Posting this, in case if your video doesn't work as converted.
Code:
ffmpeg -i %1 -f mp4 -vf "fps=24000/1001, colorspace=space=ycgco:primaries=bt709:trc=bt709:range=pc:iprimaries=bt709:iall=bt709, scale=256:144" -dst_range 1 -color_range 2 -vcodec mpeg4 -profile:v 0 -level 8 -q:v 2 -maxrate 500k -acodec aac -ar 32k -b:a 64000 -ac 1 -slices 1 -g 50 %2
Confirmed working by shutterbug2000