MP4Cropper - utility to extract portion of MP4 video [SUPERCEEDED]

Moderator: Forum moderators

Post Reply
User avatar
greengeek
Posts: 1383
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 534 times
Been thanked: 192 times

MP4Cropper - utility to extract portion of MP4 video [SUPERCEEDED]

Post by greengeek »

EDITThis utility is now replaced by a similar - but better - version which handles mp4, avi, mov and flv etc too. The new version also handles spaces in filenames.
Please see: viewtopic.php?t=12215

This is a small utility I use for cropping a portion out of an MP4 video (such as the videos produced by my dashcam).

(The "cropped" portion is the part of the video that I want to keep - and is saved with a name based on the original name combined with a timestamp in order to prevent overwriting of files. The other parts of the video are ignored and the original file is unchanged)

Just place the utility wherever you want it (I use /root), remove the false .gz suffix, then make executable and click to run it.

(It uses ffmpeg to do the cropping so should work in a variety of pups. I use it mostly in Fossapup)
NOTE: modern pups that use gtk3 will need to use the "bookwormpup" version added further down below.

mp4cropper.jpg
mp4cropper.jpg (16.78 KiB) Viewed 1265 times

.
.
Version for Pups with gtk2:

mp4cropper.gz
To use. Remove fake .gz from name and give it exec permissions
(2.4 KiB) Downloaded 53 times

.
.
Version for Pups with gtk3:

mp4cropper_bookwormpup.gz
To use. Remove fake .gz from name and give it exec permissions
(2.29 KiB) Downloaded 35 times
Last edited by greengeek on Mon Jul 22, 2024 4:16 am, edited 7 times in total.
Clarity
Posts: 3816
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1620 times
Been thanked: 519 times

Re: MP4Cropper - utility to extract portion of MP4 video

Post by Clarity »

Hello @greengeek Tested. Did not create a result in BKWP64 v1006. No matter the duration.

Code: Select all

# mp4cropper 
ffmpeg version 5.1.4-0+deb12u1 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12 (Debian 12.2.0-14)
  configuration: --prefix=/usr --extra-version=0+deb12u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-libjxl --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
Invalid duration specification for ss: -i
DURATIONSECONDS=""
SOURCEVIDEO="/mnt/home/Media/1.mp4"
STARTSECONDS=""
EXIT="Quit"
# 
did not work.jpg
did not work.jpg (57.5 KiB) Viewed 1173 times
User avatar
greengeek
Posts: 1383
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 534 times
Been thanked: 192 times

Re: MP4Cropper - utility to extract portion of MP4 video

Post by greengeek »

Clarity wrote: Mon Jul 08, 2024 1:32 am

Tested. Did not create a result in BKWP64 v1006. No matter the duration.

Thanks for the testing Clarity. I dont know what causes this but my guess is gtk version maybe.
I will set up a Bookworm pup and do some testing.
Cheers!

User avatar
greengeek
Posts: 1383
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 534 times
Been thanked: 192 times

Re: MP4Cropper - utility to extract portion of MP4 video

Post by greengeek »

Clarity wrote: Mon Jul 08, 2024 1:32 am

Did not create a result in BKWP64 v1006.

I have now added a version for Bookwormpup in the first post. I assume it is also possibly suitable for other pups that are using gtk3.
@Clarity i would be keen for you to retest if you have time please. (Thanks for the complete and accurate bug report - very helpful)
Cheers!

Semme
Posts: 40
Joined: Wed Jul 22, 2020 12:44 am
Location: Ground Zero
Has thanked: 1 time
Been thanked: 6 times

Re: MP4Cropper - utility to extract portion of MP4 video

Post by Semme »

greengeek,

This worked good enough for me. Which video player (MPV here) were you sampling with?

~ Few things move as quietly as the future ~

Clarity
Posts: 3816
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1620 times
Been thanked: 519 times

Re: MP4Cropper - utility to extract portion of MP4 video

Post by Clarity »

+1 :thumbup:

Loaded in my-applications/bin. This utility can launch from ROX (via click) or from a terminal.

Question
In your future, could it be opened in a terminal by adding the video filepath? For example
mp4cropper /mnt/home/media/1.mp4

It works very well and very fast as it is.

Last edited by Clarity on Mon Jul 08, 2024 8:32 am, edited 1 time in total.
User avatar
greengeek
Posts: 1383
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 534 times
Been thanked: 192 times

Re: MP4Cropper - utility to extract portion of MP4 video

Post by greengeek »

Semme wrote: Mon Jul 08, 2024 8:23 am

This worked good enough for me. Which video player (MPV here) were you sampling with?

