release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Wiki > Main > PluginMpegplayer (compare)

Difference: PluginMpegplayer (r120 vs. r119)

MPEG Player

Introduction

Mpegplayer on Iriver H300, Ipod Photo and Sandisk Sansa e200

mpegplayer is a work-in-progress MPEG video player viewer plugin.

It is currently capable of playing back MPEG-1 and MPEG-2 video streams with MPEG audio multiplexed into .mpg files (MPEG Program Stream).

To play a video file, you just select it in the Rockbox file browser. If your file does not have the .mpg extension, you will need to use the "Open With..." context menu option and choose "mpegplayer.

NOTE: mpegplayer does all video and audio decoding using your device's main CPU. It does not use any special video decoding hardware such as the Broadcom Video Processor found in the ipod Video. mpegplayer therefore performs very badly on such devices in comparison with the manufacturer's original firmware.

Download

Like all plugins documented on this website, mpegplayer is included in the standard Rockbox installation and does not need to be downloaded separately. NOTE: Viewer plugins like mpegplayer do not appear in the Browse Plugins menu - they are launched by selecting a file to be viewed in the normal file browser.

Supported Targets

MPEGPlayer works on all current targets apart from the Archos devices (use PluginVideo instead) and the iriver iFP. However, performance and usability varies greatly - see the following section for performance details.

Performance

The following table shows the speed that mpegplayer can decode the "Elephants Dream" sample video on various targets.

Tests are performed by enabling the Show FPS option and disabling the Limit FPS and Skip Frames options in mpegplayer, playing the video, and then waiting for the FPS to stabilise. Please round the FPS to the nearest whole number.

PlayerLCD Size128x96128x128160x96160x128176x96176x128224x128224x176320x176320x240Tested on SVN
Sansa c200 132x80                      
iriver H10 5/6GB 128x128     n/a n/a n/a n/a n/a n/a n/a n/a  
iriver H10 20GB 160x128 39fps 29fps 32fps 24fps n/a n/a n/a n/a n/a n/a  
iriver H120 160x128     30fps 22fps n/a n/a n/a n/a n/a n/a r16048
iaudio X5 160x128 52fps 39fps 44fps 32fps n/a n/a n/a n/a n/a n/a r15194
ipod Nano 176x132 57fps 42fps 47fps 35fps 43fps 32fps n/a n/a n/a n/a r13490
iriver H300 220x176   41fps 47fps 32fps 42fps 31fps 25fps 18fps n/a n/a r15168
ipod Color/Photo 220x176 55fps 41fps 45fps 33fps 41fps 30fps 25fps 18fps n/a n/a  
Sansa e200 220x176   59fps         37fps 27fps n/a n/a r16023
ipod Video 320x240 78fps 57fps 65fps 47fps 58fps 43fps 35fps 26fps 19fps 14fps r15832
Gigabeat 320x240 276fps 212fps 232fps 164fps 210fps 144fps 126fps 92fps 66fps 48fps r15189

Current limitations

Audio decoding and .mpg file parsing were added to mpegplayer on 1 January 2007. A/V Sync and rebuffering were added in March 2007. Seeking and WVS were added January 2008.

This is still a work-in-progress and is missing the following major features:

  • Limited audio samplerate - audio must be sampled at 44.1KHz, other samplerates will play, but at the wrong speed.

Anyone is welcome to download the source and implement these features.

Known Bugs

  • A/V Sync - sync is not yet perfect for all files. If you have an example file which plays in sync on a PC video player, but not in mpegplayer (with Limit FPS and Skip Frames) enabled, please post a comment and link in this forum thread.
  • USB detection - mpegplayer doesn't react correctly to USB insertion
  • End-of-file detection - sometimes mpegplayer will continue playing the file past the end - i.e. jump back to a previously buffered part of the file.
  • Backlight whilst charging - mpegplayer doesn't adjust the backlight timeout whilst charging setting, meaning that the backlight may turn off if you're watching a video when charging.
  • Quit/Stop problems - sometimes mpegplayer doesn't stop the video when requested, and may not successfully start playback of a subsequent video. (Note by DouglasValentine: Quiting playback from the menu before the end of the video then trying to play the same file again always locks up now fixed on my ipod nano) - FS #6921
  • Performance - performance seems to be noticably worse with the current mpegplayer compared to versions prior to rebuffering and av sync. (Note by PaulLouden: I think this can be tracked to the PTS update that checked for changing PTS values)
  • Headphone plug detection - When Pause on headphone remove is said, may cause similar problems to USB removal.
  • Idle power-off - FS #6091

