AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Projekte TBitmaps2Video
Thema durchsuchen
Ansicht
Themen-Optionen

TBitmaps2Video

Ein Thema von Renate Schaaf · begonnen am 26. Jul 2020 · letzter Beitrag vom 21. Mär 2021
 
Renate Schaaf

Registriert seit: 25. Jun 2020
Ort: Lippe
114 Beiträge
 
Delphi 11 Alexandria
 
#1

TBitmaps2Video

  Alt 26. Jul 2020, 18:18
Ich verfolge dieses Forum seit einiger Zeit passiv mit viel Vergnügen und habe nützliche Hinweise gefunden.
Jetzt möchte ich gern mein neuestes Projekt zur Diskussion stellen, eine Klasse, die es ermöglicht sequentiell Bitmaps zu einem Video zusammenzustellen. Ich kann mir vorstellen, dass die/der eine oder andere sowas gebrauchen kann. Die Klasse baut auf den Libav(ffmpeg)-dlls auf, aber mein Ziel war es, ein interface mit leicht und intuitiv verständlichen Prozeduren und Einstellungen herzustellen, ohne dass man sich um die etwas obskuren und technischen Prozeduren in den dlls kümmern muss.

Jetzt zu finden auf GitHub:
https://github.com/rmesch/Bitmaps2Video

Update:
Source code: Bitmaps2Video_3.zip
Es werden jetzt 7 Codecs unterstützt, m.E. die wichtigsten.
Das geänderte interface ist jetzt:

Delphi-Quellcode:
///<summary>Sequentially encode bitmaps to a compressed video. Uses Libav Dlls. </summary>
  TBitmapEncoder = class
.....
    /// <param name="filename"> Output filename. Extension picks the container format (.mp4 .avi .mkv ..)
    /// </param>
    /// <param name="Width"> Video size in pixels (multiples of 2)</param>
    /// <param name="Height"> Video size in pixels (multiples of 2)</param>
    /// <param name="FrameRate"> Frames per second (can be slightly off in the resulting file)</param>
    /// <param name="Quality"> Encoding quality, scale from 0 to 100. 0 gives marginally acceptable quality </param>
    /// <param name="CodecId"> (TAVCodecID see UFormats.pas) Identifier of the codec to use. AV_CODEC_ID_NONE picks the default codec for the file extension. </param>
    /// <param name="VideoScaling">Resample algo used if video size differs from bitmap size </param>
    constructor Create(const filename: string; Width, Height: integer;
      FrameRate: integer; Quality: byte; CodecId: TAVCodecId = AV_CODEC_ID_NONE;
      VideoScaling: TVideoScaling = vsFastBilinear);

    /// <summary> Turn a Bitmap into a movie frame </summary>
    /// <param name="bm"> Bitmap(TBitmap) to be fed to the video. Will be converted to pf32bit if not already </param>
    procedure AddFrame(const bm: TBitmap);

    /// <summary> Hold the last frame </summary>
    /// <param name="EffectTime"> Displaytime(integer) in ms </param>
    procedure Freeze(EffectTime: integer);

    /// <summary> Add a picture which is displayed for a certain time </summary>
    /// <param name="bm"> Bitmap(TBitmap) of the picture to be displayed </param>
    /// <param name="ShowTime"> Time(integer) in ms for the display </param>
    procedure AddStillImage(const bm: TBitmap; ShowTime: integer);

    /// <summary> Make a smooth transition from SourceR to TargetR within EffectTime.</summary>
    /// <param name="bm"> The Bitmap(TBitmap) to be animated </param>
    /// <param name="SourceR"> Beginning rectangle(TRectF) within rect(0,0,bm.width,bm.height) </param>
    /// <param name="TargetR"> End rectangle(TRectF) within rect(0,0,bm.width,bm.height) </param>
    /// <param name="EffectTime"> Duration(integer) of the animation in ms </param>
    /// <param name="ZoomOption"> Quality of the zoom (zoAAx2, zoAAx4, zoAAx6, zoResample). </param>
    /// <param name="SpeedEnvelope"> Modifies the speed during EffectTime. (zeFastSlow, zeSlowFast, zeSlowSlow, zeLinear) </param>
    procedure ZoomPan(const bm: TBitmap; SourceR, TargetR: TRectF;
      EffectTime: integer; ZoomOption: TZoomOption;
      SpeedEnvelope: TZoomSpeedEnvelope = zeLinear);

    /// <summary> Close the file and make the output file usable. </summary>
    function CloseFile: Boolean;
Audio wird jetzt rudimentär unterstützt:
Delphi-Quellcode:
  /// <summary> Combine the video stream from VideoFile with the audio from Audiofile. The streams will just be copied, not encoded.
  ///Audio is clipped to video length. Raises exception if the format of the audio file is not supported.</summary>
  /// <param name="VideoFile"> (string) File which contains a video stream. Any audio stream present will be ignored. </param>
  /// <param name="AudioFile"> (string) Genuine audio file (.wav .mp3 .aac) the audio of which shall be added to the video in VideoFile. </param>
  /// <param name="OutputFile"> (string) Name of the file containing the newly combined video and audio. </param>
procedure MuxStreams2(const VideoFile, AudioFile: string;
  const OutputFile: string);

Das Projekt benötigt die ffmpeg-dlls und die zugehörigen Pascal-Headers. Beides kann man hier bekommen:
http://www.delphiffmpeg.com/downloads/

Näheres im Readme, und in meiner Antwort unten.

Ich bin sehr an Verbesserungsvorschlägen interessiert, vor allem, wie man die Schreibgeschwindigkeit erhöhen kann, und wie man eventuell die vorhandenen Libav-Filter dafür benutzen kann, und auch an Vorschlägen, was man noch einbauen sollte.

Renate
Angehängte Dateien
Dateityp: zip Bitmaps2Video_3.zip (460,3 KB, 44x aufgerufen)
Renate

Geändert von Renate Schaaf (26. Aug 2020 um 13:26 Uhr) Grund: Update
  Mit Zitat antworten Zitat
 

 

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:33 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz