Homebrew MPEG4 Player for DS and DSi

Gericom

Well-Known Member
OP
Member
Joined
Jun 30, 2011
Messages
1,383
Trophies
2
Age
25
XP
4,715
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,699
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,383
Trophies
2
Age
25
XP
4,715
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
1,285
Trophies
1
Age
22
Location
米国
Website
xn--rck9c.xn--tckwe
XP
3,908
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
24
XP
95
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
24
XP
95
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
1,285
Trophies
1
Age
22
Location
米国
Website
xn--rck9c.xn--tckwe
XP
3,908
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: 441
Last edited by Pk11,

Pk11

A catgirl with a DSi
Member
Joined
Jun 26, 2019
Messages
1,285
Trophies
1
Age
22
Location
米国
Website
xn--rck9c.xn--tckwe
XP
3,908
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: 447
Last edited by Pk11,

Gekoh

New Member
Newbie
Joined
Oct 28, 2019
Messages
2
Trophies
0
Age
24
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
1,285
Trophies
1
Age
22
Location
米国
Website
xn--rck9c.xn--tckwe
XP
3,908
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
24
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
1,285
Trophies
1
Age
22
Location
米国
Website
xn--rck9c.xn--tckwe
XP
3,908
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: 628

RocketRobz

Stylish TWiLight Hero
Developer
Joined
Oct 1, 2010
Messages
16,648
Trophies
3
Age
24
XP
21,115
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
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • BigOnYa @ BigOnYa:
    Biomutant looks cool tho, may have to try that
  • Quincy @ Quincy:
    Usually when such a big title leaks the Temp will be the first to report about it (going off of historical reports here, Pokemon SV being the latest one I can recall seeing pop up here)
  • K3Nv2 @ K3Nv2:
    I still like how a freaking mp3 file hacks webos all that security defeated by text yet again
  • BigOnYa @ BigOnYa:
    They have simulators for everything nowdays, cray cray. How about a sim that shows you playing the Switch.
  • K3Nv2 @ K3Nv2:
    That's called yuzu
    +1
  • BigOnYa @ BigOnYa:
    I want a 120hz 4k tv but crazy how more expensive the 120hz over the 60hz are. Or even more crazy is the price of 8k's.
  • K3Nv2 @ K3Nv2:
    No real point since movies are 30fps
  • BigOnYa @ BigOnYa:
    Not a big movie buff, more of a gamer tbh. And Series X is 120hz 8k ready, but yea only 120hz 4k games out right now, but thinking of in the future.
  • K3Nv2 @ K3Nv2:
    Mostly why you never see TV manufacturers going post 60hz
  • BigOnYa @ BigOnYa:
    I only watch tv when i goto bed, it puts me to sleep, and I have a nas drive filled w my fav shows so i can watch them in order, commercial free. I usually watch Married w Children, or South Park
  • K3Nv2 @ K3Nv2:
    Stremio ruined my need for nas
  • BigOnYa @ BigOnYa:
    I stream from Nas to firestick, one on every tv, and use Kodi. I'm happy w it, plays everything. (I pirate/torrent shows/movies on pc, and put on nas)
  • K3Nv2 @ K3Nv2:
    Kodi repost are still pretty popular
  • BigOnYa @ BigOnYa:
    What the hell is Kodi reposts? what do you mean, or "Wut?" -xdqwerty
  • K3Nv2 @ K3Nv2:
    Google them basically web crawlers to movie sites
  • BigOnYa @ BigOnYa:
    oh you mean the 3rd party apps on Kodi, yea i know what you mean, yea there are still a few cool ones, in fact watched the new planet of the apes movie other night w wifey thru one, was good pic surprisingly, not a cam
  • BigOnYa @ BigOnYa:
    Damn, only $2.06 and free shipping. Gotta cost more for them to ship than $2.06
  • BigOnYa @ BigOnYa:
    I got my Dad a firestick for Xmas and showed him those 3rd party sites on Kodi, he loves it, all he watches anymore. He said he has got 3 letters from AT&T already about pirating, but he says f them, let them shut my internet off (He wants out of his AT&T contract anyways)
  • K3Nv2 @ K3Nv2:
    That's where stremio comes to play never got a letter about it
  • BigOnYa @ BigOnYa:
    I just use a VPN, even give him my login and password so can use it also, and he refuses, he's funny.
  • BigOnYa @ BigOnYa:
    I had to find and get him an old style flip phone even without text, cause thats what he wanted. No text, no internet, only phone calls. Old, old school.
    K3Nv2 @ K3Nv2: @BigOnYa...