Note by PaulLouden: Regarding End of File, I think that it may try to stop at the end of file and fail, because often the video will go into slow motion, in a very similar mannery to what has been described to me as happening when USB is inserted, and Headphones are inserted.

Key Mappings during playback

PlayerPause/ResumeStopMenu
ipod PLAY Long press on PLAY MENU
iriver H300 ON OFF A-B
iaudio X5 PLAY POWER REC
Gigabeat PLAY A MENU
iriver H10 PLAY POWER REW
Sansa e200 UP POWER SELECT

When a video file is selected, the start Menu will be displayed, unless it is disabled via the option "start menu" (see below). In the latter case the video will start playing immediately - unless a resume point is found, in which case the resume menu is presented.

Menu Options

Start Menu

Play from beginning

Resume information is discarded and the video plays from the start.

Resume time (min): x.x

Resume video playback at stored resume time x.x (start of the video if no resume time is found).

Set start time (min)

A preview screen is presented consisting of a thumbnail preview and a progress bar where the user can select a start time by 'seeking' through the video in 30 second increments. The video playback is started by pressing the select button.

Quit mpegplayer

Exit the plugin.

Resume Menu

Yes (min): x.x

Resume video playback at stored resume time x.x.

No

Play video from the beginning.

Main Menu

This menu can currently only be accessed during video playback, by pressing the "Menu" key during playback. (see "Key Mappings during playback") Wont work if your are currently in a menu (start/resume menu) or paused playback.

Display Options

Opens submenu - see below.

Start Menu (default: on)

Enable/disable the start menu. If disabled, video playback starts immidiately on plugin start.

Clear all resumes: x

Discard all x resume points.

Quit mpegplayer

Exit the plugin.

Display Options Menu

Dithering (default: off)

Prevent banding effects in gradients by blending of colours. (only available on Sansa e200, Sansa c200 and Gigabeat F/X, at this point).

Show FPS (default: off)

This option displays (once a second - if your video is full-screen this means it will get overwritten by the video and appear to flash once per second) the average number of frames decoded per second, the total number of frames skipped (see the Skip Frames option), the current time (in 100Hz ticks) and the time the current frame is due to be displayed.

Limit FPS (default: on)

With this option disabled, mpegplayer will display the video as fast as it can. Useful for benchmarking.

Skip frames (default: on)

This option causes mpegplayer to attempt to maintain realtime playback by skipping the display of frames - but these frames are still decoded. Disabling this option can cause loss of A/V sync.

Sample videos

Elephants Dream

The following files are encoded using mpeg2enc at "-q 6" quantization level. Audio is LAME-encoded MP3 (44.1KHz, Stereo, 170kbps VBR). The source video is the "world's first open movie" - Elephants Dream. It is available under an open license.

PlayersLCD Size 1:1 Video4:3 Video16:9 Video
iriver H300, ipod Color/Photo & Sansa e200 220x176 n/a 224x176-469kbps224x128-354kbps
ipod Nano 176x132 n/a 176x128-310kbps176x96-229kbps
ipod Video & Gigabeat 320x240 n/a 320x240-830kbps320x176-596kbps
iaudio X5 and iriver H10 20GB 160x128 n/a 160x128-287kbps160x96-212kbps
iriver H10 5/6GB 128x128 128x128-247kbps128x96-192kbps n/a

How to encode files

Choosing a resolution

