Discussion about ffplay

It’s fascinating that ffplay has touch support at all!

BTW, it would be relatively easy to create a desktop file to open links with it.

However, you need a direct link to the actual video stream, right? Youtube links won’t work? Maybe piping yt-dlp’s output?

Also, ffplay does not seem to be available on SFOS?

I think i saw ffplay in openrepos (in ffmpeg package, this one has also better touch support)
by default it unfortunately only supports mouse (and touch simulates left mouse click), so only play/pause.
for touch you have to add something like this (I’m not very good with c nor do I have much clue about sdl :upside_down_face:)

 case SDL_FINGERDOWN:
            touch_down = 1;
            touch_time = SDL_GetTicks();
            last_touch_x = event.tfinger.x;
            last_touch_y = event.tfinger.y;
            av_log(NULL, AV_LOG_INFO, "----------TOUCH START---------------\n");
            av_log(NULL, AV_LOG_INFO, "down %dms - touch x/y %f/%f\n", touch_time,last_touch_x, last_touch_y);
            av_log(NULL, AV_LOG_INFO, "------------------------------------\n");
            break;
        // touch end
        case SDL_FINGERUP: {
            Uint32 now = SDL_GetTicks();
            av_log(NULL, AV_LOG_INFO, "release %dms touch time %dms (diff=%dms)\n", now, touch_time, now-touch_time);
            av_log(NULL, AV_LOG_INFO, "----------TOUCH END-----------------\n");
            if (last_touch_y < 0.33) {
                // centers picture
                toggle_full_screen(cur_stream);
                cur_stream->force_refresh = 1;
            }
            // tap middle area for play
            if ((last_touch_x > 0.25 && last_touch_x < 0.75) && (last_touch_y > 0.33 && last_touch_y < 0.66)) {
                toggle_pause(cur_stream);
                av_log(NULL, AV_LOG_INFO, "Toggle Play/Pause\n");
            }
            // seek
            if(last_touch_x < 0.25 && (last_touch_y > 0.33 && last_touch_y < 0.66)) {
                if(now - touch_time > 200) {
                    incr = -60.0;
                } else {
                    incr = seek_interval ? -seek_interval : -10.0;
                }
                av_log(NULL, AV_LOG_INFO, "Skip %f\n", incr);
                goto do_seek;
            }
            if(last_touch_x > 0.75 && (last_touch_y > 0.33 && last_touch_y < 0.66)) {
                if(now - touch_time > 200) {
                    incr = 60.0;
                } else {
                    incr = seek_interval ? seek_interval : 10.0;
                }
                av_log(NULL, AV_LOG_INFO, "Skip %f\n", incr);
                goto do_seek;
            }
...

thanks to this thread I maybe found a way to do somewhat proper (manual) rotation (with videofiler transpose) because now I use SDL_RenderCopyEx for rotation which only rotates the portrait image. No clue how to get autorotation support

edit:
desktop file is super easy, e.g. in ~/.local/share/applications

[Desktop Entry]
Exec=/home/defaultuser/prefix/bin/ffplay %u
Icon=icon-launcher-mediaplayer
Name=FFPlay
MimeType=image/*;video/*;
Terminal=false

dont think yt links work/only with youtube-dl or whatever the current name is

2 Likes

What is the reason for not supporting 64-bit?

By default, Sailfish OS offeres 5.1.6 without ffplay. Openrepos refers to a downgrade to 5.1.3.

32-bit builds are available with a long list up to 8.0.1

SFOS ffmpeg version does not include ffplay.

2 versions in Openrepos do but won’t install or I don’t know how to explicitely downgrade SFOS’ own version.

Tried to find suitable static builds for ffplay but since SFOS’ glibc is pretty old they don’t start.

Meh, we do have SailPipe and a few other streaming apps.

If you compile yourself you can install in e.g. ~/some_dir
without messing around with system packages (I also saw ffmpeg in openrepos has some weird dependency install in description which you probably wont/shouldnt do)

I can post later howto compile ffmpeg

1 Like

Compile ffmpeg/ffplay/ffprobe:
first download some packages with zypper or pkcon

git make

some of the following devel packages maybe not needed or some are missing, you’ll notice if configure shows some error(s)

opus-devel openssl-devel openjpeg-devel libvpx-devel libvorbis-devel libtheora-devel libpng-devel libogg-devel libmp3lame-devel libdrm-devel flac-devel SDL2-devel

download ffmpeg

cd /tmp
git clone --depth=1 https://github.com/FFmpeg/FFmpeg
cd FFmpeg

optional add patch for some touch controls
patch_add_some_more_touch_controls.targz (3.7 KB)

feel free to change if needed
apply patch to source

# patch copied to /tmp/FFmpeg
git apply patch_add_some_more_touch_controls.patch

configure (this is taken from default ffmpeg, you also can only use something like e.g. ./configure --prefix=/path/to/install --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-openssl)

./configure --prefix=/home/defaultuser/prefix --disable-debug --enable-pic --disable-doc --enable-muxers --enable-demuxers --enable-protocols --enable-network --enable-libfontconfig --enable-libfreetype --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-openssl --enable-encoder=',aac,ac3,alac,apng,ass,ayuv,bmp,ffv1,ffvhuff,flac,gif,huffyuv,ilbc,jpegls,jpeg2000,libaom,libaom_av1,libcodec2,libgsm,libilbc,libjxl,libmp3lame,libopenjpeg,libopus,libschroedinger,libtheora,libvorbis,libvpx_vp8,libvpx_vp9,libwebp,libwebp_anim,mjpeg,mpeg1video,mpeg2video,opus,pam,pbm,pcm_alaw,pcm_f32be,pcm_f32le,pcm_f64be,pcm_f64le,pcm_mulaw,pcm_s16be,pcm_s16be_planar,pcm_s16le,pcm_s16le_planar,pcm_s24be,pcm_s24le,pcm_s24le_planar,pcm_s32be,pcm_s32le,pcm_s32le_planar,pcm_s8,pcm_s8_planar,pcm_u16be,pcm_u16le,pcm_u24be,pcm_u24le,pcm_u32be,pcm_u32le,pcm_u8,pcx,pgm,pgmyuv,png,ppm,rawvideo,sgi,srt,ssa,sunrast,targa,text,tiff,v210,v308,v408,v410,vorbis,webvtt,xbm,xwd,y41p,yuv4,zlib,h264,mpeg4' --enable-decoder=',aac,ac3,alac,ansi,apng,ass,ayuv,bmp,dirac,exr,ffv1,ffvhuff,ffwavesynth,flac,gif,gsm,huffyuv,ilbc,jpeg2000,libaom,libaom_av1,libcodec2,libgsm,libilbc,libjxl,libopenjpeg,libopus,libschroedinger,libvorbis,libvpx_vp8,libvpx_vp9,mjpeg,mp1,mp1float,mp2,mp2float,mp3,mp3float,mpeg1video,mpeg2video,,opus,pam,pbm,pcm_alaw,pcm_bluray,pcm_dvd,pcm_f32be,pcm_f32le,pcm_f64be,pcm_f64le,pcm_mulaw,pcm_s16be,pcm_s16be_planar,pcm_s16le,pcm_s16le_planar,pcm_s24be,pcm_s24le,pcm_s24le_planar,pcm_s32be,pcm_s32le,pcm_s32le_planar,pcm_s8,pcm_s8_planar,pcm_u16be,pcm_u16le,pcm_u24be,pcm_u24le,pcm_u32be,pcm_u32le,pcm_u8,pcx,pgm,pgmyuv,pgssub,pgx,png,ppm,rawvideo,sgi,srt,ssa,sunrast,targa,text,theora,tiff,v210,v210x,v308,v408,v410,vorbis,vp3,vp5,vp6,vp6a,vp6f,vp8,vp9,webp,webvtt,xbm,xwd,y41p,yuv4,zlib,,aac_latm,h264,mpeg4'

If you get warning like this you can either ignore or try to download devel packages

WARNING: Disabled libaom_av1_encoder because not all dependencies are satisfied: libaom
WARNING: Disabled libcodec2_encoder because not all dependencies are satisfied: libcodec2
WARNING: Disabled libgsm_encoder because not all dependencies are satisfied: libgsm
WARNING: Disabled libilbc_encoder because not all dependencies are satisfied: libilbc
WARNING: Disabled libjxl_encoder because not all dependencies are satisfied: libjxl libjxl_threads
WARNING: Disabled libwebp_anim_encoder because not all dependencies are satisfied: libwebp
WARNING: Disabled libwebp_encoder because not all dependencies are satisfied: libwebp
WARNING: Disabled libcodec2_decoder because not all dependencies are satisfied: libcodec2
WARNING: Disabled libgsm_decoder because not all dependencies are satisfied: libgsm
WARNING: Disabled libilbc_decoder because not all dependencies are satisfied: libilbc
WARNING: Disabled libjxl_decoder because not all dependencies are satisfied: libjxl libjxl_threads
WARNING: Disabled libaom_av1_decoder because not all dependencies are satisfied: libaom

(there is no package for libx264, you can download source and compile yourself if you need h264 encoding support)

compile and install to directory specifed with --prefix= (I usually just use ~/prefix)
you can add path to ~/.profile)

make -j6
make install

this will take some time

.desktop file for usage with e.g. file manager (.local/share/applications/ffplay.desktop):

[Desktop Entry]
Exec=/home/defaultuser/prefix/bin/ffplay -v quiet -fs -vf "null" -vf "transpose=1" -vf "transpose=1,transpose=1" -vf "transpose=2" %u
Icon=icon-launcher-mediaplayer
Name=FFPlay
MimeType=image/*;video/*;
Terminal=false
Type=Application

not sure what the mimetype for music files is, probably music/* ?
with above command rotation is either via bottom swipe (some scaling is applied) or double tap (only downscales if e.g. portrait video is rotated to landscape but not vice versa, remove multigesture if you dont need this. Also keyboard support is removed/commented, undo if you need this [but uncomment mouse stuff])
Also touch controls stay the same (portrait), if you want to switch if landscape is used you have to add/change this yourself (shouldnt be complicated)

2 Likes

Thank you so much.

Don’t forget to install gcc btw.

I had to install a lot of *-devel packages before ./configure went through.

make took a long while. But in the end there’s no ffplay

probably just missing package(s), as ffplay should also be built

[defaultuser@Fairphone4 FFmpeg]$ ls
CONTRIBUTING.md                           RELEASE                                   fftools
COPYING.GPLv2                             compat                                    libavcodec
COPYING.GPLv3                             config.h                                  libavdevice
COPYING.LGPLv2.1                          config_components.h                       libavfilter
COPYING.LGPLv3                            configure                                 libavformat
CREDITS                                   doc                                       libavutil
Changelog                                 ffbuild                                   libswresample
FUNDING.json                              ffmpeg                                    libswscale
INSTALL.md                                ffmpeg_g                                  patch_add_some_more_touch_controls.patch
LICENSE.md                                ffplay                                    patch_add_some_more_touch_controls.targz
MAINTAINERS                               ffplay_g                                  presets
Makefile                                  ffprobe                                   tests
README.md                                 ffprobe_g                                 tools

you could try to run configure like this:

./configure --enable-ffplay

hopefully this shows the missing package(s) (? maybe some sdl stuff ?)
also check configure output it should show ffplay like this

...
Programs:
ffmpeg                  ffplay                  ffprobe
...

and
make ffplay (to only build ffplay but if nothing is built yet this will also take long time)

1 Like

Doh, I forgot to install the dependencies you mentioned, including sdl2.

ffplay works on this machine.

Now back to my idea of piping yt-dlp’s file output to ffplay. cat movie.ext | ffplay - works, so that’s a start.

BTW, any idea how to make ffplay respect screen dimensions, i.e. scale the video to screen size, possibly also in landscape mode, or detect rotation?

video can be scaled with scale filter (this allows something like e.g. -1:1080 or 1280:720), check online examples. (something like .e.g -vf “transpose=1,scale=w:h” https://trac.ffmpeg.org/wiki/Scaling
dont know how to add autorotation, thats why I added the manual rotation (if you applied patch dont use double tap, use filter change with bottom swipe)

It’s been a while but I thought I’d mention that I had begun doing packaging for Chum: Show home:poetaster / ffmpeg - SailfishOS Open Build Service

I wanted more codecs (obviously) and a couple of flags . I could include ffplay. I would not, however go much beyond 5 at the moment, since 7.x drops a bunch of ‘deprecated’ stuff that I’m still using.

1 Like

There’s a bunch of code from videoworks here harbour-clipper/qml/py/videox.py at 86707e48890a9aa256b2da5ded48af43efbadfd1 · poetaster/harbour-clipper · GitHub where L349 is the beginning of the scaling functions.

2 Likes

nasty keep screen on patch (uses mcetool -j enabled/disabled, keeps screen on until video is closed even if power button is pressed)
use with patch -p1 -i path_to_patch in fftools folder
patch_add_keep_screen_on.targz (829 Bytes)

3 Likes

This way its possible to get display orientation, so autorotation should be doable

case SDL_DISPLAYEVENT: {
    SDL_DisplayEvent devt;
    SDL_DisplayOrientation dori;
    dori = SDL_GetDisplayOrientation(devt.display);
    av_log(NULL,AV_LOG_INFO,"\nEVENT Display %u\n", devt.display);
    av_log(NULL, AV_LOG_INFO, "Display Orientiation %d\n", dori);
    break;
}


Display Orientiation 3
  37.04 A-V: -0.005 fd=  13 aq=   32KB vq=  356KB sq=    0B
EVENT Display 0
Display Orientiation 2
  38.05 A-V:  0.010 fd=  13 aq=   32KB vq=  299KB sq=    0B
EVENT Display 0
Display Orientiation 4
  38.96 A-V: -0.019 fd=  13 aq=   32KB vq=  227KB sq=    0B
EVENT Display 0
Display Orientiation 1
  39.94 A-V: -0.004 fd=  13 aq=   32KB vq=  209KB sq=    0B
EVENT Display 0
Display Orientiation 3


/*
* SDL_ORIENTATION_UNKNOWN,            < The display orientation can't be determined
* SDL_ORIENTATION_LANDSCAPE,          < The display is in landscape mode, with the right side up, relative to portrait mode
* SDL_ORIENTATION_LANDSCAPE_FLIPPED,  < The display is in landscape mode, with the left side up, relative to portrait mode
* SDL_ORIENTATION_PORTRAIT,           < The display is in portrait mode
* SDL_ORIENTATION_PORTRAIT_FLIPPED    < The display is in portrait mode, upside down
*/

also improve the current way of keeping screen on somewhat, add this to allow powering screen off if app window is in background (homescreen), add the lines between the comments in SDL_WINDOWEVENT

//case SDL_WINDOWEVENT: 
            /*
             * Window Event 13 is used if window is left
             */
            //av_log(NULL,AV_LOG_INFO,"Window Event %d\n", event.window.event);
            //switch (event.window.event) {
// ------------------ add this -----------------------
                SDL_WINDOWEVENT_FOCUS_LOST:
                    keep_screen_on_hack(0);
                    break;
                SDL_WINDOWEVENT_FOCUS_GAINED:
                    keep_screen_on_hack(1);
                    break;
// ---------------------------------------------
//                case SDL_WINDOWEVENT_SIZE_CHANGED:
4 Likes

patch that adds touch controls and autorotation (use with unchanged ffmpeg source)
patch_add_some_touch_control_and_rotation.targz (5.3 KB)

autorotation:
best start ffplay with video filters, else only image will be rotated

ffplay -fs -vf "null" -vf "transpose=1" -vf "transpose=1,transpose=1" -vf "transpose=2" 

also useful

-autoexit #exit when file end is reached
-vst # select video stream, .e.g. -vst v:2
-ast # select audio stream .e.g -ast a:1

e.g.

ffplay -fs -vst v:3 -ast a:1 -vf "null" -vf "transpose=1" -vf "transpose=1,transpose=1" -vf "transpose=2" https://derste247liveint.akamaized.net/hls/live/662735/daserste_int/master.m3u8

(Statusbar/Homescreen stays in portait mode not sure why)

if player crashes or doesnt quit properly screen blanking is still disabled, which then needs mcetool -j disabled command to enable screen blanking again

Controls

While playing:
External Keyboard
q, ESC              quit
f                   toggle full screen
p, SPC              pause
m                   toggle mute
9, 0                decrease and increase volume respectively
/, *                decrease and increase volume respectively
a                   cycle audio channel in the current program
v                   cycle video channel
t                   cycle subtitle channel in the current program
c                   cycle program
w                   cycle video filters or show modes
s                   activate frame-step mode
left/right          seek backward/forward 10 seconds or to custom interval if -seek_interval is set
down/up             seek backward/forward 1 minute
page down/page up   seek backward/forward 10 minutes


While playing:
Portrait
 _____________________
|                      |
|      Fullscreen/     |
|        Center        |
|     (same as -fs)    |
|     Longpress for    |
|     Audio Display    |
|______________________|
|     |          |     |
|     |          |     |
| RW  |   Play   | FF  |
| 10s |   Pause  | 10s |
|  /  |          |  /  |
| 60s |          | 60s |
|_____|__________|_____|
|                      |
|      Multitouch      |
|        rotate        |
|           /          |
|        Swipe         |
| change Video filter  |
|______________________|

While playing:
Landscape

 _________________________________________
|                                         |
|    Fullscreen / Center  (same as -fs)   |
|       Long press for Audio Display      |
|-----------------------------------------|
|    RW 10s |      Play       | FF 10s    |
|      /    |        /        |   /       |
|     60s   |     Pause       |  60s      |
|-----------------------------------------|
|          Multitouch:  Rotate            |
|       Swipe: Change Video Filter        |
|_________________________________________|

FFmpeg:
if you need ffmpeg with h264 encoding support, first download x264 and compile then add something like this to configure (adjust paths if needed, maybe not all flags needed. if you install x264 with make install path stuff and extra flags shouldnt be needed)

PKG_CONFIG_PATH="/home/defaultuser/Project/x264" ./configure ... --enable-gpl --enable-nonfree --enable-version3 --enable-libx264 ... --extra-cflags=-I/home/defaultuser/Project/x264 --extra-cxxflags=-I/home/defaultuser/Project/x264 --extra-ldflags=-L/home/defaultuser/Project/x264 --extra-libs=-lx264
1 Like