|
|
| (9 intermediate revisions by the same user not shown) |
| Line 14: |
Line 14: |
| </pre> | | </pre> |
| First command generates the convolution file, second command applies it. | | First command generates the convolution file, second command applies it. |
| == Remove Subitles == | | == Remove Subtitles == |
| <pre> | | <pre> |
| ffmpeg -i series_launch_english.mp4 -c copy -sn series_launch_english_nosubs.mp4 | | ffmpeg -i series_launch_english.mp4 -c copy -sn series_launch_english_nosubs.mp4 |
| Line 20: |
Line 20: |
| See Also: https://start.duckduckgo.com/?q=Advanced+SubStation+Alpha&ia=web | | See Also: https://start.duckduckgo.com/?q=Advanced+SubStation+Alpha&ia=web |
|
| |
|
| = DVD Handling = | | = FFMpeg = |
| == TL;DR (updated 2025-07-15): == | | == Concat == |
| === Rip from DVD ===
| |
| <pre> | | <pre> |
| makemkvcon mkv --minlength=3600 disc:0 all mkv_out_01/
| | cat > list.txt |
| | file 'file1.mkv' |
| | file 'file2.mkv' |
| | ^d |
| | ffmpeg -f concat -safe 0 -i list.txt -map 0 -c copy output.mkv |
| </pre> | | </pre> |
| === Set Crop ===
| | or |
| <pre> | | <pre> |
| export FILE=mkv_out_01/foo.mkv
| | ffmpeg -f concat -safe 0 -i list.txt \ |
| (ffmpeg -i "$FILE" -vf cropdetect -f null - 2>&1 & echo $! > /tmp/cropdetect.id) | grep crop | head -30000 | awk '{print $14}' | sort | uniq -c | sort -n && pkill -P $(cat /tmp/cropdetect.id)
| | -map 0:v -map 0:a -map 0:s -map 1:v -map 1:a -map 1:s \ |
| export CROP=crop=720:200:90:60
| | -c copy output.mkv |
| </pre> | | </pre> |
| | | == Resize == |
| === Compress === | | === Scale, Match Vertical to Suit 720 === |
| Cartoons with Interlacing:
| |
| <pre> | | <pre> |
| export VPATH=Family_Guy-S05D01 ; ls $VPATH | perl -e '$a=0;while(<>){$a++;$b="0".$a;if($a>9){$b="".$a;}chomp;print"export FILE=".$_." && ffmpeg -i \"\$VPATH/\$FILE\" -map 0 -vf \"yadif=1:-1:0,\$CROP\" -c:v libx264 -crf 23 -preset fast -b:a 192k -c:s copy Family_Guy-S05E$b.mkv\n";}' | sh
| | ffmpeg -i input.avi -filter:v scale=720:-1 -c:a copy output.mkv |
| </pre>
| |
| | |
| Latest (2025-07-29, used for live action, but should work for animation also)
| |
| <pre>
| |
| $ export VPATH=s01d01/ ; export LAST_NUM=0; export SEASON="01"; export SHOW="Le_Bureau" ; ls $VPATH | perl -e '$a='$LAST_NUM';while(<>){$a++;$b="0".$a;if($a>9){$b="".$a;}chomp;print"export FILE=\"".$_."\" && ffmpeg -i \"\$VPATH/\$FILE\" -map 0 -vf \"yadif=1:-1:0,\$CROP\" -c:v libx264 -crf 23 -preset fast -b:a 192k -c:s copy '$SHOW'-S'$SEASON'E$b.mkv\n";}'
| |
| </pre>
| |
| | |
| Latest latest, 10 minutes later:
| |
| <pre>
| |
| export VPATH=s02d01 ; export LAST_NUM=0; export SEASON="02"; export SHOW="Le_Bureau" ; ls $VPATH | perl -e '$a='$LAST_NUM';while(<>){$a++;$b="0".$a;if($a>9){$b="".$a;}chomp;print"ffmpeg -i \"'$VPATH'/".$_."\" -map 0 -vf \"yadif=1:-1:0,\$CROP\" -c:v libx264 -crf 23 -preset fast -b:a 192k -c:s copy '$SHOW'-S'$SEASON'E$b.mkv\n";}'
| |
| </pre>
| |
| | |
| <pre>
| |
| export LAST_NUM=0; export DISC="01"; export SEASON="01"; export SHOW="Le_Bureau" ; export VPATH="s"$SEASON"d"$DISC; ls $VPATH | perl -e '$a='$LAST_NUM';while(<>){$a++;$b="0".$a;if($a>9){$b="".$a;}chomp;print"ffmpeg -i \"'$VPATH'/".$_."\" -map 0 -vf \"yadif=1:-1:0,'$CROP'\" -c:v libx264 -crf 23 -preset fast -b:a 192k -c:s copy '$SHOW'-S'$SEASON'E$b.mkv\n";}'
| |
| </pre>
| |
| | |
| == Make ISO Image ==
| |
| <pre>
| |
| $ time dd if=/dev/sr0 of=/media/bob/backup/media/tmp/How_to_Train_Your_Dragon.iso bs=4M status=progress
| |
| </pre>
| |
| == Copy to Disk ==
| |
| <pre>
| |
| makemkvcon mkv --minlength=3600 disc:0 all mkv_out_01/
| |
| makemkvcon mkv --minlength=3600 iso:How_to_Train_Your_Dragon.iso all dragon_out/
| |
| </pre>
| |
| | |
| == Downscale MKV With Subtitles and Audio ==
| |
| <pre>
| |
| export FILE=mkv_out_01/foo.mkv
| |
| (ffmpeg -i "$FILE" -vf cropdetect -f null - 2>&1 & echo $! > /tmp/cropdetect.id) | grep crop | head -30000 | awk '{print $14}' | sort | uniq -c | sort -n && pkill -P $(cat /tmp/cropdetect.id)
| |
| export CROP=crop=720:200:90:60
| |
| ffmpeg -i "$FILE" -map 0 -vf "$CROP" -c:v libx264 -crf 23 -preset fast -b:a 196k -c:s copy Magnificent_Seven-The.mkv
| |
| ffmpeg -i "$FILE" -map 0 -vf "yadif=1:-1:0,$CROP" -c:v libx264 -crf 23 -preset fast -b:a 196k -c:s copy Magnificent_Seven-The.mkv
| |
| </pre>
| |
| | |
| To use AAC if Vorbis is barfing:
| |
| <pre>
| |
| ffmpeg -i "$FILE" -map 0 -vf "$CROP" -c:v libx264 -c:a aac -crf 23 -preset fast -b:a 196k -c:s copy Magnificent_Seven-The.mkv
| |
| </pre>
| |
| | |
| <pre>
| |
| ffmpeg -i "$FILE" -map 0 -vf "scale=-1:720" -c:v libx264 -crf 23 -preset fast -b:a 196k -c:s copy "../$FILE"
| |
| </pre>
| |
| <pre>
| |
| (ffmpeg -i "$FILE" -vf cropdetect -f null - 2>&1 & echo $! > /tmp/cropdetect.id) | grep crop | head -10000 | tail -5000 | shuf | head -10 && pkill -P $(cat /tmp/cropdetect.id)
| |
| ffmpeg -i "$FILE" -vf cropdetect -f null - 2>&1 | grep crop | head -10000 | tail -5000 | shuf | head -10
| |
| </pre>
| |
| | |
| crf 23 is mid-field
| |
| | |
| crf 28 is aggressive compression
| |
| | |
| <pre>
| |
| ffmpeg -i "$FILE" -map 0 -vf "scale=-1:720" -c:v libx264 -crf 23 -preset fast -b:a 128k -c:s copy Firefly-s01e01-Serenity.mkv
| |
| </pre>
| |
| | |
| <pre>
| |
| ffmpeg -i mkv_out_01/Zombieland_t00.mkv -map 0 -vf scale=-1:720 -c:v libx264 -crf 23 -preset fast -b:a 128k -c:s copy Zombieland.mkv
| |
| </pre>
| |
| <pre>
| |
| 720:368:0:54
| |
| </pre>
| |
| <pre>
| |
| ffmpeg -i input.mp4 -vf "crop=720:368:0:54" -c:v libx264 -crf 23 -preset fast output.mp4
| |
| </pre> | | </pre> |
| | == Time == |
| <pre> | | <pre> |
| ffmpeg -i mkv_out_01/Zombieland-J1_t00.mkv -map 0 -vf "crop=720:352:0:66" -c:v libx264 -crf 23 -preset fast -b:a 128k -c:s copy Zombieland.mkv | | ffmpeg -i foo.avi -ss 01:23:45 -to 02:34:56 out.avi |
| </pre> | | </pre> |
|
| |
|
| Fix aspect ratio without changing pixels:
| |
| <pre>
| |
| ffmpeg -i input.mp4 -c copy -aspect 16:9 output.mp4
| |
| </pre>
| |
| === All Episodes ===
| |
| <pre>
| |
| export CROP=crop=720:480:0:0
| |
| export VPATH=monk-s06d01 ; ls $VPATH | perl -e '$a=0;while(<>){$a++;$b="0".$a;if($a>9){$b="".$a;}chomp;print"export VPATH=\"'$VPATH'\" && export FILE=".$_." && ffmpeg -i \"\$VPATH/\$FILE\" -map 0 -vf \"yadif=1:-1:0,\$CROP\" -c:v libx264 -crf 23 -preset fast -b:a 192k -c:s copy Monk-S06E$b.mkv\n";}' > cmd.sh
| |
| </pre>
| |
|
| |
| <pre>
| |
| export VPATH=mkv_out_02 ; ls $VPATH | perl -e '$a=8;while(<>){$a++;$b="0".$a;if($a>9){$b="".$a;}chomp;print"export FILE=".$_." && ffmpeg -i \"\$VPATH/\$FILE\" -map 0 -vf \"\$CROP\" -c:v libx264 -crf 23 -preset fast -b:a 192k -c:s copy Scrubs-S01E$b.mkv\n";}'
| |
| </pre>
| |
| <pre>
| |
| ls mkv_out_01/ | perl -e '$a=0;while(<>){$a++;$b="0".$a;if($a>9){$b="".$a;}chomp;print"export FILE=".$_." && ffmpeg -i \"mkv_out_01/\$FILE\" -map 0 -vf \"\$CROP\" -c:v libx264 -crf 23 -preset fast -b:a 192k -c:s copy Scrubs-S01E$b.mkv\n";}'
| |
| </pre>
| |
| ==== Interlacing in Cartoons ====
| |
| Detect Interlacing:
| |
| <pre>
| |
| ffmpeg -i input.mp4 -vf idet -frames:v 100 -an -f rawvideo -y /dev/null
| |
| </pre>
| |
| remove interlacing artifacts with:
| |
| <pre>
| |
| export VPATH=Family_Guy-S05D01 ; ls $VPATH | perl -e '$a=0;while(<>){$a++;$b="0".$a;if($a>9){$b="".$a;}chomp;print"export FILE=".$_." && ffmpeg -i \"\$VPATH/\$FILE\" -map 0 -vf \"yadif=1:-1:0,\$CROP\" -c:v libx264 -crf 23 -preset fast -b:a 192k -c:s copy Family_Guy-S05E$b.mkv\n";}' | sh
| |
| </pre>
| |
|
| |
| <pre>
| |
| -vf "yadif=0:-1:0" -c:v libx264 -flags +ilme+ildct -crf 23
| |
| -vf "yadif=0:-1:0" -flags -ilme -flags -ildct -c:v libx264 -crf 23
| |
| -vf yadif
| |
| yadif=0:-1:0 (default)
| |
| yadif=1:-1:0 (double frame)
| |
| </pre>
| |
| === list tv show seasons ===
| |
| <pre>
| |
| video/tv/incoming$ find . -type f -name '*.mkv' | perl -e 'while(<>){chomp;if ($_=~/\/.*\/.*\//){}else{$a=$_;$a=~s/(-[SV][0-9][0-9]).*/$1/;print $a."\n";}}' | sort | uniq | cut -d '/' -f 3
| |
| </pre>
| |
|
| |
| == Resetting a USB DVD Drive in Linux ==
| |
|
| |
| If your USB DVD drive becomes unresponsive in Linux, you can attempt to reset it without rebooting your system by following these steps:
| |
|
| |
| === Identify the USB Device ===
| |
| Use the <code>lsusb</code> command to list all USB devices and find your DVD drive:
| |
|
| |
| <pre>
| |
| lsusb
| |
| </pre>
| |
|
| |
| <pre>
| |
| Bus 002 Device 005: ID 152d:0562 JMicron Technology Corp. / JMicron USA Technology Corp. JMS567 SATA 6Gb/s bridge
| |
| </pre>
| |
|
| |
| === Check the Device Status ===
| |
| Use <code>dmesg</code> or look at <code>/var/log/syslog</code> or <code>/var/log/messages</code> for any specific issues.
| |
|
| |
| === USB Device Reset ===
| |
| Reset the USB device by echoing a special value to the <code>/sys</code> directory:
| |
|
| |
| <pre>
| |
| echo 0 | sudo tee /sys/bus/usb/devices/usb[Bus]/[Bus]-[Device]/authorized
| |
| echo 1 | sudo tee /sys/bus/usb/devices/usb[Bus]/[Bus]-[Device]/authorized
| |
| </pre>
| |
|
| |
| Replace <code>[Bus]</code> and <code>[Device]</code> with the appropriate numbers from the <code>lsusb</code> output.
| |
|
| |
| === Unloading and Reloading the Kernel Module ===
| |
| If you know the kernel module for your USB drive, unload it:
| |
|
| |
| <pre>
| |
| sudo rmmod uhci_hcd
| |
| </pre>
| |
|
| |
| And reload it:
| |
|
| |
| <pre>
| |
| sudo modprobe uhci_hcd
| |
| </pre>
| |
|
| |
| === Restarting the udev Service ===
| |
| Restart the <code>udev</code> service, which manages device nodes:
| |
|
| |
| <pre>
| |
| sudo service udev restart
| |
| </pre>
| |
|
| |
| === Using usbreset ===
| |
| Compile and use the <code>usbreset</code> program for a more convenient reset.
| |
|
| |
| '''Note:''' Replace <code>uhci_hcd</code> with the module specific to your system. Always ensure no process is using the device before attempting a reset.
| |
|
| |
| '''Caution:''' Resetting kernel modules and USB devices can lead to an unstable system state. Use these commands carefully and ensure you're not affecting other essential USB devices.
| |
|
| |
| If these methods do not resolve the issue, the problem may lie with the hardware of the drive, USB port, or cable. Consider trying a different port or cable.
| |
|
| |
| = FFMpeg =
| |
| == Resize ==
| |
| === Scale, Match Vertical to Suit 720 ===
| |
| <pre>
| |
| ffmpeg -i input.avi -filter:v scale=720:-1 -c:a copy output.mkv
| |
| </pre>
| |
| = Players = | | = Players = |
| == MPV == | | == MPV == |
| Line 223: |
Line 61: |
|
| |
|
| = Subtitle Processing = | | = Subtitle Processing = |
| | == Embed .vtt into .mkv == |
| | <pre> |
| | ffmpeg -i input.mkv -i subtitles.vtt -c:v copy -c:a copy -c:s mov_text -map 0 -map 1 -metadata:s:s:0 language=fre output.mkv |
| | </pre> |
| | <pre> |
| | ffmpeg -i subtitles.vtt subtitles.srt |
| | ffmpeg -i input.mkv -i subtitles.srt -c:v copy -c:a copy -c:s srt -map 0 -map 1 -metadata:s:s:0 language=fre output.mkv |
| | </pre> |
| | |
| == Dual Subtitles == | | == Dual Subtitles == |
| === Option 1: Use <code>secondary-sid</code> === | | === Option 1: Use <code>secondary-sid</code> === |
Quick Tips
imdbpy search movie "12 Monkeys"
python ../../util/test.py 0114746 > 12_Monkeys.json
Image Stabilization
FFMPEG
ffmpeg -i input.mp4 -vf vidstabdetect=shakiness=10:accuracy=15 -f null -
ffmpeg -i input.mp4 -vf vidstabtransform=smoothing=30:zoom=0 output.mp4
First command generates the convolution file, second command applies it.
Remove Subtitles
ffmpeg -i series_launch_english.mp4 -c copy -sn series_launch_english_nosubs.mp4
See Also: https://start.duckduckgo.com/?q=Advanced+SubStation+Alpha&ia=web
FFMpeg
Concat
cat > list.txt
file 'file1.mkv'
file 'file2.mkv'
^d
ffmpeg -f concat -safe 0 -i list.txt -map 0 -c copy output.mkv
or
ffmpeg -f concat -safe 0 -i list.txt \
-map 0:v -map 0:a -map 0:s -map 1:v -map 1:a -map 1:s \
-c copy output.mkv
Resize
Scale, Match Vertical to Suit 720
ffmpeg -i input.avi -filter:v scale=720:-1 -c:a copy output.mkv
Time
ffmpeg -i foo.avi -ss 01:23:45 -to 02:34:56 out.avi
Players
MPV
Prefer French audio:
$ mpv ./Futurama-S0[123]*mkv --alang=fr,fre,en --loop-playlist
Use two sets of subtitles:
$ mpv kaamelott_book_1_volume_2.webm --sid=1 --secondary-sid=2
Specify a subtitle file and run two sets of subtitles:
$ mpv kaamelott_book_1_volume_1.webm --sub-file=kaamelott_book_1_volume_1.en-GB.vtt --sid=1 --secondary-sid=2
Subtitle Processing
Embed .vtt into .mkv
ffmpeg -i input.mkv -i subtitles.vtt -c:v copy -c:a copy -c:s mov_text -map 0 -map 1 -metadata:s:s:0 language=fre output.mkv
ffmpeg -i subtitles.vtt subtitles.srt
ffmpeg -i input.mkv -i subtitles.srt -c:v copy -c:a copy -c:s srt -map 0 -map 1 -metadata:s:s:0 language=fre output.mkv
Dual Subtitles
Option 1: Use secondary-sid
mpv has a secondary-sid option, which lets you specify a second subtitle track to render alongside the primary one.
For example:
Where:
--sid=1 → the main subtitle track (e.g., English)
--secondary-sid=2 → the secondary subtitle track (e.g., French)
You can check the track IDs by running:
or just mpv video.mkv and press j to cycle through tracks and note their IDs.
Option 2: External subtitle files
If you have separate .srt or .vtt files for English and French:
You can also use .vtt files this way.
Option 3: Config file
If you often want this behavior, add to your ~/.config/mpv/mpv.conf:
You may need to adjust the numbers (sid) to match your preferred language tracks.
More Options
You are correct: in mpv 0.35.1, there is support for --secondary-sid (to select a second subtitle track already present in the media), but there is no option called --secondary-sub-file.
This is because mpv’s “secondary subtitle” system only applies to subtitle streams already loaded, either from the container or from a single external subtitle file loaded as primary.
What works:
If your video already contains both English and French subtitle tracks:
You can enable them both like this:
This renders both subtitle tracks simultaneously. They will stack in the same position unless you adjust one of them with options like sub-pos or sub-margin-y.
If you have two separate external subtitle files (.srt or .vtt):
By default, mpv will only load one external subtitle file, even if you specify multiple --sub-file arguments — it ignores the rest.
Workarounds:
- Mux both subtitle files into the video container (e.g.,
.mkv) Use mkvmerge:
- This displays both lines in one cue.
- Use an mpv Lua script to load two external subtitle files. There are community Lua scripts that let you load and display two external subtitles, one at the top and one at the bottom. See the mpv Lua script resources page: https://mpv.io/resources/
Summary:
--secondary-sub-file is not implemented.
--secondary-sid works, but only with embedded tracks.
- For external files: either mux them into the video file, combine them manually, or use a Lua script.
If you’d like, I can help you:
- Write a shell script to mux
.srt files into .mkv automatically.
- Write a minimal Lua script to load and render two
.srt files in mpv.
- Then you can use
--sid and --secondary-sid as above.
- Manually combine them into one subtitle file. Example:
Voice Acting
- 10 Voice Tones: https://old.reddit.com/r/TikTokCringe/comments/1at3n7a/voiceover_actor_explains10_tones_used_during_reads/
- "im an audio for video engineer, im the person directly communicating with the voice actor to make sure the producer is happy during recording, and it really is wild the amount of times they give what is a really over the top read from their point of view, and we have to prop then up to get them to go even bigger and more exaggerated. It feels unnatural, and bizarre, but it plays well in a VO"
- "It's like that for stage plays and performances. a persons delivery really flattens out the farther it travels so you gotta make it over-the-top"