Hi Semme - good to hear from you. Which pup were you using for the test please? My usual daily driver is a version of Ozsouth's Fossa 9.5 Mid which uses mplayer, but I have now also tested it with BookwormPup (mpv) and rockedge's latest Fossa 9.6 CE which also uses mpv.
(I think there may be a problem with the mpv in bookworm but I have only just started testing it so too early to confirm...)

User avatar
greengeek
Posts: 1383
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 534 times
Been thanked: 192 times

Re: MP4Cropper - utility to extract portion of MP4 video

Post by greengeek »

Clarity wrote: Mon Jul 08, 2024 8:24 am

Question
In your future, could it be opened in a terminal by adding the video filepath? For example
mp4cropper /mnt/home/media/1.mp4

Very good question and I am afraid I do not know the answer.
I will do some research about how to achieve that.

EDIT : I just tried this and it seems to work:
Placed the mp4cropper_bookwormpup utility into /usr/local/bin and opened a terminal and ran the following:
mp4cropper_bookwormpup /root/test.mp4

....and it opens up the gui as normal.

Does this work for you? Or did I misunderstand your question?

EDIT2:
No i guess what you meant was - is it possible to pass all the parameters to the utility ex cli.
eg: mp4cropper /mnt/home/media/1.mp4 x y - where x is start_seconds and y is duration_seconds.
Unfortunately I don't know how that is done (gut feeling that it may be something to do with ncurses) - but will do more researching)

EDIT3:
I have worked out how to "collect" the variables passed by the user from the CLI to the script - but havent worked out yet how to default them into the gtkdialog gui display. Workin' on it. I may be some time...

Semme
Posts: 40
Joined: Wed Jul 22, 2020 12:44 am
Location: Ground Zero
Has thanked: 1 time
Been thanked: 6 times

Re: MP4Cropper - utility to extract portion of MP4 video

Post by Semme »

Thank you gg, Mate. As for my driver I'm still running philb's, rock-solid Fossapup!

~ Few things move as quietly as the future ~

User avatar
greengeek
Posts: 1383
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 534 times
Been thanked: 192 times

Re: MP4Cropper - utility to extract portion of MP4 video

Post by greengeek »

Clarity wrote: Mon Jul 08, 2024 8:24 am

In your future, could it be opened in a terminal by adding the video filepath? For example
mp4cropper /mnt/home/media/1.mp4

Hi @Clarity - I have decided not to integrate passsing of cli variables into the gtk gui just yet (as I need to find more info first).

However - if you have time please try this similar script I have written ("mp4crop")
(It is not a gtkdialog gui - just a cli only version of the same conversion).

Usage:
- Place "mp4crop" in PATH (i used /usr/local/bin but your my-applications-bin method will work i assume??)
- in terminal type the following:
mp4crop /root/test.mp4 x y

(where x= startseconds and y=durationseconds)
(and obviously change the filename to match yours)

Delete false .gz suffix, make executable, and place in PATH

mp4crop.gz
Remove false .gz suffix and place in /usr/local/bin
(1023 Bytes) Downloaded 25 times
Clarity
Posts: 3816
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1620 times
Been thanked: 519 times

Re: MP4Cropper - utility to extract portion of MP4 video

Post by Clarity »

Works :thumbup:

Clarity
Posts: 3816
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1620 times
Been thanked: 519 times

Re: MP4Cropper - utility to extract portion of MP4 video

Post by Clarity »

I like and continue to use the MP4Cropper. :geek: :thumbup: Again THANKS!

I offer this ONLY for information (entertainment for some): AND it is NO WAY is a suggestion.

Enjoy ===> 2024 Editing in Linux

geo_c
Posts: 2877
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2197 times
Been thanked: 872 times

Re: MP4Cropper - utility to extract portion of MP4 video

Post by geo_c »

I like this!

Using the command line version.

For a 3min video the crop was nearly instantaneous.

geo_c
Old School Hipster, and Such

User avatar
greengeek
Posts: 1383
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 534 times
Been thanked: 192 times

Re: MP4Cropper - utility to extract portion of MP4 video [SUSPENDED]

Post by greengeek »

This utility has been replaced by a better one (vidxtractor) which can be found here:
viewtopic.php?t=12215

Two main reasons for replacement:
1) mp4cropper could not handle spaces in filenames (new utility can)
2) The term "cropping" a video was a bit of a misnomer. "Cropping" really should refer to the changing of resolution or aspect ratio of each video frame - rather than extacting a portion of the video at original resolution. (ffmpeg CAN handle frame cropping but my utility was not intended for that so the name was deceptive)

If there are any questions re mp4cropper I will still attempt to answer - but I recommend vidxtractor instead, so I have marked this thread superceeded.

Post Reply

Return to “Multimedia”