Recent

Author Topic: NON(!)-EXE FFPlay4Laz  (Read 64916 times)

furious programming

  • Sr. Member
  • ****
  • Posts: 483
  • I click a little.
    • TreeStructInfo — format for text and binary configuration files
Re: NON(!)-EXE FFPlay4Laz
« Reply #120 on: August 11, 2020, 11:23:58 pm »
Gosh, I didn't even know there was a second thread too — sorry for off-topic.

Unfortunately, I tried FFmpeg and had a lot of problems. Either there was no desktop recorder, or the audio capture didn't work, or I was getting a tons of errors during recording. I had the biggest problem with recording a fragment of the desktop, which is on an additional monitor, with a negative X coordinate (the monitor is to the left of the main screen) — it's just imposible. I gave up.

Then I used the VLC player, because it can record the desktop and sound (although it is not intuitive), but I still had problems with the sound. Despite reinstalling the drivers, codecs and the VLC player itself, the problems could not be fixed... Finally, I record the gameplay using VLC (video) and Audacity (audio), and then merge both source files using ShotCut. It takes a little more work, but better this than nothing.
« Last Edit: August 11, 2020, 11:26:54 pm by furious programming »
Lazarus 2.0.10 with FPC 3.2.0 (SVN Revision 63526), Windows 10 — all 64-bit

metis

  • Full Member
  • ***
  • Posts: 221
Re: NON(!)-EXE FFPlay4Laz
« Reply #121 on: August 13, 2020, 12:31:49 pm »
@furious programming

Did the FFmpeg-CommandLines, that I've posted work for You ?

Quote
I tried FFmpeg and had a lot of problems.
You are not alone with this.

Quote
with a negative X coordinate...it's just imposible.
Negative X/Y-Coordinates result in an Error, which is shown in the CLI's Output.

Quote
Then I used the VLC player, ...
IMHO 'VLC' is too slow for Playing and too complicated for Recording with Sound.

Quote
Despite reinstalling ..., codecs and the VLC player itself, ...
If You use 'FFmpeg' directly, no further Installations are needed -> much easier.

Most Apps, that I've found for ScreenRecording or Converting are nothing else than
Wizards, which compose a CommandLine and pass it to ... FFmpeg, that's all.
So, if You know, how to use the FFmpeg-CommandLines, You won't need anything else.
There are lots of WebPages to show, how to do it, mostly for C-Programming, but
hey, the CommandLines are the same with FPC.


Please, put further Posts, that are not related to Streaming/Playing with 'FFmpeg' into
my FFGrab4Laz-Thread. I started it, because the Code and CommandLines for
Recording/Converting are totally different from Streaming/Playing, so
it's better not to merge the two Subjects.

BTW (if not found yet): FFInfo4Laz = Read out MediaFile-Data with FFmpeg-LIBs is here:
https://forum.lazarus.freepascal.org/index.php/topic,22038.msg208700.html#msg208700
-> Download attached 'FFStreamInfo.lpr.txt'.
Or use RunFFmpeg's [Info] resp. FFmpeg's CommandLine-Tool 'ffprobe.exe', like:
ffprobe.exe -i "input.mp4" -report -hide_banner

Now, You got all my 'FFmpeg for Lazarus/FPC' related Projects.  :)
« Last Edit: January 24, 2021, 11:36:23 am by metis »
Life could be so easy, if there weren't those f*** Details.

BosseB

  • Sr. Member
  • ****
  • Posts: 342
Re: NON(!)-EXE FFPlay4Laz
« Reply #122 on: November 01, 2020, 09:24:34 pm »
Excuse me, but I just stumbled on this massive thread and I would like to ask if it is appropriate reading when I want to create a video/audio capture app with Lazarus/Fpc on Windows10?