MPEG-1 and MPEG-2 video is encoded using blocks of 16x16 pixels but the display dimensions can be anything which is a multiple of 2x2, not 2x2 pixels. just 16x16. The following table shows the LCD sizes of the various Rockbox players supported by mpegplayer, their LCD size, and the suggested resolution for approximate full-screen 4:3 and 16:9 video files.

PlayersLCD Size4:3 Video16:9 Video
ipod Video & Gigabeat 320x240 320x240 320x180
iriver H300, ipod Color/Photo & Sansa e200 220x176 220x166 220x124
ipod Nano 176x132 176x128 176x100
iaudio X5 / M5 and iriver H10 20GB / H120 160x128 160x120 160x90
ipod Mini 1G / 2G 138x110 138x104 138x78
iriver H10 5/6GB 128x128 128x96 128x72
Sansa c200 132x80 106x80 132x74

Note: Rockbox automatically rotates videos on the Gigabeat to landscape 320x240 and on the Sansa e200 to 220x176.

Encoding

Using WinFF (Windows/Linux)

1) Download and install WinFF 0.29 here: http://biggmatt.com/winff/downloads/winff-version-0.291.html

2) After the program is installed, replace the presets.xml in the WinFF folder (default is C:\Program Files\WinFF\) with this one: presets.xml

3) Run WinFF, pick your desired player from the list, type in any overrides in the boxes at the bottom of the window, add files to the list at the top, and start encoding! Note for Windows Vista users: WinFF may need to be run as an administrator (right click and choose to run it as administrator, or change the properties so that it always does) for it to properly be able to run ffmpeg.

Warning: If you're using the Linux version, and the encoder window flashes and disappears nearly instantly, resulting in 0-size files, it is most likely caused by your build of ffmpeg not having MP3 support. Check the documentation for your Linux distribution and see about compiling or downloading an appropriate replacement.

Using ffmpeg (Linux)

1) Install ffmpeg: on Debian-based systems, "apt-get install ffmpeg" will most likely do the job

2) run ffmpeg

ffmpeg -i [inputfilename] -s [displayresolution] -vcodec mpeg2video -b [video bitrate] -ab [audio bitrate] -ac [audio channels] -ar 44100 -acodec [audio codec] [outputfilename]

Short explanation of the parameters:

ParameterInfoGood for iPod Photo/Color
-i filename of the source video you choose :)
-s display resolution, f.e. 1024x768 220x176 220x166
-vcodec video codec, must be "mpeg2video" mpeg2video
-b video bitrate 200k
-ab audio bitrate 192k
-ac audio channels 2
-ar audio samplerate, must be 44100Hz 44100
-acodec audio codec, f.e. mp3 mp3 or libmp3lame

The ipod photo/color settings have been tested with some shorter music videos (3-5min) and seemed to work quite well. Framerate stays at about 20fps, minimal frame skipping on fast camera movement visible. The video will be mpeg2-encoded with 192kbps mp3 sound at 44.1KHz and 2 Channels (Stereo). The video bitrate is 200kbps, increasing it will make mpegplayer skip (too) many frames. The resolution of 220x176 will fill the ipod's whole display, except black borders caused by a different aspect ratio in the source video file.

Using VLC to encode on Linux / Mac OS X / Windows

Open a command line prompt and go to the VLC installation directory (default is C:\Program Files\VideoLAN\VLC\ ). Run the following command line:

vlc <input> --sout=#transcode{vcodec=mp2v,vb=600,width=<the width>,height=<the height>,
acodec=mp3,ab=128,samplerate=44100,audio-sync}:std{access=file,mux=ps,url=<filename>.mpg}

Note: You'll need to add quotes around #transcode{....}:std{...} on Linux or OS X.

vb stands for "video bitrate in kbits/sec". 600 kbits/sec should be good enough for most targets ... you might want to try a lower value for small screens.

ab stands for "audio bitrate in kbits/sec" and samplerate is the audio samplerate in Hz. Currently (2nd January 2007), mpegplayer only supports 44.1KHz audio.

