{"id":13766324,"url":"https://github.com/mofo7777/Stackoverflow","last_synced_at":"2025-05-10T21:33:21.299Z","repository":{"id":133473104,"uuid":"146646919","full_name":"mofo7777/Stackoverflow","owner":"mofo7777","description":"All source codes I've provided on stackoverflow as an answer, usually under tag ms-media-foundation. Mediafoundation, audio, video, 3D, decoder, encoder.","archived":false,"fork":false,"pushed_at":"2020-01-31T20:42:20.000Z","size":535,"stargazers_count":34,"open_issues_count":1,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-17T02:34:00.183Z","etag":null,"topics":["audio","capture-screen","decoder","evr","mediafoundation","source-reader","transcode","video"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mofo7777.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-08-29T19:14:58.000Z","updated_at":"2024-10-23T01:17:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"fcffd488-b50d-4b9c-8a59-54f087cf6415","html_url":"https://github.com/mofo7777/Stackoverflow","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mofo7777%2FStackoverflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mofo7777%2FStackoverflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mofo7777%2FStackoverflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mofo7777%2FStackoverflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mofo7777","download_url":"https://codeload.github.com/mofo7777/Stackoverflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253486336,"owners_count":21916136,"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":["audio","capture-screen","decoder","evr","mediafoundation","source-reader","transcode","video"],"created_at":"2024-08-03T16:00:53.912Z","updated_at":"2025-05-10T21:33:20.807Z","avatar_url":"https://github.com/mofo7777.png","language":"C++","readme":"# Stackoverflow\nAll source codes I've provided on stackoverflow as an answer, usually under tags ms-media-foundation. Most of the source codes here are quick fixes to source code from people asking for help. So be careful, it's not necessarily the most appropriate way to do it. That just answers the question. It' s up to the user to improve the code.\n\nIn the programs below, some values are harcoded, like video file path for example :\n\n#define VIDEO_FILE L\"C:\\\\\\\\Users\\\\\\\\Public\\\\\\\\Videos\\\\\\\\Sample Videos\\\\\\\\Wildlife.wmv\"\n\nDont't forget to change them, if you use a different video file, in a different path.\n\n\n## AudioSourceReaderSeek\nThis program uses SourceReader to check seek position with audio file.\n\nstackoverflow question : https://stackoverflow.com/questions/49739170/imfsourcereader-m4a-audio-accurate-frame-seek\n\n## CustomVideoMixer\nThis program shows the basic essentials for implementing a custom video mixer, to be used by a media session.\n\nYou must register the CustomVideoMixer.dll with this command, and with the administrator rights : regsrv32 CustomVideoMixer.dll.\n\nBe careful, the width and height of both videos are hardcoded (320x240). See VIDEO_WIDTH_1 and VIDEO_HEIGHT_1, change it if necessary.\n\nIn this example, I use two identical mp4 files, big_buck_bunny_240p_5mb.mp4 and a copy of itself. the two videos use NV12 video format as input. therefore, there is no real alpha mix, but both videos can be displayed next to each other, as the picture below.\n\nstackoverflow question : https://stackoverflow.com/questions/42946608/media-foundation-custom-mixer-mft-getting-error-mf-e-cannot-create-sink\n\n![Custom Video Mixer](./Media/CustomVideoMixer.jpg)\n\n## EncodeWithSourceReaderSinkWriter\n\nEncode a video file using SourceReader and SinkWriter manually.\n\nstackoverflow question : https://stackoverflow.com/questions/55054531/media-foundation-video-re-encoding-producing-audio-stream-sync-offset\n\n## FrameRateConverterDSP\n\nThis program shows how to use the Frame Rate Converter DSP (CLSID_CFrameRateConvertDmo), using a Source Reader. You can change the frame rate of a video stream. For example, if the video has 30 fps, you can get 60 fps.\n\nstackoverflow question : https://stackoverflow.com/questions/8412343/how-to-use-frame-rate-convertor-dmo-in-mf-app\n\n## IMFSinkWriterCallback\n\nThis program shows how to use an IMFSinkWriterCallback and event to wait for the Finalize method on the Sink Writer. The program simply create a wmv video file with blue frames, using the Sink Writer.\n\nstackoverflow question : https://stackoverflow.com/questions/34189440/imfsinkwritercallback-never-happens\n\n![IMFSinkWriterCallback](./Media/IMFSinkWriterCallback.jpg)\n\n## MFVideoCaptureEVR\n\nThis program shows how to setup EVR (enhanced video renderer), and how to provide video capture samples to it, using a Source Reader.\nSame as MFVideoEVR, but with video capture card source.\n\nstackoverflow question : https://stackoverflow.com/questions/59616228/webcam-source-to-evr-sink\n\n## MFVideoEVR\n\nThis program shows how to setup EVR (enhanced video renderer), and how to provide video samples to it, using a Source Reader.\nSame as MFVideoCaptureEVR, but with video file source.\n\nstackoverflow question : https://stackoverflow.com/questions/32739558/media-foundation-evr-no-video-displaying\n\n## MFMultiVideo\n\nA program to see if there are memory leaks using 1 to 16 MediaSession.\n\nstackoverflow question : https://stackoverflow.com/questions/58912803/media-foundation-multiple-videos-playback-results-in-memory-leak-crash-after-u\n\n![MFMultiVideo](./Media/MFMultiVideo.jpg)\n\n## MinimalSinkRenderer\n\nThis program shows the basic essentials for implementing a custom sink renderer, to be used by a Media Session. The stream sink format is MFVideoFormat_RGB32.\n\nYou must register the MinimalSinkRenderer.dll with this command, and with the administrator rights : regsrv32 MinimalSinkRenderer.dll.\n\nstackoverflow question : https://stackoverflow.com/questions/52198300/how-to-have-custom-video-media-stream-sink-request-rgb32-frames-in-media-foundat\n\n## ScreenCaptureEncode\n\nThis program takes screenshots using Directx9, and create a mp4 video file with Mediafoundation API. In this example, the video duration is 5 seconds, see VIDEO_FRAME_COUNT to change it.\n\nstackoverflow question : https://stackoverflow.com/questions/33753912/directx-screen-capture-and-output-as-video\n\n![Screen Capture Encode](./Media/ScreenCaptureEncode.jpg)\n\n## TranscodeMp4ToMp4\nThis program transcode a mp4 video file into a new mp4 file, using mp4 Sink Writer and a Media Session with topology. There is no real encoding process, because output file has the same format as input file.\nThe concept was to show how to setup IMFTopologyNode for both audio and video.\n\nstackoverflow question : https://stackoverflow.com/questions/52025546/configuring-the-mpeg4mediasink\n\n## VideoStabilizationMFT\n\nUsing the Video Stabilization MFT with Source Reader and Sink Writer.\n\nstackoverflow question : https://stackoverflow.com/questions/59471641/trying-to-use-a-mft-in-media-foundation-encoding\n\n## WasapiCapture\n\nA program to capture sound with Wasapi, and record the captured audio in a wav file. Handle PCM format and Extensible Format.\n\nstackoverflow question : https://stackoverflow.com/questions/59483071/trying-to-create-a-wav-file-with-capturing-a-stream-from-win32-wasapi-c\n","funding_links":[],"categories":["Learning","HarmonyOS"],"sub_categories":["Windows Manager"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmofo7777%2FStackoverflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmofo7777%2FStackoverflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmofo7777%2FStackoverflow/lists"}