What I want to do is capture a video playing inside a FireFox or Chrome window to a complete mp4 video/audio file.
I have already written a video editing tool, which can work with video files directly but never captured anything from another window. The tool uses PasLibVlc (and therefore the VLC engine), but the video I need to work with is not a regular stream URL, but it plays on FFx and Chrome so a screen capture app is needed.

If this is not the right thread, please say so and I will search on (after removing this post from the thread).
--
Bo Berglund
Sweden

metis

  • Full Member
  • ***
  • Posts: 221
Re: NON(!)-EXE FFPlay4Laz
« Reply #123 on: November 02, 2020, 09:30:49 pm »
@BosseB

Quote
...ask if it is appropriate reading when I want to create a video/audio capture app...
No, see my last Post:
"Please, put further Posts, that are not related to Streaming/Playing with 'FFmpeg' into
my FFGrab4Laz-Thread. I started it, because..."


This Thread is about a highly responsive and accurate FFmpeg-Streamer/Player with
outstanding AudioQuality, entirely written with FPC/Lazarus.

Anyway...
(I answer in General for any Kind of Audio/Video-Capture from WebSites, if other's are interested, too.)

Quote
...capture a video playing inside a FireFox or Chrome window...
Capture/Streaming Videos from a WebSite does not depend on Your WebBrowser.
You need the Video's URL and a WebSite, that permits to "use" that URL independently of it, too.

If the Site does not provide the Possibility for Downloading or even blocks Downloads via URL,
You may try Apps like the '4k Video Downloader': https://www.4kdownload.com

If even this is blocked, the only Way to record the Video is to capture the Monitor's Screen together with
the PC's Audio-Output. Of course, this will limit the Video's Audio-/Video-Quality to the Quality of Your
Soundcard resp. the Resolution of Your Monitor.

For how to do it with FFmpeg and Lazarus, see FFGrab4Laz as mentioned above:
http://forum.lazarus.freepascal.org/index.php/topic,43411.0.html
-> GoTo: "ScreenRecorder2FPC" (= Video only via FFmpeg-LIBs) and "RunFFmpeg" (= anything via FFmpeg-CLIs).

Here is a FFmpeg-CommandLine for ScreenRecording with Audio, that You may use with 'RunFFmpeg':
https://superuser.com/questions/995021/how-to-record-whats-playing-on-the-soundcard-using-ffmpeg
-> GoTo: "Here is a command for audio and video at the same time".
('gdigrab' and 'dshow' is for Windows; for Linux You may take 'x11grab' and 'pulse'.)

If You want to record an App's entire Window, You have to replace
-i desktop with -i title=AppWindowTitle/Caption.

If You want to record Parts of the Screen, You have to insert e.g. this into the FFmpeg-CommandLine:
... -offset_x 10 -offset_y 20 -video_size 640x480 -show_region 1 ..., which will
grab a 640x480 Region at Position X=10/Y=20, and shows the currently grabbed Region on the Screen.

FFmpeg-CommandLines in General are explained in the FFmpeg-Documentation:
http://www.ffmpeg.org/ffmpeg-all.html.

BTW: You can use 'FFmpeg' for any Kind of VideoEditing, as well.  ;)
Life could be so easy, if there weren't those f*** Details.

BosseB

  • Sr. Member
  • ****
  • Posts: 342
Re: NON(!)-EXE FFPlay4Laz
« Reply #124 on: November 05, 2020, 02:28:52 pm »
Thanks, I downloaded your archive containing the sources and I have a few questions:

RunFFmpegDemo
1) Is it needed to use a 32 bit Lazarus/Fpc as mentioned in descriptions? Mine is 64 bit...
What are the caveats when not using 64 bit?

2) It was possible to compile/build the application using my configuration but when I ran it I got a form where the ffmpeg binaries are not found. But they are on my path:
Code: Text  [Select][+][-]
  1. >where ffmpeg.exe
  2. C:\Programs\ffmpeg\bin\ffmpeg.exe
  3. >where ffprobe.exe
  4. C:\Programs\ffmpeg\bin\ffprobe.exe
  5. >where ffplay.exe
  6. C:\Programs\ffmpeg\bin\ffplay.exe
