Personal Profile

FFmpeg

Simple Video Player for Raspberry Pi

Simple Video Player on Raspberry Pi

Simple Video Player on Raspberry Pi

Did you know that you can easily code an audio video player with the latest version 0.8.4 of GLSL Hacker ? This is possible thanks to the FFmpeg plugin that can now read audio and video frames and synchronize them. The FFmpeg plugin is available with all versions of GLSL Hacker: Windows, Linux, OS X and, of course, Raspberry Pi.

I prepared an archive file for Raspberry Pi with a ready-to-use video player named vplay. vplay is simply GLSL Hacker that has been renamed in vplay. The full source code in Lua is included in the download (in the audio_video/ folder):


In a word, vplay is a video player based on GLSL Hacker that uses FFmpeg to decode audio-video files, OpenMAX to play the decoded audio buffer and OpenGL ES to display the decoded video frames.

Playing a video with vplay is simple. Open a terminal in vplay folder and pass the absolute path to the video file:

$ vplay /video=\"video_file_absolute_path\"

A concrete example:

$ vplay /video=\"/home/pi/mykoolvideo.mp4\"

You can also force the resolution and fullscreen mode like this:

$ vplay /width=1920 /height=1080 /fullscreen /video=\"/home/pi/mykoolvideo.mp4\"

/width, /height and /fullscreen are command line parameters of GLSL Hacker and are not specific to VPlay demo.

By default, the video is played on a quad with an orthographic camera (a 2D camera). But vplay can be easily tweaked to play the video on another kind of support like a 3D box. After all, in a FRAME script, a video is just a simple 2D texture that can be mapped (like any other texture) on any 3D object. I added a command line parameter /usebox (you can add other params by parsing the command line in Lua, look for the gh_utils.get_command_line() function in the source code of the demo, line 167) to play the video using a 3D cube and a perspective camera:

$ vplay /video=\"/home/pi/mykoolvideo.mp4\" /usebox

And the result:

Simple Video Player on Raspberry Pi

Simple Video Player on Raspberry Pi

The video played on a 3D cube

And since the video is a simple 2D texture, you can play with the uv tiling factor in the pixel shader (line 31 and 388 of the xml file):

Simple Video Player on Raspberry Pi

Simple Video Player on Raspberry Pi

The video played on a quad with a texture tiling factor of 2.0

If you are interested about how vplay works, here are some code snippets that show how to use the audio-video functions of the FFmpeg plugin (Lua or Python) in GLSL Hacker:

INIT script:

-- Opening of the video file.
av1 = gh_av.decoder_open(av_filename, loop_mode)

-- video resolution. 
video_width, video_height = gh_av.video_get_resolution(av1)

-- Creation of a 2D texture with correct resolution (width x height). 
video_tex = gh_av.video_init_texture(av1, PF_U8_RGB)

-- Starting of the audio-video processing thread.
gh_av.start_audio_video_processing(av1, update_video, update_audio)

FRAME script:

-- Binding of the video texture and updating from the current video frame.
gh_texture.bind(video_tex, 0)
gh_av.video_update_texture(av1, video_tex)

-- Now the texture can be mapped on any mesh.

TERMINATE script:

-- Stopping of the audio-video processing thread.
gh_av.stop_audio_video_processing(av1)

-- Closing of the video file.
gh_av.decoder_close(av1)

The full source code is in the archive, so do not hesitate to hack it!



