I never thought of that.
Lets see...
Code:
yt-dlp -f 140 "https://youtube.com/watch?v=muAiqLbblVQ&t=10" -o test1.m4a
mplayer test1.m4a
url=$(yt-dlp -g -f 140 https://m.youtube.com/watch?v=muAiqLbblVQ)
mplayer "$url"
Nope, it grabbed the whole thing.
It's hard to beat ffmpeg for video/audio manipulation. ffmpeg is my first goto for that.
The problem that the @OP will have is, you'll have to know where the breaks that you want are before you start to download the segments. So you'll have to get the whole audio to start with anyway. Unless you have some kind of notes on the video because you were there when it was made. Otherwise, I don't see how one could know where the segments should start/stop.
And if you are playing it over and over to determine that, you'll use more bandwidth than if you downloaded it once, and then worked on that local file.
You can make a script easy enough to get time stamps for where it should be cut. Play the local video once and mark it while you play it.
Example:
There was a sitcom that I caught from TV tuner to file, overnight. My machine awakened, caught the video, went back to sleep. And that gave me a 34 min long transport stream. mpeg2 video, ac3 audio.
It had 4 segments that I wanted to keep, and get rid of the commercial breaks. First thing that I wanted was to run it through ffmpeg to make a mp4 out of the transport stream so that it had an accurate time base for ffmpeg to work with. A transport stream does not, there is no way to cut a video on time stamps with a file.ts, because it doesn't have one.
I wanted to be able to play the video quickly and mark the start and stop of the segments that I wanted to keep, cut them out with ffmpeg into separate files, then put all of them together in to one video. Done.
Here are a few snippets of it.
Make a mp4 out of it if wanted.
Code:
read -p "Enter/Paste file.ts for editing :" vid
#Make a .mp4 out of it so it has correct time index
read -p "Make .mp4 file to start? y or n :" yn
case $yn in
[Yy]* ) ffmpeg -i "$vid" -c:a copy -c:v copy "${vid%.*}".mp4
vid=""${vid%.*}".mp4" ;;
[Nn]* ) ;;
esac
Mark the video segments start/stop with the space bar while playing the video with mplayer. I'll use a utube video for source.
Code:
vid="MyVideo.mp4"
#Get video index times from mplayer. Press space bar to
#capture index times to array for start/stop times of segments
tstamp=($(while read line; do
grep -oP 'A:\K[^V]+' <<< "$line" | tail -n 1 | cut -d "." -f1
done < <(mplayer -osdlevel 3 "$vid" -vf scale=768:432 2>&1)))
For a test, I marked the video with the space bar for 6-13 seconds, then 20-28 seconds.
Code:
echo "${tstamp[@]}"
6 13 20 28
You can then use that info for ffmpeg.
Code:
#Loop through array and use ffmpeg to make video segments.
arr_num=0
mp4_num=1
for i in "${tstamp[@]}"; do
#Stop on last segment
if [ "$arr_num" -eq "${#tstamp[@]}" ]; then
break
fi
#Start/Stop time of segments
Start="${tstamp[arr_num]}"
arr_num=$(($arr_num + 1))
Stop="${tstamp[arr_num]}"
arr_num=$(($arr_num + 1))
Diff=$(($Stop - $Start))
#ffmpeg string to make video segments
ffmpeg -ss "$Start" -t "$Diff" -i "$vid" -c:a aac -b:a 192k \
-af volume=1.2 -c:v libx264 -crf 18 -preset slow -s 768x432 \
file"$mp4_num".mp4 &&
#echo file name created to ConFile for ffmpeg
echo "file 'file"$mp4_num".mp4'" >> ConFile
mp4_num=$(($mp4_num + 1))
done
And that gives me file1.mp4, file2.mp4 and Confile.
Code:
#Put the segments together.
ffmpeg -f concat -i ConFile -c:a copy -c:v copy Tv_finished.mp4
Code:
ffprobe Tv_finished.mp4
ffprobe version n5.0 Copyright (c) 2007-2022 the FFmpeg developers
built with gcc 11.2.0 (GCC)
...
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Tv_finished.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf59.16.100
Duration: 00:00:15.07, start: 0.000000, bitrate: 1597 kb/s
Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 768x432 [SAR 1:1 DAR 16:9], 1412 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
Metadata:
handler_name : ISO Media file produced by Google Inc.
vendor_id : [0][0][0][0]
Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 179 kb/s (default)
Metadata:
handler_name : ISO Media file produced by Google Inc.
vendor_id : [0][0][0][0
If you have a bash shell, youtube-dl and ffmpeg, There isn't much that can't be done with utube vids.