What did I do wrong? I assume that utilites like ffmpeg will be used as found on the path, or not?

UPDATE:
I copied the files mentioned above to the FFGrab4Laz_01\bin_ffmpeg-3.4.2\win64 directory and the initial messages went away.
But when I tried the grab function by changing the desktop caption to what is actually on the test window (Chrome playing a YouTube video), I got an error about ffplay anyway...
« Last Edit: November 05, 2020, 02:54:39 pm by BosseB »
--
Bo Berglund
Sweden

BosseB

  • Sr. Member
  • ****
  • Posts: 342
Re: NON(!)-EXE FFPlay4Laz
« Reply #125 on: November 05, 2020, 09:06:12 pm »
So I downloaded the SDL2.dll file as described and came a bit further...

I am using the default command in the top editbox but I replaced the text describing the window title where the screen data should come from and some metrics too.
In my case this title in the real case is very long so I used a Youtube video as test instead.
I wonder if there is not a possibility to define the source window using its handle instead? I can easily enumerate the windows and select the one with the correct listed title but use the handle value instead for the ffmpeg command.
Otherwise is there a flag to tell ffmpeg to use a partial match for the title?

I tested with a Youtube video playing in a FireFox window but no matter what I did the following happened:
- I used this as the "Grab" command:
Code: Text  [Select][+][-]
  1. -f gdigrab -framerate 25 -offset_x 60 -offset_y 200 -video_size 815x443 -show_region 1 -i desktop "(4) cnn - YouTube - Mozilla Firefox"
- When I clicked the Grab button a white rectangle briefly appeared in the upper left corner area of the screen (probably the area of screen that would be recorded?).
- Then it disappeared and an ffmpeg error was generated and nothing more happened.

Code: Text  [Select][+][-]
  1. *** FFProcess "ffmpeg.exe" started ***
  2. > ExitStatus CHANGED to: 259
  3. R LastLn[0000]: [gdigrab @ 0000021d1198ea00] Capturing whole desktop as 815x443x32 at (60,200)
  4. > ExitStatus CHANGED to: 1
  5. E ERROR: ExitCode=1 -> FFProcess stopped 'OnFFmpegError'.

What do I do then???

And where is the grabbed video file supposed to wind up?
« Last Edit: November 05, 2020, 09:42:25 pm by BosseB »
--
Bo Berglund
Sweden

metis

  • Full Member
  • ***
  • Posts: 221
Re: NON(!)-EXE FFPlay4Laz
« Reply #126 on: November 05, 2020, 09:50:37 pm »
@BosseB

Please, please, please,
put Questions, that are related to Recording with 'FFmpeg' into my FFGrab4Laz-Thread:  :'(
https://forum.lazarus.freepascal.org/index.php/topic,43411.0.html
(And remove Your last two Post from this Thread, of course.)

Then I will answer to all of Your Questions, e.g.:
Remove "(4) cnn - YouTube - Mozilla Firefox" and specify an OutputFile instead, like "grabbed.mkv".
I really do not want to merge Recording-Issues with Playing-Issues - they are too different !  ;D
Life could be so easy, if there weren't those f*** Details.

metis

  • Full Member
  • ***
  • Posts: 221
Re: NON(!)-EXE FFPlay4Laz
« Reply #127 on: November 06, 2020, 01:47:25 pm »
@BosseB
You find my Answer to Your last 2 Posts at its correct Place here.
Life could be so easy, if there weren't those f*** Details.

BosseB

  • Sr. Member
  • ****
  • Posts: 342