Popular Pages
  • CV Resume Ahmadrezar Razian-سید احمدرضا رضیان-رزومه Resume Full name Sayed Ahmadreza Razian Nationality Iran Age 36 (Sep 1982) Website ahmadrezarazian.ir  Email ...
  • CV Resume Ahmadrezar Razian-سید احمدرضا رضیان-رزومه معرفی نام و نام خانوادگی سید احمدرضا رضیان محل اقامت ایران - اصفهان سن 33 (متولد 1361) پست الکترونیکی ahmadrezarazian@gmail.com درجات علمی...
  • Nokte feature image Nokte – نکته نرم افزار کاربردی نکته نسخه 1.0.8 (رایگان) نرم افزار نکته جهت یادداشت برداری سریع در میزکار ویندوز با قابلیت ذخیره سازی خودکار با پنل ساده و کم ح...
  • Tianchi-The Purchase and Redemption Forecasts-Big Data-Featured Tianchi-The Purchase and Redemption Forecasts 2015 Special Prize – Tianchi Golden Competition (2015)  “The Purchase and Redemption Forecasts” in Big data (Alibaba Group) Among 4868 teams. Introd...
  • Brick and Mortar Store Recommendation with Budget Constraints-Featured Tianchi-Brick and Mortar Store Recommendation with Budget Constraints Ranked 5th – Tianchi Competition (2016) “Brick and Mortar Store Recommendation with Budget Constraints” (IJCAI Socinf 2016-New York,USA)(Alibaba Group...
  • Drowning Detection by Image Processing-Featured Drowning Detection by Image Processing In this research, I design an algorithm for image processing of a swimmer in pool. This algorithm diagnostics the swimmer status. Every time graph sho...
  • Shangul Mangul Habeangur,3d Game,AI,Ahmadreza razian,boz,boz boze ghandi,شنگول منگول حبه انگور,بازی آموزشی کودکان,آموزش شهروندی,آموزش ترافیک,آموزش بازیافت Shangul Mangul HabeAngur Shangul Mangul HabeAngur (City of Goats) is a game for child (4-8 years). they learn how be useful in the city and respect to people. Persian n...
  • 1st National Conference on Computer Games-Challenges and Opportunities 2016-Featured 1st National Conference on Computer Games-Challenges and Opportunities 2016 According to the public relations and information center of the presidency vice presidency for science and technology affairs, the University of Isfah...
  • Design an algorithm to improve edges and image enhancement for under-sea color images in Persian Gulf-Featured 3rd International Conference on The Persian Gulf Oceanography 2016 Persian Gulf and Hormuz strait is one of important world geographical areas because of large oil mines and oil transportation,so it has strategic and...
  • 2nd Symposium on psychological disorders in children and adolescents 2016 2nd Symposium on psychological disorders in children and adolescents 2016 2nd Symposium on psychological disorders in children and adolescents 2016 Faculty of Nursing and Midwifery – University of Isfahan – 2 Aug 2016 - Ass...
  • MyCity-Featured My City This game is a city simulation in 3d view. Gamer must progress the city and create building for people. This game is simular the Simcity.
  • GPU vs CPU Featured CUDA Optimizing raytracing algorithm using CUDA Abstract Now, there are many codes to generate images using raytracing algorithm, which can run on CPU or GPU in single or multi-thread methods. In t...
Popular posts
Interested
About me

My name is Sayed Ahmadreza Razian and I am a graduate of the master degree in Artificial intelligence .
Click here to CV Resume page

Related topics such as image processing, machine vision, virtual reality, machine learning, data mining, and monitoring systems are my research interests, and I intend to pursue a PhD in one of these fields.

جهت نمایش صفحه معرفی و رزومه کلیک کنید

My Scientific expertise
  • Image processing
  • Machine vision
  • Machine learning
  • Pattern recognition
  • Data mining - Big Data
  • CUDA Programming
  • Game and Virtual reality

Download Nokte as Free


Coming Soon....

Greatest hits

Imagination is more important than knowledge.

Albert Einstein

One day you will wake up and there won’t be any more time to do the things you’ve always wanted. Do it now.

Paulo Coelho

Anyone who has never made a mistake has never tried anything new.

Albert Einstein

You are what you believe yourself to be.

Paulo Coelho

Waiting hurts. Forgetting hurts. But not knowing which decision to take can sometimes be the most painful.

Paulo Coelho

It’s the possibility of having a dream come true that makes life interesting.

Paulo Coelho

Gravitation is not responsible for people falling in love.

Albert Einstein

The fear of death is the most unjustified of all fears, for there’s no risk of accident for someone who’s dead.

Albert Einstein


Site by images
Recent News Posts