I hate video editors

All i want to do is edit a video and cut off the last few seconds to tidy it up and none of the stupid software lets me do that simple thing. something this simple aught to be intuitive

2 Likes

To just cut few seconds at the beginning or end you can use a command line tool. I think ffmpeg can do it.

3 Likes

One thing I don’t like is that if I just cut away a few seconds at the beginning or end, I need to re-export the whole video and burn my CPU. Logically speaking, it should be like copying the video file without a few bytes from the beginning or end. But yeah, I know videos don’t work that way.

2 Likes

Let’s face it. When it comes to video editing I’m a dullard. I literally can’t figure it out.

1 Like

I guess you should go for Avidemux. Very easy to use and various formats supported. Can be installed from AUR (avidemux-qt).
Even Handbrake could do the job.

That reminds me of a guy who tried to use split to to transform a large video file into a few smaller ones. :rofl: :rofl:
Surprise it didn’t work.

4 Likes

As @Zircon34 said ffmpeg can do that.

ffmpeg  -i "inputvideo.mkv"       \
            -ss "00:00:25"        \
            -to "00:02:30"        \
            -map 0:v? -c:v copy   \
            -map 0:a? -c:a copy   \
            -map 0:s? -c:s copy   \
            "outputvideo.mkv"

It is split to several lines just to make is clear. -i specify input video
-ss from time
-to to time
-map tells it to use certain channels from the input video where 0:v? means “use input video number 0 (a.k.a. first video) and take video channels (v) and take all of them (?)”
-c specify which codec should be used for encoding where v, a, s stands for video, audio, subtitles and copy just tell it to use the same as is in the input video. If you don’t specify copy it will try to guess the codec by output video’s name.
the last line is just a name of the output video.

See, simple. :rofl:

If you want this is my script for converting all videos in a current directory to mkv with x265 encoding and resizing it to 720P by default. Use at your own risk. :wink:

video-convert
#!/bin/bash

dir="$(pwd)"

# default storage locations
out_dir="_converted"
out_log="${out_dir}/_log"

# error output storage
err_file="_00000_ERROR_conversion.txt"
rm -f "${dir}/${err_file}"

# default values
height=720                  # maximal pixel height of converted video
crf=26                      # video quality
aa='-map 0:a? -c:a copy'    # audio mapping
ss='-map 0:s? -c:s copy'    # subtitles mapping
log=1                       # default true

# print help
usage() {
    echo "Usage: $0 [-hf:t:P:q:sal]
    -h ........... this help
    -f <val> ..... from time - format hh:mm:ss
    -t <val> ..... to time - format hh:mm:ss (make sure f<t)
    -P <val> ..... pixel height (default ${height}p)
    -q <val> ..... video quality as crf (default ${crf}; 0=lossless, 51=worst)
    -s ........... no subtitles
    -a ........... no audio
    -l ........... no conversion logging
    " 1>&2; exit "$1"; }

# parse command line arguments
while getopts "hf:t:P:q:sal" arg; do
	case "${arg}" in
		h)
			usage 0
			;;
		f)
			f="-ss ${OPTARG}"
			;;
		t)
			t="-to ${OPTARG}"
			;;
		P)
			height="${OPTARG}"
			;;
		q)
		    crf="${OPTARG}"
		    ;;
		s)
			ss=''
			;;
		a)
			aa=''
			;;
		l)
		    log=0
		    ;;
		*)
		    usage 1
		    ;;
	esac
done


# find all files and get rid of all already converted and some non-video files
# then for each file make the conversion
find "${dir}" -type f                                                   |\
grep -Evie "^.*(${out_dir}).*$"                                         |\
grep -Evie '^.*\.(txt|srt|sub|log|i?nfo|rar|zip|7z)$'                   |\
sort -Vfs                                                               |\
while read file; do

    # create storage directories
	mkdir -p "${file%/*}/${out_dir}"
    [[ log -eq 1 ]] && mkdir -p "${file%/*}/${out_log}"

    # get file name for further processing
    printf "${file}"
    filename=${file##*/}

    # log storage file from the ffmpeg output
    if [[ log -eq 1 ]]; then
        log_file="${file%/*}/${out_log}/${filename%.*}_${height}p.log"
    else
        log_file="/dev/null"
    fi

    # conversion time measurement
    TIME_START=$(date +%s%N)

    # the conversion itself
    ffmpeg  -y -i "${file}"                                                                     \
            ${f}                                                                                \
            ${t}                                                                                \
            -map 0:v? -c:v libx265 -crf ${crf} -vf scale="trunc(oh*a/2)*2:min(${height}\,ih)"   \
            ${aa}                                                                               \
            ${ss}                                                                               \
            "${file%/*}/${out_dir}/${filename%.*}_${height}p.mkv"                               \
            2> "${log_file}" < /dev/null

    # store which files return with an error code
	if [ $? -ne 0 ]; then
        echo "${file}" >> "${dir}/${err_file}"
	fi

    # conversion time measurement
	TIME_STOP=$(date +%s%N)
	printf "\t\tdone: %.2f s\n" "$(echo "(${TIME_STOP}-${TIME_START})/1000000000" | bc -l | sed -e "s/,/\./g")"
done

# print all files that had a problem with the conversion
if [[ -f "${err_file}" ]]; then
    echo -e "\n\nconversion errors:"
    cat "${err_file}"
fi
6 Likes

Why on earth did you mark that as the solution? What does that post solve? How is it helpful to others? :man_facepalming:t3:

As others have suggested, use ffmpeg. With it, it is trivial to remove sections from the beginning or the end of a video.

You should really mark @vlkon’s post as the solution, he even gave you a nice example, so the only thing you have to do is note the “from” and “to” times.

5 Likes

Another easy and simple gui frontend is Vidcutter.

2 Likes

Thank’s for standing up for me. :blush: :frog:

3 Likes

His post didnt exist when I marked a solution. I just got out of bed. It’s sabbath rest day. Don’t be mean to me before breakfast,?even on sabbath

One example that I’ve used a lot is avidemux-qt. Very simple to use.

2 Likes

avidemux

Avidemux, like others say, so easy.
Open video…
Scroll to the area where you want to cut
ALWAYS use KEYFRAMES to find where you want to cut.
When the mark is set, hit delete to remove the end and then save.

2 Likes

You can still change it :stuck_out_tongue:

1 Like

my video is all black when i open it in avidemux-qt my decoder says vdpau and i cant seem to change it?

where are keyframes at?

VidCutter works well if all you want to do is snip a video. I’d forgotten about it.

this worked easy enough for me to figure it out.

The keyframes are found by using the buttons I use in the GIF. You can see what they do if you hold the mouse over them.

Preferences → HW Accel → Remove marks or set the correct one.

Just for your understanding what keyframes are :
The keyframe (i-frame) is the full frame of the image in a video.
There are also, so called p-frames (predictive or delta frames). These only contain the changes (hence delta frames) compared to the previous frame.
There are always several p-frames between two i-frames.
So if you cut a video you’re always supposed to cut at i-frames (keyframes).

1 Like

I use this one, which works fine and since it is an appimage, there is no install :slight_smile:
[https://github.com/mifi/lossless-cut]
:slight_smile:

1 Like