Re: NON(!)-EXE FFPlay4Laz
« Reply #128 on: January 22, 2021, 11:53:25 am »
Hi again @metis
I have used your info plus PasLibVlc to manage videos downloaded from streams and Youtube in order to edit out the commercials before viewing the videos.
My edit application plays the video and I can step through it in various step sizes to find and set clip points (in seconds) where the commercials start and end.
Then the application can compile a call to ffmpeg to:
1) Extract every active video section into a tmp_xx.mp4 file
2) Combine these video files into a single complete (minus the commercials) video file.

This works fine except for a minor issue I have been wondering about, so here is a question regarding this:

It turns out that if I use ffmpeg to extract  from a specific time into the video for a set duration, both in seconds, then the resulting video does not really start at the point I wanted.
It seems to always contain something before the clip start point, it can be 1-2 seconds but sometimes longer than that.
How come this happens?
Are mp4 videos quantized such that there is a video "atom" which cannot be divided and any clip will be done at "atom" borders?
I figured it should be possible to cut at frame borders (1/25 or 1/30 s) but it does not seem like this is happening.
The command I use to extract the tmp files is like this example (here the start is 1250s into the video and lasts for 600 s):
Code: Text  [Select][+][-]
  1. ffmpeg -ss 1250 -i input.mp4 -to 600 -c copy output.mp4


--
Bo Berglund
Sweden

metis

  • Full Member
  • ***
  • Posts: 221
Re: NON(!)-EXE FFPlay4Laz
« Reply #129 on: January 24, 2021, 11:31:59 am »
@BosseB

Quote
This works fine except for a minor issue ... It turns out that if I use ffmpeg...
I'm really pleased, that I could help You with Your VideoEditor-App, but
I still don't know, why You keep on Putting Your Questions at the wrong Place.  %)

This Thread is - and always will be - about Streaming/Playing with FFmpeg-Libraries and Lazarus.

Composing FFmpeg-CommandLines is totally different from Writing Code for FFmpeg-Libraries.
Therefore, their Issues and Points for Discussion are not comparable at all, and I do not want to merge them in this Thread !  ;D

All Questions related to FFmpeg-CommandLine-Tools, like 'ffmpeg.exe', are welcome in my FFGrab4Laz-Thread:
https://forum.lazarus.freepascal.org/index.php/topic,43411.0.html;)
« Last Edit: January 24, 2021, 11:41:35 am by metis »
Life could be so easy, if there weren't those f*** Details.

BosseB

  • Sr. Member
  • ****
  • Posts: 342
Re: NON(!)-EXE FFPlay4Laz
« Reply #130 on: January 24, 2021, 01:19:37 pm »
@BosseB

Quote
This works fine except for a minor issue ... It turns out that if I use ffmpeg...
I'm really pleased, that I could help You with Your VideoEditor-App, but
I still don't know, why You keep on Putting Your Questions at the wrong Place.  %)

This Thread is - and always will be - about Streaming/Playing with FFmpeg-Libraries and Lazarus.
Before posting I tried to find where I had discussed this earlier but failed....
--
Bo Berglund
Sweden

sport123

  • Newbie
  • Posts: 1
Re: NON(!)-EXE FFPlay4Laz
« Reply #131 on: February 19, 2021, 02:32:22 pm »
Are there ffmpeg components for Lazarus?  Like delphiffmpeg.com  ?

metis

  • Full Member
  • ***
  • Posts: 221
Re: NON(!)-EXE FFPlay4Laz
« Reply #132 on: February 19, 2021, 02:44:51 pm »
AFAIK no.
Life could be so easy, if there weren't those f*** Details.

BosseB

  • Sr. Member
  • ****
  • Posts: 342
Re: NON(!)-EXE FFPlay4Laz
« Reply #133 on: February 19, 2021, 04:32:13 pm »
@BosseB
This Thread is - and always will be - about Streaming/Playing with FFmpeg-Libraries and Lazarus.

