MPEG4 Player for DS and DSi

Discussion in 'NDS - Emulation and Homebrew' started by Gericom, Jul 22, 2019.

  1. Gericom
    OP

    Gericom GBAtemp Maniac

    Member
    11
    Jun 30, 2011
    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.
     

    Attached Files:

    Tarmfot, Zense, Indy13 and 16 others like this.
  2. pasc

    pasc Newbie

    How does this fare in comparison to tunavids ?

    How come the colors look garbled on the pc ? Is this a codec problem ?
     
  3. Gericom
    OP

    Gericom GBAtemp Maniac

    Member
    11
    Jun 30, 2011
    Netherlands
    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, Jul 22, 2019
  4. alexander1970

    alexander1970 GBAtemp allows me to be here

    Member
    11
    Nov 8, 2018
    Austria
    Austria
    I really apprecite your still great passion for the DSi.
    Thank you.:)
     
    Tarmfot, zxr750j, Ryccardo and 2 others like this.
  5. Pk11

    Pk11 Newbie

    Newcomer
    1
    Jun 26, 2019
    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"
    
     
    Tarmfot, tomrev and Gericom like this.
  6. tomrev

    tomrev GBAtemp Fan

    Member
    2
    Oct 19, 2009
    United States
    Thank you for your mavelous app for DS. Could you expand vertical resolution to 192 pixel?
     
  7. Gericom
    OP

    Gericom GBAtemp Maniac

    Member
    11
    Jun 30, 2011
    Netherlands
    I'm currently busy with some other things, but I may add support for that later.
     
    Tarmfot, tomrev, ber71 and 2 others like this.
  8. Merith

    Merith Newbie

    Newcomer
    1
    Sep 12, 2019
    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, Sep 15, 2019 at 9:07 PM
  9. tomrev

    tomrev GBAtemp Fan

    Member
    2
    Oct 19, 2009
    United States
    That terminal output is normal. Do you test your out.mp4 with MP4 player?
     
  10. Merith

    Merith Newbie

    Newcomer
    1
    Sep 12, 2019
    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, Sep 16, 2019 at 10:52 PM
Loading...