{"id":23662748,"url":"https://github.com/rambod-rahmani/ffmpeg-video-player","last_synced_at":"2025-04-05T01:06:34.693Z","repository":{"id":37735790,"uuid":"158871371","full_name":"rambod-rahmani/ffmpeg-video-player","owner":"rambod-rahmani","description":"An FFmpeg and SDL Tutorial.","archived":false,"fork":false,"pushed_at":"2023-11-08T20:41:31.000Z","size":48347,"stargazers_count":458,"open_issues_count":2,"forks_count":105,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-29T00:06:57.821Z","etag":null,"topics":["arch-linux","audio","clion","cmake","cmake-modules","cmakelists","codec","decoding","encoding","ffmpeg","learning","learning-by-doing","libav","linux","multimedia","multimedia-files","sdl","sdl-tutorial","sdl2","video-player"],"latest_commit_sha":null,"homepage":"http://rambodrahmani.it","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rambod-rahmani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-23T19:34:26.000Z","updated_at":"2025-03-28T16:53:29.000Z","dependencies_parsed_at":"2024-12-29T07:15:30.503Z","dependency_job_id":null,"html_url":"https://github.com/rambod-rahmani/ffmpeg-video-player","commit_stats":{"total_commits":41,"total_committers":5,"mean_commits":8.2,"dds":"0.14634146341463417","last_synced_commit":"5cf20004b5b0b094d0c8d9486c147b44532bfd6a"},"previous_names":["rambod-rahmani/ffmpeg-video-player","rambodrahmani/ffmpeg-video-player"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rambod-rahmani%2Fffmpeg-video-player","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rambod-rahmani%2Fffmpeg-video-player/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rambod-rahmani%2Fffmpeg-video-player/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rambod-rahmani%2Fffmpeg-video-player/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rambod-rahmani","download_url":"https://codeload.github.com/rambod-rahmani/ffmpeg-video-player/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247271528,"owners_count":20911587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arch-linux","audio","clion","cmake","cmake-modules","cmakelists","codec","decoding","encoding","ffmpeg","learning","learning-by-doing","libav","linux","multimedia","multimedia-files","sdl","sdl-tutorial","sdl2","video-player"],"created_at":"2024-12-29T05:05:41.536Z","updated_at":"2025-04-05T01:06:34.673Z","avatar_url":"https://github.com/rambod-rahmani.png","language":"C","funding_links":[],"categories":["HarmonyOS"],"sub_categories":["Windows Manager"],"readme":"# FFmpeg Video Player\n\n\u003c!-- PROJECT SHIELDS --\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"#\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/languages/top/rambodrahmani/ffmpeg-video-player.svg?logo=github\" alt=\"Github Top Languages\"\u003e\n    \u003ca href=\"#\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/downloads/rambodrahmani/ffmpeg-video-player/total.svg?logo=github\" alt=\"Github Donwloads\"\u003e\n    \u003ca href=\"https://github.com/rambodrahmani/ffmpeg-video-player/commits/master\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/last-commit/rambodrahmani/ffmpeg-video-player.svg?logo=github\" alt=\"GitHub last commit\"\u003e\n    \u003ca href=\"https://github.com/rambodrahmani/ffmpeg-video-player/issues\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/issues-raw/rambodrahmani/ffmpeg-video-player.svg?logo=github\" alt=\"GitHub issues\"\u003e\n    \u003ca href=\"https://github.com/rambodrahmani/ffmpeg-video-player/pulls\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/issues-pr-raw/rambodrahmani/ffmpeg-video-player.svg?logo=github\" alt=\"GitHub pull requests\"\u003e\n    \u003ca href=\"https://gitter.im/ffmpeg-video-player/devops\"\u003e\n    \u003cimg src=\"https://img.shields.io/gitter/room/rambodrahmani/ffmpeg-video-player.svg?logo=gitter\" alt=\"Chat on Gitter\"\u003e\n\u003c/p\u003e\n\n![FFmpeg Video Player](/screenshots/2019-10-25-224809_1366x768_scrot.png)\n\n# Setup\n\nThe provided Docker file can be used to setup a container with everything that is needed.\n\n```bash\ndocker build -t ffmpeg-video-player -f Dockerfile .\n```\n\nMake sure to update the `-v /home/rr/DevOps/:/home/ffmpeg/DevOps` parameter and run the container for the first time using:\n\n```bash\ndocker run --gpus 'all,\"capabilities=graphics,utility,display,video,compute\"' --net host --privileged --name ffmpeg-video-player -itu ffmpeg -e NVIDIA_VISIBLE_DEVICES=all -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:rw -v /home/rr/DevOps:/home/ffmpeg/DevOps ffmpeg-video-player /bin/bash\n```\n\n# Compilation\n\nEach tutorial can be compiled manually using\n```bash\n$ cd DevOps/ffmpeg-video-player/tutorial01\n$ gcc -o tutorial01 tutorial01.c -lavutil -lavformat -lavcodec -lswscale -lz -lm\n$ ./tutorial01\n```\n\nYou can also compile all the source files in this repo using the provided CMake files using\n```bash\n$ cd DevOps/ffmpeg-video-player/\n$ cmake CMakeLists.txt -B build\n$ cd build/\n$ make\n```\nAs an example:\n```bash\nffmpeg@rr-workstation:~/DevOps/ffmpeg-video-player$ cmake CMakeLists.txt -B build\n-- The C compiler identification is GNU 11.4.0\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working C compiler: /usr/bin/cc - skipped\n-- Detecting C compile features\n-- Detecting C compile features - done\n-- Found PkgConfig: /usr/bin/pkg-config (found version \"0.29.2\") \n-- Checking for one of the modules 'sdl'\n-- Checking for one of the modules 'sdl2'\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/ffmpeg/DevOps/ffmpeg-video-player/build\nffmpeg@rr-workstation:~/DevOps/ffmpeg-video-player$ cd build/\nffmpeg@rr-workstation:~/DevOps/ffmpeg-video-player/build$ make\n[  5%] Built target tutorial01-deprecated\n[ 11%] Built target tutorial01\n[ 16%] Built target tutorial02-deprecated\n[ 22%] Built target tutorial02\n[ 27%] Built target create_window\n[ 33%] Built target moving_rectangle\n[ 38%] Built target render_present\n[ 44%] Built target tutorial03-deprecated\n[ 50%] Built target tutorial03-resampled-deprecated\n[ 55%] Built target tutorial03-resampled\n[ 61%] Built target tutorial04-deprecated\n[ 66%] Built target tutorial04-resampled-deprecated\n[ 72%] Built target tutorial04-resampled\n[ 77%] Built target tutorial05\n[ 83%] Built target tutorial06\n[ 88%] Built target tutorial07\n[ 94%] Built target player-sdl\n[100%] Built target player-sdl2\n```\n\nThen run the desired tutorial:\n```bash\nffmpeg@rr-workstation:~/DevOps/ffmpeg-video-player/build$ ./tutorial01/tutorial01\nInvalid arguments.\n\nUsage: ./tutorial01 \u003cfilename\u003e \u003cmax-frames-to-decode\u003e\n\ne.g: ./tutorial01/tutorial01 ../Iron_Man-Trailer_HD.mp4 200\n```\n\n# Major opcode of failed request:  151 (GLX)\nIn case you end up having this error when trying to execute one of the\ntutorials, then refer to the `Tearing` section below.\n\n# Major opcode of failed request:  152 (GLX)\nIn case you end up having this error when trying to execute one of the\ntutorials, then you are probabily have nvidia drivers installed on your system\nwith no NVIDIA Hardware. To check if this is the case, just run\n```\npacman -Qs nvidia\n```\nif you find, among the other packages, the ```nvidia-340xx-utils``` and no\nNVIDIA hardware in your machine, then you have to remove it\n```\nsudo pacman -R nvidia-340xx-utils\n```\nand reboot.\n\n# Tearing\nStarting from tutorial03 and noticed some screen tearing happening when playing\nthe media. To be precise vertical tearing.\n\nAt the time of this writing I am using Arch Linux and after making sure the\nproblem was not my code and some troubleshooting I managed to fix the tearing.\n\nFirst of all use the following command to find out your graphic card:\n```\n[rambodrahmani@rr-workstation ~]$ lspci\n00:00.0 Host bridge: Intel Corporation Intel Kaby Lake Host Bridge (rev 05)\n00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16) (rev 05)\n00:02.0 VGA compatible controller: Intel Corporation HD Graphics 630 (rev 04)\n00:14.0 USB controller: Intel Corporation 200 Series PCH USB 3.0 xHCI Controller\n00:16.0 Communication controller: Intel Corporation 200 Series PCH CSME HECI #1\n00:17.0 SATA controller: Intel Corporation 200 Series PCH SATA controller [AHCI mode]\n00:1b.0 PCI bridge: Intel Corporation 200 Series PCH PCI Express Root Port #17 (rev f0)\n00:1c.0 PCI bridge: Intel Corporation 200 Series PCH PCI Express Root Port #1 (rev f0)\n00:1c.2 PCI bridge: Intel Corporation 200 Series PCH PCI Express Root Port #3 (rev f0)\n00:1c.6 PCI bridge: Intel Corporation 200 Series PCH PCI Express Root Port #7 (rev f0)\n00:1d.0 PCI bridge: Intel Corporation 200 Series PCH PCI Express Root Port #9 (rev f0)\n00:1f.0 ISA bridge: Intel Corporation 200 Series PCH LPC Controller (Z270)\n00:1f.2 Memory controller: Intel Corporation 200 Series PCH PMC\n00:1f.3 Audio device: Intel Corporation 200 Series PCH HD Audio\n00:1f.4 SMBus: Intel Corporation 200 Series PCH SMBus Controller\n00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (2) I219-LM\n01:00.0 PCI bridge: PLX Technology, Inc. PEX 8747 48-Lane, 5-Port PCI Express Gen 3 (8.0 GT/s) Switch (rev ca)\n02:08.0 PCI bridge: PLX Technology, Inc. PEX 8747 48-Lane, 5-Port PCI Express Gen 3 (8.0 GT/s) Switch (rev ca)\n02:10.0 PCI bridge: PLX Technology, Inc. PEX 8747 48-Lane, 5-Port PCI Express Gen 3 (8.0 GT/s) Switch (rev ca)\n06:00.0 USB controller: ASMedia Technology Inc. Device 2142\n07:00.0 Ethernet controller: Intel Corporation I210 Gigabit Network Connection (rev 03)\n08:00.0 USB controller: ASMedia Technology Inc. Device 2142\n```\nAs you can see I am using the \n```\nIntel Corporation HD Graphics 630 (rev 04)\n```\nOften it is not recommended, however for the DDX driver (which provides 2D\nacceleration in Xorg), install the xf86-video-intel package.\n\nThe Intel kernel module should load fine automatically on system boot. \n\nThe SNA acceleration method causes tearing on some machines. To fix this, enable\nthe \"TearFree\" option in the driver by adding the following line to your\nconfiguration file:\n```\n/etc/X11/xorg.conf.d/20-intel.conf\n```\n```\nSection \"Device\"\n Identifier  \"Intel Graphics\"\n Driver      \"intel\"\n Option      \"TearFree\" \"true\"\nEndSection\n```\nand reboot.\n\n# An FFmpeg and SDL Tutorial\n\nThis repo contains an updated and reviewed version of the original\n[\"An ffmpeg and SDL Tutorial or How to Write a Video Player in Less Than 1000 Lines\"](http://dranger.com/ffmpeg/).\n\nFFmpeg is a wonderful library for creating video applications or even general\npurpose utilities. FFmpeg takes care of all the hard work of video processing by\ndoing all the decoding, encoding, muxing and demuxing for you. This can make\nmedia applications much simpler to write. It's simple, written in C, fast, and\ncan decode almost any codec you'll find in use today, as well as encode several\nother formats.\n\nFFmpeg is a free software project, the product of which is a vast software suite\nof libraries and programs for handling video, audio, and other multimedia files\nand streams. At its core is the FFmpeg program itself, designed for\ncommand-line-based processing of video and audio files, widely used for format\ntranscoding, basic editing (trimming and concatenation), video scaling, video\npost-production effects, and standards compliance (SMPTE, ITU). FFmpeg includes\nlibavcodec, an audio/video codec library used by many commercial and free\nsoftware products, libavformat (Lavf), an audio/video container mux and demux\nlibrary, and the core ffmpeg command line program for transcoding multimedia\nfiles. FFmpeg is published under the GNU Lesser General Public License 2.1+ or\nGNU General Public License 2+ (depending on which options are enabled).\nThe name of the project is inspired by the MPEG video standards group, together\nwith \"FF\" for \"fast forward\". The logo uses a zigzag pattern that shows how MPEG\nvideo codecs handle entropy encoding.\nFFmpeg is part of the workflow of hundreds of other software projects, and its\nlibraries are a core part of software media players such as VLC, and has been\nincluded in core processing for YouTube and the iTunes inventory of files.\nCodecs for the encoding and/or decoding of most of all known audio and video\nfile formats is included, making it highly useful for the transcoding of common\nand uncommon media files into a single common format.\n\nThe only problem is that documentation is basically nonexistent. There is a\nsingle tutorial that shows the basics of FFmpeg and auto-generated doxygen\ndocuments. That's it. So, when I decided to learn about FFmpeg, and in the\nprocess about how digital video and audio applications work, I decided to\ndocument the process and present it as a tutorial.\n\nThere is a sample program that comes with ffmpeg called ffplay. It is a simple C\nprogram that implements a complete video player using FFmpeg. This tutorial will\nbegin with an updated version of the original tutorial, written by Martin Böhme \n(I have stolen liberally borrowed from that work), and work from there to\ndeveloping a working video player, based on Fabrice Bellard's ffplay.c. In each\ntutorial, I'll introduce a new idea (or two) and explain how we implement it.\nEach tutorial will have a C file so you can download it, compile it, and follow\nalong at home. The source files will show you how the real program works, how we\nmove all the pieces around, as well as showing you the technical details that\nare unimportant to the tutorial. By the time we are finished, we will have a\nworking video player written in less than 1000 lines of code!\n\nIn making the player, we will be using SDL to output the audio and video of the\nmedia file. SDL is an excellent cross-platform multimedia library that's used in\nMPEG playback software, emulators, and many video games. You will need to\ndownload and install the SDL development libraries for your system in order to\ncompile the programs in this tutorial.\n\nThis tutorial is meant for people with a decent programming background. At the\nvery least you should know C and have some idea about concepts like queues,\nmutexes, and so on. You should know some basics about multimedia; things like\nwaveforms and such, but you don't need to know a lot, as I explain a lot of\nthose concepts in this tutorial.\n\n##### Originally seen at: http://dranger.com/ffmpeg/\n##### This repo contains both the original (deprecated) and updated implementations for each tutorial.\n##### The source codes originally written by Martin Bohme are also provided for ease of access.\n\n--\n\nRambod Rahmani \u003c\u003crambodrahmani@autistici.org\u003e\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frambod-rahmani%2Fffmpeg-video-player","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frambod-rahmani%2Fffmpeg-video-player","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frambod-rahmani%2Fffmpeg-video-player/lists"}