Composing FFmpeg-CommandLines is totally different from Writing Code for FFmpeg-Libraries.
I must be missing something here (maybe not related to my project):
When you talk about ffmpeg-libraries, what are you referring to?
I thought that ffmpeg is a command line tool on both windows and linux the same, so the "library" would then become the command line interface, right?
Apparently not, so could you in simple terms discuss what the libraries are (plural and all)?

And I am genuinely being curious if there is some package that includes libraries that could ease the use of ffmpeg, no flame intended at all.

--
Bo Berglund
Sweden

metis

  • Full Member
  • ***
  • Posts: 221
Re: NON(!)-EXE FFPlay4Laz
« Reply #134 on: February 20, 2021, 08:10:25 pm »
@BosseB

Quote
I thought that ffmpeg is a command line tool
The FFmpeg-Project consists of several CommandLine-Tools and Libraries, see here.

The FFmpeg-CommandLine-Tools have a CommandLine-Interface (CLI), and You can pass
Options to them (= FFmpeg-CommandLines), when they start and then communicate with them, when they are running.
Those Tools are: 'ffmpeg.exe', 'ffprobe.exe', 'ffplay.exe' (and 'ffserver.exe', which was removed on 2018-01-06).
Advantage: easy to use; Disadvantage: Slow Communication via Pipes and Strings, restricted to the available Options.

The FFmpeg-Libraries (LIBs) are Collections of FFmpeg-Code, where You can access their
exported Parts and use them in Your own Code as if they were inside of Your Code, means
as if You would have written that Code by Yourself.
Advantage: fast and flexible; Disadvantage: much more complex to use compared to the FFmpeg-CLIs.

Quote
so the "library" would then become the command line interface, right?
The FFmpeg-CommandLine-Tools and -Libraries are built and compiled from the FFmpeg-SourceFiles.
This Process depends on the Target-Platform and on diverse Switches, that determine which
Parts of the Sources to include in the TargetFiles (= CLIs and LIBs).

One of those Switches determines, whether the CLIs shall be built "static" or "shared":
Static means, that the CLIs will have all of their LIBs included, so that they run
independently as stand-alone Programs, which results in bigger FileSizes for each CLI.
Shared means, that the CLIs will have all of their LIBs separated, so that each
CLI is smaller, but they only run together with their corresponding LIBs (= Dependencies).
In this Case You have to add the SDL-DLL to run 'ffplay.exe', and
this is, what You need, if You want to use the FFmpeg-LIBs in Your own App.

Now, it's obvious, that there's no Need to rewrite already existing and perfectly running Code so long as
we're Talking about self-contained Tasks (e.g. Convert a VideoFormat to an other), and so long as you're
happy with the available Options for that Task.
You simply launch, e.g. 'ffmpeg.exe' with CommandLine-Arguments, and it will be executed until the Job is done.
This is covered by FFGrab4Laz.

Things are different, if You want e.g. a fast and responsive MediaPlayer with special Features, like:
usually not implemented VideoManipulations, outstanding AudioQuality or TouchScreen-Support.
You actually have to write all by Yourself, where You may use already existing Codes inside of Libraries,
here 'FFmpeg', 'SDL' and 'Portaudio'.
This is covered by this Thread, called FFPlay4Laz.

The SourceCodes to use CLIs are totally different from the SourceCodes to use LIBs.
Therefore all related Issues and Discussions are totally different, as well.
That's why I've started two separated Threads, which I'd like to stay separated.

BTW:
You are just Writing a VideoEditor.
If You want it really fast and precice, You should use Libraries, too, but this is very complex, and
there is already a Bunch of really good VideoEditors, see e.g. in VideoHelp.

Understandable enough ?  :)

Quote
if there is some package that includes libraries that could ease the use of ffmpeg
For FreePascal: AFAIK no; for DelphiPascal, see the FFVCL-Site.
« Last Edit: February 21, 2021, 11:18:26 am by metis »
Life could be so easy, if there weren't those f*** Details.

 

TinyPortal © 2005-2018