Important: mpeg2 allows only some very specific framerates. If encoding fails, it's likely that your source framerate doesn't comply. To change the frame rate, add fps=25 or fps=29.97 in transcode{...}. (This applies to the following .bat file too)

A convenient way for Windows users to achieve the same result is to use VLC-transcode.bat. Simply save this file somewhere and drag&drop a video onto it and it will be transcoded using the above settings. You will probably want to edit the file to change width and height (default is 320x240).

Using Mplayer/Mencoder to encode on Linux / Mac OS X / Windows

MEncoder uses the following command line format:

mencoder <input> <options> -o <output file>

Video options:

-ovc lavc  [output video module]
-lavcoptc vcodec=mpeg2video [output video codec]
...vmax_b_frames=16:vb_strategy=2 [the player needs as many b-frames as possible, to ease decoding and frame skipping]
(note: specify the video bitrate with: mpeg2video:vbitrate=<bitrate>)
-vf scale,harddup [scale the video, remove duplicate frames]
-ofps <fps> [output frames per second, depending on the target, adjust as needed]
-zoom [when scaling, zoom rather than crop]

Audio options:

-oac lavc [output audio module]
-lavcopts acodec=mp3:abitrate=192 [output audio codec and bitrate, mp1/mp2/mp3 can be used]
(note: if your video already has a compatible audio track simply use '-oac copy' to copy it to the output file without transcoding)
-af resample=44100:0:0 [resample to 44.1 kHz, otherwise it won't play at proper speed]
Example

In a terminal do :

mencoder <input> -of mpeg -oac lavc -lavcopts acodec=mp2:abitrate=96:vmax_b_frames=16:vb_strategy=2 -af resample=44100:0:0 -ovc lavc -lavcopts 
vcodec=mpeg2video:vbitrate=<bitrate> -vf scale=<width>:<height>,harddup -ofps 25 -o <filename>.mpg

Other useful options : -ss start position in the input ( -ss 1:20:00 ) -endpos lenght of the output ( -endpos 1:00 )

You can use mpeg1video for the vcodec= instead of mpeg2video

The man page of mencoder : http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.html

Here is an example BAT file for encoding files in Windows with Drag and Drop. The new .mpg file will be made in the same folder as the .bat file (you can even leave the bat on your PMP). Change the settings to your liking(the path to mencoder), I am using these settings on a Gigabeat F.

  • encode.bat: Example BAT file for encoding files with mencoder

Using MediaCoder to encode on Windows

MediaCoder offers a point&click alternative to encoding single files, folders or DVD/CD.

1) Download the latest version from their website and install, also download this .zip and unzip it to C:\Program Files\MediaCoder\extensions\

2) Restart MediaCoder, add any files you want to encode (the GUI is very straight forward and their site is helpful if you have any problems) and click the "Extension" button at the top.

3) A pop-up window will give show you list of different devices, click "Rockbox Jukebox" under "Digital Media Player" This will open the Rockbox extension.

4) Here you can select your player and aspect ratio from the drop-down list. (some are grouped together, having the same screen dimensions)

5) Select your preferences and click "Play" to start/stop a preview, Click "Start" to begin the encoding. ("Preview" is to preview the encoded file after the encoding has begun)

6) For more advanced options, return to the main MediaCoder window and adjust the additional settings before starting. (you can also use the "Start" button in the main window)

[To be completed: using mpeg2enc, ...]

Future Development (notes for developers)

Links


CategoryPlugin: MPEG video player [H100DONE, H300DONE, H10DONE, iPod 4GDONE, iPod ColorDONE, iPod MiniDONE, iPod NanoDONE, iPod VideoDONE, iAudio M5DONE, iAudio X5DONE, GigabeatDONE, Sansa e200DONE, Sansa c200DONE]

r172 - 02 Nov 2012 - 00:04:10 - DavidHall

Revision r120 - 11 Jan 2008 - 09:29 - MarcoenHirschberg
Revision r119 - 11 Jan 2008 - 01:46 - MarcoenHirschberg
Copyright by the contributing authors.