1. Gericom

    OP Gericom GBAtemp Maniac
    Member

    Joined:
    Jun 30, 2011
    Messages:
    1,359
    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.
     

    Attached Files:

  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

    Joined:
    Jun 30, 2011
    Messages:
    1,359
    Country:
    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
    Tarmfot likes this.
  4. alexander1970

    alexander1970 A Pink Background for Christmas please.
    Member

    Joined:
    Nov 8, 2018
    Messages:
    11,091
    Country:
    Austria
    I really apprecite your still great passion for the DSi.
    Thank you.:)
     
    ry755, Tarmfot, zxr750j and 3 others like this.
  5. Pk11

    Pk11 A cat girl with a DSi
    Member

    Joined:
    Jun 26, 2019
    Messages:
    187
    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"
    
     
    Stealphie, Robz8, Tarmfot and 2 others like this.
  6. tomrev

    tomrev GBAtemp Fan
    Member

    Joined:
    Oct 19, 2009
    Messages:
    364
    Country:
    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

    Joined:
    Jun 30, 2011
    Messages:
    1,359
    Country:
    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 Member
    Newcomer

    Joined:
    Sep 12, 2019
    Messages:
    14
    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, Sep 15, 2019
  9. tomrev

    tomrev GBAtemp Fan
    Member

    Joined:
    Oct 19, 2009
    Messages:
    364
    Country:
    United States
    That terminal output is normal. Do you test your out.mp4 with MP4 player?
     
  10. Merith

    Merith Member
    Newcomer

    Joined:
    Sep 12, 2019
    Messages:
    14
    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, Sep 16, 2019
  11. Pk11

    Pk11 A cat girl with a DSi
    Member

    Joined:
    Jun 26, 2019
    Messages:
    187
    Country:
    United States
    @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
     

    Attached Files:

    Last edited by Pk11, Oct 20, 2019
    Tarmfot, alexander1970 and tomrev like this.
  12. Pk11

    Pk11 A cat girl with a DSi
    Member

    Joined:
    Jun 26, 2019
    Messages:
    187
    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
     

    Attached Files:

    Last edited by Pk11, Nov 27, 2019
  13. Gekoh

    Gekoh Newbie
    Newcomer

    Joined:
    Oct 28, 2019
    Messages:
    2
    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?
     
  14. Pk11

    Pk11 A cat girl with a DSi
    Member

    Joined:
    Jun 26, 2019
    Messages:
    187
    Country:
    United States
    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).
     
  15. Hambrew

    Hambrew not your therapist
    Member

    Joined:
    Oct 9, 2018
    Messages:
    505
    Country:
    United States
  16. Gekoh

    Gekoh Newbie
    Newcomer

    Joined:
    Oct 28, 2019
    Messages:
    2
    Country:
    Canada
    Thanks for the reply, I tried the edited version but it still makes an empty mp4.
     
  17. Pk11

    Pk11 A cat girl with a DSi
    Member

    Joined:
    Jun 26, 2019
    Messages:
    187
    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:
     

    Attached Files:

  18. Robz8

    Robz8 Coolest of TWL
    Developer

    Joined:
    Oct 1, 2010
    Messages:
    13,677
    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
     
  19. azure0612

    azure0612 Member
    Newcomer

    Joined:
    Sep 24, 2017
    Messages:
    18
    Country:
    Indonesia
    How to fix no sound video? I've test it with media player in my pc and It's alright and jas a sound. The video show correctly but no with sound.
     
  20. Robz8

    Robz8 Coolest of TWL
    Developer

    Joined:
    Oct 1, 2010
    Messages:
    13,677
    Country:
    United States
    Have you tried what I posted?
     
Draft saved Draft deleted
Loading...

Hide similar threads Similar threads with keywords - Player, MPEG4,