Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2019-02

Can I use fpc/Lazarus to edit mp4 files?

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bo Berglund

I am looking for a way to edit mp4 video files by cutting away parts of the file.
So I am not looking for a way to view and edit the video visually, rather a file cutting tool where I can use times into the video to cut away parts between two timestamps.

Preferably as a command line utility that can be scripted.

Is such a thing even possible and if so is it already done?

Something like:
videocut -x33.4-41.1 -x134.9-148.6 myvideo.mp4
where the -x parameter specifies a section to remove.

I don't think that it is possible to just open the file as binary and write some sections of it into an output file since that would have to be done based on file position in bytes and I have no idea how video times relate to the actual file position...

Bo Berglund Developer in Sweden

Reply by email

José Mejuto
to Bo Berglund
Bo Berglund wrote 7 lines
I am looking for a way to edit mp4 video files by cutting away parts of the file. So I am not looking for a way to view and edit the video visually, rather a file cutting tool where I can use times into the video to cut away parts between two timestamps. Preferably as a command line utility that can be scripted.

Hello,

Just use ad-hoc tools like ffmpeg (I'm using it for everything audio/video related) as its command line is powerful enough.

If you have problems with it mail me private with expected result and I'll try to give you a command line params to achieve it.

Reply by email

Bo Berglund
to José Mejuto
José Mejuto wrote 13 lines
El 28/02/2019 a las 10:12, Bo Berglund via lazarus escribió: > I am looking for a way to edit mp4 video files by cutting away parts > of the file. > So I am not looking for a way to view and edit the video visually, > rather a file cutting tool where I can use times into the video to cut > away parts between two timestamps. > > Preferably as a command line utility that can be scripted. Hello, Just use ad-hoc tools like ffmpeg (I'm using it for everything audio/video related) as its command line is powerful enough.

Thanks for the input!

Yes, I had googled for the function and thought about ffmpeg too but when I located a stackoverflow post about cutting video it turns out to work the opposite way!

https://stackoverflow.com/questions/18444194/cutting-the-videos-based-on-start-and-end-time-using-ffmpeg

Instead of cutting *away* the section it instead cut away everything else leaving only the part that I wanted to remove...

I used this as a test to *remove* a section from 1:30 to 2:30 in the video, but instead it extracted a 2:30 long part from the video starting at 1:30...

ffmpeg -i testvideo.mp4 -ss 00:01:30 -t 00:02:30 -async 1 cut.mp4

Then I also used another command later in the post:

ffmpeg -ss 00:01:30 -i testvideo.mp4 -to 00:02:30 -c copy cut2.mp4

This created the same length output containing the same video section but was MUCH faster...

But still it did not do what I want, instead it extracts into a new video the part what I want to get rid of...

If you have problems with it mail me private with expected result and I'll try to give you a command line params to achieve it.

Thanks for the offer, but I don't know your email address (I am interfacing with the mail list via GMane news gateway only)...

What I would like to do is to specify multiple cutaways in a file based on time from the start so the process would be a one-time operation where the final video does not contain any of the specified video sections.

And I could probably use Lazarus to create a program enabling me to specify the time sections and such and send a properly formatted command line to ffmpeg...
(These cmd line utilities have such complex commands that one is prone to forget between uses.)

Bo Berglund Developer in Sweden

Reply by email

José Mejuto
to Bo Berglund
Bo Berglund wrote
Yes, I had googled for the function and thought about ffmpeg too but when I located a stackoverflow post about cutting video it turns out to work the opposite way!

Hello,

It could be done thinking opposite... :-)

Thanks for the offer, but I don't know your email address (I am interfacing with the mail list via GMane news gateway only)...

I'll mail you in private, it is too much off topic here.

Reply by email

Bo Berglund
to José Mejuto
José Mejuto wrote 15 lines
El 28/02/2019 a las 10:56, Bo Berglund via lazarus escribió: > Yes, I had googled for the function and thought about ffmpeg too but > when I located a stackoverflow post about cutting video it turns out > to work the opposite way! Hello, It could be done thinking opposite... :-) > Thanks for the offer, but I don't know your email address (I am > interfacing with the mail list via GMane news gateway only)... I'll mail you in private, it is too much off topic here.

Thanks,
I have found other threads etc where people have asked the same as I did and clarified what they meant. Whereupon the solution seemed to have been to make good pieces of the video and then merge these together into one, all using ffmpeg.
I am looking forward to your email.

Bo Berglund Developer in Sweden

Reply by email