/tech/ - Technology

Technology & Computing


New Reply
Name
×
Sage
Subject
Message
Files Max 5 files32MB total
Tegaki
Password
[New Reply]


Putin's given us the boot! Read about it here: https://zzzchan.xyz/news.html#66208b6a8fca3aefee4bf211


7d74793bc85116e57152ce564d2d0256e6bd4d98023fbe44899bbedae9ae7e81.png
[Hide] (133.3KB, 474x266)
I was looking through the video editing thread on /v/ and figured it would be appropriate to have something similar here now that /tech/ exists. Except I think it would be ideal if the focus was on free software solutions, and also encompassing a broader spectrum of content rather than just videos.

In this thread give tips and ask questions about image editing, video editing, encoding, and anything else you think might be relevant for creating content.

Recommended Software
Video Editors
>Shotcut
https://www.shotcut.org/
>Kdenlive
https://kdenlive.org/
Recording & Streaming
>OBS (Open Broadcaster Software)
https://obsproject.com/
Audio
>Audacity
https://www.audacityteam.org/
Image Editing
>GIMP
https://www.gimp.org/
>Krita
https://krita.org/
General Tools
>FFmpeg (Encoding)
https://ffmpeg.org/
>HandBrake (FFmpeg GUI)
https://handbrake.fr/
>youtube-dl (Downloading video files from virtually any site)
https://youtube-dl.org/
Replies: >>130 >>237
Let me mention gallery-dl, which is an extremely useful tool for gathering large volumes of images and other media from most online art gallery places.  It even takes Nitter/Twitter URLs, although the default output file paths are weird.  You can find it easily with a search, either on Github or the Python file hosting community.

>shotcut
My copy of Vegas is getting kind of old, so I figured I'd give it a shot.  It's pretty lean and smooth, which I like, but every time I jump to a different frame in the timeline it plays the audio at that specific point.  Is there any way to disable this without disabling the audio from the timeline itself?  I'm on the wangblows version if that makes a difference.
Replies: >>973 >>1005
>>128 (OP) 
>no Blender
unironically a good video editor, what other video editor allows you to render a spinning 3d cube on top of a video?

Also OBS decided to fug my shit up, might have to look into logs if it has any. So I had to fall back to the chad ffmpeg
[code]
ffmpeg \
	-f pulse -ac 2 -i default \
	-r 60 \
	-f x11grab $(slop -l -n 1 -f '-video_size %wx%h -i +%x,%y') \
	-b:v 4M \
	-b:a 80k \
	~/"$(date +%Y-%m-%d_%H-%M-%S)".mp4
[/code]
As long as you don't move the window around, it should be ok but isn't as good as Windows' gdigrab feature

I would also recommend Aegisub, absolute god tier subtitle editor - pretty sure most dedicated fansubbers use this program.
Replies: >>1005
Is there an equivalent of WebM for Retards on Linux? It doesn't work under wine and I don't want to put in 100 different modifiers in a terminal just to make a file under 16MB or whatever the limit is for my Estonian bus enthusiast forums. A GUI is simpler for all the options it has. QWinFF doesn't have the features I want, most specifically how it dynamically changes commands to get it under a certain filesize.
Replies: >>145 >>146 >>1005
>>143
HandBrake used to let you target file size in an earlier version but they removed it for some reason. You could maybe try using that version but it's quite old, it's 0.9.5. A more clean solution is probably some bash scripting, but that's out of my depth.
https://stackoverflow.com/questions/29082422/ffmpeg-video-compression-specific-file-size
The target file size feature in webm for retards never worked properly for me anyways. These days I just do the bitrate calculations manually. Target file size / duration. If you're using handbrake you might need to account for the audio bitrate as well. Hopefully some other anon has a better more retard proof solution up their sleeves. I have almost no clue what I'm talking about
>>143
> I don't want to put in 100 different modifiers in a terminal just to make a file under 16MB or whatever the limit is
It's 32MB here (literally read the post form, newfag), but are you really making videos that are so complex?  My default use case for encoding a webm or MP4 is like:
ffmpeg -i input.mp4 -b:v video_bitrate -b:a audio_bitrate -s resolution -fs 16MB -f webm output.webmwhich is hardly difficult to modify with a bit of trial and error, since the only things I ever really change are the video bitrate and the resolution.  I imagine you must be making something more complicated.
Replies: >>147
>>146
Unless I'm mistaken -fs just cuts off the video when it reaches the file size.
Is there a realistic replacement for GIMP at this point? Every update makes the UI worse and tools worse. It's become difficult to use these days.
>>223
Try Krita. It's targeted at mostly artfags, but it can also be used as an image manipulation program.
>>128 (OP) 
I have some txt files that i need to convert to mp4, any reliable program to do that?
How do you calculate estimated webm size, to help you pick bitrates without completely blind trial and error? I remember there was some method to do it.
Replies: >>263 >>1005
1470505874679.webm
[Hide] (194KB, 640x360, 00:05)
>too many packets buffered for output stream 0:1, conversion failed!
On my first day too.
>>238
I don't know that much about ffmpeg and conversion, but the only format that is reliably calculated is constant bitrate. As simple as taking the bitrate and multiplying it by seconds, just keep in mind that it's measured in bits. However, some sources say that constant rate factor is better, since it gives a less blocky picture during sudden movements as opposed to CBR. With CRF, there is no size estimation per se, you just specify a desired size and 2-pass encoding picks a CRF value to match that. I've seen a manual method mentioned, where it takes 5-10% of overall frames in the video and does a one pass encode with the value you specified. It's supposed to be fast enough to estimate size and play around with the settings, but I have no idea if it works.
On a side note, does anybody have that ffmpeg image guide that circulated around boards for video posting?
webm_guide.png
[Hide] (1.1MB, 2400x3420)
How did no one post this.
Replies: >>502 >>505
>>397
thank you so much i was looking for this
Replies: >>505
>>502
When I make webms, I usually consult >>397 and the presets on https://developers.google.com/media/vp9/settings/vod\ .
>>223
it only works on windows but I like paint.net a lot
>>223
Krita is pretty good. The UI is a little weird but nowhere near as janky as GIMP's, and it has a few useful features that GIMP never had (like an actually usable color-to-alpha tool, or rectangles).
How can I split a single FLAC file into multiple FLAC files with the cue file, preferably with ffmpeg?
Replies: >>1005
I like Openshot for video editing, although I think I had problems with it crashing when I used it on Linux.
Replies: >>1005
>>129
>gallery-dl
Thanks, been looking for something like this and was worried I'd have to write something myself. Anything you know of for hashing large numbers of images and moving unique ones?
ruski_boorder.jpg
[Hide] (168.7KB, 1024x768)
How does blender's video editing mode compare to kdenlives and such?
Audacity a shit, any alternatives? Not looking for anything fancy just very basic audio editing and maybe a few effects.

>>129
>gallery-dl
Thanks for this. I have a question; when downloading from tumblr, does it download the original uncompressed images or only the publicly available 1280px versions?
>Is there any way to disable this
Settings -> (uncheck) Scrub audio

>>130
>Also OBS decided to fug my shit up
What happened? I don't use it much but it runs pretty smoothly, granted I only use the internal ffmpeg encoder and never the stock one.
>ffmpeg
I already managed to capture application audio using it but there's always a delay of a few seconds and the audio sometimes gets choppy. Ironically I don't have that problem with OBS.

>>143
Use webm.py: https://github.com/Kagami/webm.py it's a small wrapper for ffmpeg with very sane encode settings that I've backported into my own vanilla ffmpeg scripts, it's that good.
To get a 16MB video you just do webm -i input.mp4 -l 16

>>223
Disable tool grouping and rearrange the tools any way you want, that should fix most/all UI woes. Alternatively downgrade to 2.8.22: https://download.gimp.org/mirror/pub/gimp/v2.8/windows/

>>238
>How do you calculate estimated webm size
Exact formula is covered here: https://trac.ffmpeg.org/wiki/Encode/H.264#twopass

>>698
On windows you can use CUETools, on linux you can use flacon (needs flac to be installed). This is the easiest, graphical way.
Otherwise google found this for ffmpeg: https://gist.github.com/Theldus/bf7b9fd7370f4ea4c57da5cb596e9da9

>>952
It crashes on windows too, no reason to use it when Shotcut exists.
Replies: >>1019
>>1005
>what happened
obs works on my machine now
prog.png
[Hide] (148.4KB, 954x524)
outberg.gif
[Hide] (97.2KB, 400x225)
Any ffmpeg experts that can help me? I'm trying to create a program that makes creating webms and gifs easier, think of it like 'Webm for Retards' 2.0.

The idea is that you can accurately pick the time/frame that you want and see a thumbnail of the current time, but my problem is that I don't know how to accurately measure time, specifically frame-by-frame.

To give a more concrete problem: when the video is seeked to a specific HH:MM:SS time, I want to be able to see the frame number and/or press a key to move to the next frame. How could I accomplish this? Is there some trick I could use to convert a timestamp into a frame number and vice-versa?
Replies: >>1028 >>1045 >>1181
Oh and I can get info with ffprobe as well, in case that has a way.
>>1026
Cool, not an expert dude but ffmpeg has fuckeasy any video to gif creation commands all you have to do simplify and call it with the UI right? You can even do variable fps feasible up to 60(i dont have the commands on hand right now) and if you dont already know you can set time and cuts in ffmpeg, this only requires you to watch the given video and memorize numbers to figure what you want to cut which you will try and eliminate with your GUI.

>To give a more concrete problem: when the video is seeked to a specific HH:MM:SS time, I want to be able to see the frame number and/or press a key to move to the next frame. How could I accomplish this? Is there some trick I could use to convert a timestamp into a frame number and vice-versa?
I don't know but read ffmpeg source code to get inspired and maybe you can rip it off, I know it has neat stuff like frame counters of a given input (on conversion.)
out.gif
[Hide] (373.2KB, 400x225)
dither.png
[Hide] (122.2KB, 1200x675)
How do I improve the quality of gifs made with ffmpeg? Mostly talking about dithering and the color palette. I tried searching but can't figure out how to apply the shit I find. Pics related, it bleeds dithering out of it's ass even though the image is full of flat solid colors.

The command used for pic related was:
ffmpeg  -i "/path/to/file.mkv"  -ss starttime  -t duration  -filter:v scale=w=400:h=400:force_original_aspect_ratio=decrease  -y  "path/to/out.gif"

How can I modify it to remove dithering, limit the number of colors to somewhere between 32-128, or make the color palette less retarded? I can't figure out the answer to any one of those questions.
Replies: >>1045
rain.png
[Hide] (37.8KB, 320x240)
rain-no.png
[Hide] (4.3KB, 320x240)
rain-pz.png
[Hide] (7.7KB, 320x240)
rain-fs.png
[Hide] (12KB, 320x240)
rain-fsr.png
[Hide] (12KB, 320x240)
>>1026
The way Shotcut does it is represents time as HH:MM:SS:FF where FF is the frame number in a given second SS. For example a 60 FPS video would have FF values from 00 to 59 for every second... There was an alternative method from what I recall where you could just input HH:MM:SS.MS where MS is milliseconds and it automatically converts it to the first format... You could look into implementing that system.

>>1041
The dithering algorithm in your picture is called "Positioned" and it's what MS Paint uses lol, you're better off using an algorithm called "Floyd-Steinberg". Pics related (in order) show the difference between the original image, no dithering, positioned dithering, Floyd-Steinberg (normal) and Floyd-Steinberg (reduced color bleeding).
Now I don't know how to tune ffmpeg for creating GIFs however here is a very simple way to do it using GIMP:
>export your video as PNG/JPEG frames using ffmpeg (resize if needed)
>make a new file in GIMP with the dimensions of the video and delete the default Background layer
>drag all frames into the GIMP window and they will be inserted on top of each other in a stack way (from bottom to top 1,2,3...etc)
<save the file as XCF (backup)
>click Image -> Mode -> Indexed
>- choose the maximum number of colors (128-256 is good)
>- check "Remove unused"
>- uncheck both "dithering transparency" and "dithering text"
>- choose Floyd-Steinberg dithering or F-S (reduced color bleeding) and click convert
>click File -> Export as and type filename.gif then go from there
Replies: >>1046 >>1047
>>1045
Forgot to say, before you export go to
>Filters -> Animation -> Optimize (for GIF) or (Difference) it doesn't matter much)
to reduce file size as much as possible.
>>1045
>represents time as HH:MM:SS:FF where FF is the frame number in a given second SS
That won't make sense for videos with 29.97 fps for example. I also don't want to approximate the duration of frames in milliseconds, because that may lead to frames being skipped when you jump forward frame-by-frame, supposedly the frames don't always have the same duration.

For now I'm jumping forward 10 milliseconds when you press the arrow keys, and 100 if you hold shift. It's good enough for finding the frame you want, but it's obviously not ideal.

>dithering
I need it for the aforementioned program, so Gimp is not an option. Exporting the animation as frames is something I didn't consider though, I suppose I could have that option so they can be used in a different program to finish the job, maybe even use imagemagick to create the final animation automagickally.
Replies: >>1048
>>1047
>That won't make sense for videos with 29.97 fps for example.
You can probably do HH:MM:SS:FF.FF who knows. Anyway vanilla ffmpeg supports HH:MM:SS.MSS where MSS is milliseconds so you can just go with that.
>dithering
http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
See the color mapping section.
>> 1048
>http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
>See the color mapping section.
This is exactly the kind of shit that I don't know how to apply. I get how to generate the palette since all I need to do is add ",palettegen" to the filters, but I have no idea how to then use it because all the examples use -filter_complex with seemingly completely different syntax and the ffmpeg documentation doesn't tell me anything about what the difference is.
Replies: >>1050
>>1049
I think this is a two-pass process: first pass generates the palette and stores it in a temporary location, then second pass uses that palette to encode. Check the "usage" section in the link.
Replies: >>1051
shit_bayer.gif
[Hide] (515.4KB, 400x225)
bloated_sierra2.gif
[Hide] (6.7MB, 400x225)
>>1050
I know it is, but the syntax suddenly goes from a relatively understandable "s1=xxx,s2=zzz" style to having brackets and semicolons in a nonsensical pattern.

Anyway I did get it to work but the results are worse than they were at the beginning. It generates a stupid palette that completely misses certain colors, the dithering becomes incredibly noisy and bloats the filesize, and the only dithering methods that even use the generated palette remotely correctly in the first place have the most noise and create a file that's literally 20 times larger than the non-paletted one. Even if I disable dithering, the filesize is still about 12% bigger despite looking like complete trash.

I think ffmpeg is a lost cause and I just need to use a different program to make a gif from extracted frames or something.
Replies: >>1054
source.mp4
[Hide] (61.7KB, 608x352, 00:00)
output.gif
[Hide] (491.2KB, 400x225)
And here's an example of it missing colors.
Replies: >>1054
test.gif
[Hide] (1MB, 400x225)
Can't believe I spent an entire day fighting with that shit. Just exporting frames and putting them together in imagemagick immediately gives great results. Only problem is that it's having a stroke and jumping to the first frame over and over.
Replies: >>1054 >>1056 >>1060
>>1051
>>1052
>>1053
JUST
Look, I don't mean to discourage you but I think you have a long way to go in understanding how ffmpeg works to begin with before even attempting to leverage it with an automated script, let alone your own tool.
You need to google more until you get to a point where you already know how to do everything through commands, and only need a simple program to call these commands.
Replies: >>1057
By the way if imagemagick isn't cutting it try graphicsmagick.
>>1053
the truth is thats actually the best gif itt
Replies: >>1057
frames.png
[Hide] (401.8KB, 1612x1100)
>>1054
>you have a long way to go in understanding how ffmpeg works to begin with before even attempting to leverage it with an automated script, let alone your own tool
I'm already doing it though. The problem is that I've googled everything I'm capable of and have exhausted my ability to get any more out of it. ffmpeg just doesn't seem to be capable of exporting good gif animations period.

Meanwhile imagemagick gives a glitchy result even though I literally copypasted the exact command someone mentioned, there's nothing esoteric about it, just input frames output gif.
magick frame_*.png output.gif
The command I used for the previous gif was a bit different but it's glitched no matter what. There's nothing wrong about the frames either, pic related.

>>1056
Well yeah, that's the first gif made with imagemagick instead of ffmpeg.
Replies: >>1058 >>1113
>>1057
That command was written for linux, take note of the * implying a wildcard. Windows doesn't work that way.
Replies: >>1059
>>1058
Well it successfully finds the frames anyway. It's not a call to windows, it's something I'm giving as an input to ffmpeg.
>>1053
>Well yeah, that's the first gif made with imagemagick instead of ffmpeg.
I mean in that it's terrorizingly glitching
out.gif
[Hide] (525.7KB, 400x225)
What the fuck, all I had to do was rename the files to frame_001 etc instead of frame_1. I can kind of guess why, but I don't understand why it only jumps to the first frame every time instead of repeating frame_1, frame_10, frame_11 or similar pattern. Maybe they were too similar so they got merged into a single frame which is why I only saw a single incorrect frame at a time in gimp.
Replies: >>1113
>>1062
Forgot, but here's the commands in case anyone wants a way to make gifs.

First, use ffmpeg to create a list of images from the video frames (as seen in >>1057 )
ffmpeg   -ss 00:00:00.000   -i INPUTFILE   -t 00:00:00.000   -filter:v scale=w=400:h=400:force_original_aspect_ratio=decrease  OUTPUTPATH/frame_%04d.png
Put the start time after -ss and the duration after -t. w=400:h=400 is the maximum width and height of the gif you want, around 400-600 is good for gifs. Replace INPUTFILE and OUTPUTPATH with whatever you want, I recommend outputting to an empty folder since it creates tons of files.

If you want to crop it, you can put it before the scale:
-filter:v crop=WIDTH:HEIGHT:X:Y,scale=w=...
You can also crop in the next step, but I don't have the command for that.

Next, use imagemagick to combine the frames into an optimized gif animation:
magick   -delay 1xFRAMERATE   INPUTPATH/frame_*.png   -fuzz 2%   -layers OptimizeFrame -layers OptimizeTransparency   +fuzz   OUTPUTFILE.gif
FRAMERATE must be the framerate of the video, for example 1x30 if the video is 30fps, see below. Again replace INPUTPATH and OUTPUTFILE with whatever. You can increase the fuzz value to improve filesize (it ignores pixels whose color changes less than 2%), but it may create artifacts, 1-3% seems usually fine.

You can find out the fps of a video by using ffprobe: ffprobe   -hide_banner   -i INPUTFILE there should be "xx fps" somewhere. If it's something like 29.97, then it's fine to just pretend it's 30.
Is there a way to get ffprobe's functionality with ffmpeg?

I'm trying to put together >>1026 and want to make a separate version with ffmpeg included with it so you don't have to install it separately, but I don't want to include both ffmpeg and ffprobe because they're 64MB each. Their file sizes are almost identical so I thought maybe ffmpeg has a command or something that makes it act like ffprobe.
Replies: >>1184 >>1206
>>1181
My ffprobe is only about 150K. You can bundle a dynamically linked version. Or write a C wrapper around it's library in your program(which should be what you are doing anyway).
Replies: >>1188
>>1184
I have no idea how to use it as a library. Literally every single library except stb_* is incompatible with my environment, and I'm not going to start digging for macros and types within the source code so I could nigger rig a dll. I would be much happier and my program would be much better if I was able to use it that way though.
Replies: >>1191
>>1188
>developing
>on losedows
NGMI
Replies: >>1195 >>1206 >>1504
Untitled.png
[Hide] (16.8KB, 783x213)
>>1191
Replies: >>1200 >>1486 >>1504
>>1195
Maybe forums with bigger market share are more suitable for you.
Replies: >>1500 >>1504
>>1181
Look into libffmpeg, I haven't personally used it but a lot of programs do. Pretty sure the ffprobe functionality is included, besides you can compile with only the codecs you want in order to shrink size.
And seconding what >>1191 said, you're better off programming on linux, even when targeting windows. Make a linux VM and develop on it, should be much easier.
Test
8bbd150da485805ea726daa3168ba1ad7a5a2374b1d443982d5f6c1260343c5c.mp4
[Hide] (2.9MB, 960x720, 03:08)
1.webm
[Hide] (3MB, 960x720, 03:09)
I adapted ffmpeg command for music  webm (vp8) to mp4 (h264) and it worked great everywhere but in mpv, for some reason .mp4 version makes mpv crash if I try skipping 5 seconds with arrow keys. Any ideas why?

Original command. 
ffmpeg -i audio -r 1 -loop 1 -i pic.jpg -c:v libvpx -crf 20 -b:v 0 -g 9999 -sn -c:a libopus -b:a 96k -ac 2 -metadata title="title" -shortest -auto-alt-ref 0 -f webm out.webm 
Adapted command for .mp4
ffmpeg -ss 0 -i audio -r 1 -loop 1 -i pic.jpg -crf 20 -b:v 0 -g 9999 -sn -t 3:08 -pix_fmt yuv420p -c:a libopus -b:a 96k -ac 2 -metadata title="title" -shortest -auto-alt-ref 0 -f mp4 out.mp4 
Is code tag broken?
Replies: >>1505 >>1544
>>1195
What are you even doing in this website? You don't belong here.
Replies: >>1500 >>1504
>>1486
>>1200
The sheer crude mentality of linux users. Always complain why nobody uses and if somebody uses it they lash out like death was tomorrow.
Replies: >>1501 >>1504
>>1500
The sheer crude mentality of windows users. Always complain why it is so shitty and if somebody suggests an alternative they lash out like death was tomorrow.
Replies: >>1504 >>1507
>>1191 >>1195 >>1200
>>1486 >>1501 >>1500
The fact is that all your OS's are shit and if you say otherwise you are delusional nigger cattle with stockholm syndrome. Wake up.
32e9d76ec566e8195cd98425467fed3ec6bf6e18892b13cf5fe1c630f33bbbf5.jpg
[Hide] (191.3KB, 775x800)
>>1481
Thank you for sharing this.
>>1501
Speaking of that, now that Linux got shilled plenty, it's also common in the Linux world.

All the university-raised sysadmins, (((RedHat))) software users, Desktop Environment streetshitters, trannies, and other assorted trash, do that shit all the time.
This has always got me the best results easily: https://github.com/HelpSeeker/Restricted-WebM

This is a piece of shit but GUI opts for when you're lazy: https://github.com/Kagami/boram

And for some fuckery stuff: https://gitlab.com/Baut/imgboardtools
Replies: >>1533
>>1532
And here's a couple of .bashrc functions

possible language: bash, relevance: 44
# Spoof webm duration
spooflen() {
	declare -r filen=${1?No input given}
	declare vidlen
	[[ -f ${filen} ]] || { printf '"%q" - not a file.\n' "${filen}" >&2; return 1; }
	vidlen=$(ffprobe -i "${filen}" -show_entries format=duration -v quiet -of csv="p=0")
	vidlen=${vidlen%%.*}
	# 1ms
# 	LC_ALL=C sed 's/\x44\x89\x88[\x00-\xFF]\{4\}/\x44\x89\x88\x3F\xF0\x00\x00/g' "${filen}" > "${filen%.*}_(Len_${vidlen}s).webm"
	# 2 min
# 	LC_ALL=C sed 's/\x44\x89\x88[\x00-\xFF]\{4\}/\x44\x89\x88\x40\xFD\x4C\x00/g' "${filen}" > "${filen%.*}_(Len_${vidlen}s).webm"
	# 5 min
	LC_ALL=C sed 's/\x44\x89\x88[\x00-\xFF]\{4\}/\x44\x89\x88\x41\x12\x4F\x80/g' "${filen}" > "${filen%.*}_(Len_${vidlen}s).webm"
}

# Split video into parts of n seconds per segment
splitvid() {
	declare -r filen=${1?No input given}
	declare -ri vidlen=${2:-600}
	[[ -f ${filen} ]] || { printf '"%q" - not a file.\n' "${filen}" >&2; return 1; }
	mkdir -p split-vids/
	ffmpeg -i "${filen}" -sn -acodec copy -f segment -segment_time "${vidlen}" -vcodec copy -reset_timestamps 1 -map 0 -segment_start_number 1 split-vids/"${filen%.*}_Part%d.${filen##*.}"
}
>>1481
here is this mess automated, enjoy 

` bash
#!/bin/sh

titl="$(youtube-dl $1 --get-filename -o '%(title)s_%(id)s' --restrict-filenames)"
length="$(youtube-dl $1 --get-duration)"
filename="$(youtube-dl $1 --get-filename -o '%(title)s' --restrict-filenames)"

youtube-dl -f 251  -o - $1|ffmpeg -ss 0 -i pipe:0 -r 1 -loop 1 -i /tmp/cover.jpg  -c:v libvpx-vp9 -pix_fmt yuv420p -t $length  -crf 20 -b:v 0 -g 9999 -sn -c:a libopus -b:a 96k -ac 2 -metadata title="$titl" -shortest -auto-alt-ref 0 -f mp4 $filename.mp4
`
Yukikaze_01_sylph_(use_headphones).webm
[Hide] (5MB, 640x480, 02:04)
ffmpeg -ss XX:XX.XX -to XX:XX.XX -i sauce.mkv subtitles.ass
ffmpeg -i sauce.mkv -vf subtitles="subtitles.ass" -f yuv4mpegpipe - | aomenc --codec=av1 --webm -t X --lag-in-frames=25 --end-usage=vbr --target-bitrate=250 --auto-alt-ref=1 --tile-columns=6 --tile-rows=6 --frame-parallel=0 --row-mt=1 --min-q=0 --max-q=63 --frame-boost=1 --deltaq-mode=2 --cpu-used=4 --sharpness=7 --sb-size=128 --enable-qm=1 --qm-min=0 --qm-max=15 --kf-max-dist=9999 --enable-tpl-model=1 --enable-fwd-kf=1 -w 640 -h 480 --passes=2 --pass=X --fpf=2pass.log -o "output" -
ffmpeg -i sauce.mkv -c:a libopus -b:a 96k -af sofalizer=/path/to/HRIR.sofa audio.opus
ffmpeg -i output -i audio.opus -c copy -map 0:v:0 -map 1:a:0 -f webm "final.webm"

ffmpeg's libaom wrapper a shit! SHIT!
Replies: >>1551
>>1550
Isn't it faster for the same size to do two pass vp9 at the highest compression/quality present?
mpv-shot0130.jpg
[Hide] (103.2KB, 1280x720)
mpv-shot0129.jpg
[Hide] (108.6KB, 1280x720)
mpv-shot0128.jpg
[Hide] (106.6KB, 1280x720)
mpv-shot0127.jpg
[Hide] (97.7KB, 1280x720)
mpv-shot0126.jpg
[Hide] (84.8KB, 1280x720)
Is it possible to fix interpolated frames in video like this?
Search engines only show how to interpolate video to 60 fps.
Replies: >>1762
>>1732
May as well just remove those frames and interpolate again. If those frames got inserted every x frames, shouldn't be hard to remove them.
Something I just seemed to find out yesterday: FF (and pale moon, which has been a different browser for some time now) won't play .webm if the audio isn't 48K opus.

FFmpeg complains if I try to use libmp3lame with the .webm container, and while the browser doesn't seem to have a problem with -ac 1 (mono not stereo) or low bitrates like -b:a 42K it breaks if I use -ar 12K or even -ar 24K.

 When the audio is just some guy rambling slowly, it seems needless to have a high sample rate. and VLC, HPC-64, both play the downloaded file fine but FF says 'nope'

...is there a list somewhere, of things to do to make sure your content can be rendered by an average browser? TIA, -anon
Replies: >>1801
>>1798
>mp3
>in a webm
That won't work because the WEBM container doesn't support MP3 audio, only Opus and Vorbis audio. And Opus' sampling rate is locked at 48kHz. See:
https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers#webm
>is there a list somewhere
Yes there is:
https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_codecs#codec_details
https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Audio_codecs#codec_details
But here's an even shorter list:
  1. VP9 video + Vorbis/Opus audio in a WEBM
  or
  2. H.264 video + AAC/MP3 audio in a MP4
Anything other than these 2 combos is not guaranteed to work across browsers.
Replies: >>1804
example.webm
[Hide] (3.1MB, 640x332, 03:17)
>>1801
>And Opus' sampling rate is locked at 48kHz

1: By whom?
2: That's really dumb.

Okay, thanks. Now I know it's broken. As I said media players render opus at any sample rate FFmpeg will agree to encode it in, which seems to be 8K, 11K, 12K, 24K, and yes double that to 48K.

MP3 standbys like 22050 and 44100 don't agree with FFmpeg, so I figure that would not render correctly but... seriously? Why does it make sense to take a 22K sound and pad it with a bunch of zeroes so it could be transcoded into a format most useful for compressing for overworked network usage.
Replies: >>1806
>>1804
>1: By whom?
The Xiph.Org foundation which designed it in the first place... The answers to your questions are most probably in the specification: https://archive.ph/cEaYu#selection-1205.3-1205.22
Regardless of how the codec works, its massive quality to file size ratio alone is more than enough reason to use it in videos. You need every kilobyte you can get for storing the encoded video, so it makes sense to minimize the size of the audio as much as possible.
Replies: >>1807
>>1806
>need every kilobyte
>that's why we choose to waste data with literal non sense

That's not at all what the page you just linked to say. It lists the effective sample rates to be 8, 12, 16, 24 & 48 kilohertz.
Which means that FFmpeg & VLC are right, and whoever wrote the subroutines for this browser decided to chintz out and only include half the code.
Maybe less than that; scrolling down I read that any opus decoder can decode audio encoded to any bandwidth. By definition, then, FF and I guess Pale Moon can't render the opus audio codec.

 Now, I can kinda understand that, because I don't consider a web browser to be a media player, and I have a separate MP3 player exactly because I also don't consider my phone to be an MP3 player.

 and for as frustrated by this as I am, I obviously need to thank you for having these weblinks handy since I new about Xiph but hadn't gone looking for the codec specification because I was expecting it to talked about by more-normal people than the math nerds making lossy ways of writing down the description of the parts of sound you care about hearing.
But that page was surprisingly readable, so I'm impressed at whoever they hired to act as translator.
Replies: >>1817
warthog_44k.flac
[Hide] (17.8MB, 1400x1400, 03:22)
warthog_44k.opus
[Hide] (2.9MB, 03:22)
warthog_8k.opus
[Hide] (2.6MB, 03:22)
>>1807
>That's not at all what the page you just linked to say. It lists the effective sample rates to be 8, 12, 16, 24 & 48 kilohertz.
You are right, however I think it's impossible to encode an opus file at any rate other than 48kHz.
I just tested the official opusenc and it doesn't even let the user specify an output sample rate. See https://opus-codec.org/docs/opus-tools/opusenc.html And regardless of the input sample rate, the program always outputs at 48kHz. I tested ffmpeg as well and it, too, always outputs 48kHz opus files, regardless of the input sample rate or the -ar specified...
How exactly did you produce the 12/24kHz opus files?
>that's why we choose to waste data with literal non sense
You're talking about defaulting to 48kHz when encoding opus? If so, I disagree that data is wasted, because my tests showed a decrease in file size... If you throw a 44.1kHz flac file and a 8kHz flac file at opusenc, you'll find the output of the former to be larger than the output of the latter. Similarly, if you encode a 44.1kHz flac file using ffmpeg twice, once without -ar and once with -ar 8000, you'll get the same difference in file size. Attached are example files showing this.
>and for as frustrated by this as I am, I obviously need to thank you for having these weblinks handy
No problem, glad I could help.
Replies: >>1823
>>1817
ffmpeg always reports 48kHz for decoding opus, see https://stackoverflow.com/questions/39186282/ffmpeg-not-honoring-sample-rate-in-opus-output
Is there a way to make ffmpeg shut the fuck up? I have a video that has 800 million chapters and ffmpeg spams the fuck out of my console with them every time I touch it. I don't want to see them, but I do want to see the conversion progress and errors and the like.
Replies: >>2009
>>2007
RTFM, faggot
man ffmpeg
Regex loglevel
I've been using handbrake to re-encode video and hardcode extant subs. I'm using .mkv files and converting into mp4 files. For most of the files it has worked fine. But in two of the videos (which use PGS files for subs) the subs are shifted to the right side of the screen. They're all there but off-center and it's giving me cancer. All attempted ffmpeg solutions have failed outright (maybe I am retarded at ffmpeg, but trying to use ffmpeg to accomplish what I'm doing with handbrake just results in one sub being stuck on the screen for the whole video duration). Obviously ffmpeg won't be helpful with hardsubs. So I guess what I'm asking is - is there a way to use ffmpeg to convert a .mkv video with subtitles into a .mp4 video with hardsubs that actually works?
Replies: >>3992
>>3991
The problem should be caused by the original softsub. Are they shifted in the mkv? If so, you can either extract the subtitle and fix it, or download a working subtitle. ffmpeg + subtitles filter should work then.
Replies: >>3998
>>3992
They're normal and in the right place in the mkv when I use mpv to play it. How would I extract PGS subs to a workable file?
cute.png
[Hide] (9.2KB, 640x640)
How do I make .mp4 files streamable? So I can open them before encoding is finished.
Replies: >>4000
>>3999
They are streamable, try opening it with mpv after encoding some percent of it.
Replies: >>4003
>>4000
[ffmpeg/demuxer] mov,mp4,m4a,3gp,3g2,mj2: moov atom not found
[lavf] avformat_open_input() failed
[ffmpeg/demuxer] mov,mp4,m4a,3gp,3g2,mj2: moov atom not found
[lavf] avformat_open_input() failed
Failed to recognize file format.
Replies: >>4004
>>4003
Interesting, maybe I was encoding webm. https://stackoverflow.com/questions/16131616/how-to-create-streamable-audio-file-with-ffmpeg
First time I had problem with overhead, how do I lover or avoid it?
video:19998kB audio:7249kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 27.373976%
It's 2 hour video.
Replies: >>4049
>>4023
What codec are you using and which container? A couple searches say some format may need tweaking or another tool to do a better job.
bb452a2417f2444a3108e3762be82ce22c65564442df8e2098fa9bf076043ced.webm
[Hide] (334.2KB, 854x480, 01:26)
What codec should I use to destroy audio and video, like webm related?
>>4252
Anything with low bitrate.
>>4252
The audio codec definitely sounds like opus at <16kbps. Couldn't say for the video, but obviously try doing the same thing for mp4/webm/etc.
>>4252
Source for the video: https://invidious.snopyta.org/watch?v=U-sd4mKcOXM
Strategic_bombing_with_HRTF.webm
[Hide] (32MB, 1920x1080, 06:47)
Is there a way to convert ((( (((Dolby Atmos))) ))) metadata into something that can be encoded into a regular ol' stereo bitstream using libmysofa with an appropriate HRIR?
Proprietary standards for object-based 3D Audio disgust me.
Replies: >>4273
>>4271
No, software ((( (((atmos))) ))) decoding is not possible. The sofalizer plugin only works with decoded audio. https://github.com/mpv-player/mpv/issues/3903
If you only use the TrueHD/AC3 part of the audio, then it will work. But the atmos data is ignored.
ika_shakal.mp4
[Hide] (640.8KB, 1280x720, 01:29)
Have you also became hyper sensitive to video artifacts after you started encoding videos?
>>4252
Single pass low bitrate x264/opus.
Replies: >>4313 >>4319
>>4311
Yes.
>>4311
Yes, to encode videos I'd tweak the bitrate until I could stare at a still and only barely see the artifacts, with the idea that if it looks almost perfect on stills then it looks perfect in movement.
But I learned what to look for instinctively and now I can spot what is an artifact and what isn't more easily.
ClipboardImage.png
[Hide] (56KB, 1061x1023)
Is there any way to remove duplicate images from a PDF file? I'm making an e-magazine where some pages have the same images, but in the exported PDF each image is stored multiple times instead of just once.
I think ghostscript can achieve this but it compresses all the images and fucks up the quality, so alternative solutions are appreciated.
Replies: >>4436 >>4458
>>4435
https://itectec.com/superuser/use-ghostscript-but-tell-it-to-not-reprocess-images/
Replies: >>4437
>>4436
This doesn't solve my question in any way
Replies: >>4438
>>4437
>ghostscript can achieve this
>but it compress all the images
<a way to not compress images
>doesn't solve your question in any way
Replies: >>4443
>>4438
What's so hard to understand about
>but in the exported PDF each image is stored multiple times instead of just once
?
Replies: >>4444
>>4443
What's so hard to just add those flags to your working commandline to remove duplicates? Ghostscript can't process duplicate images with those flags?
What about adding this: -dDetectDuplicateImages
with
-dAutoFilterColorImages=false
-dAutoFilterGrayImages=false
-dColorImageFilter=/FlateEncode
-dGrayImageFilter=/FlateEncode
-dColorConversionStrategy=/LeaveColorUnchanged
-dDownsampleMonoImages=false
-dDownsampleGrayImages=false
-dDownsampleColorImages=false
Replies: >>4458
>>4444
None of these flags stop Ghostscript from compressing the images and fucking up the quality.
Read >>4435 again
>I think ghostscript can achieve this but it compresses all the images and fucks up the quality, so alternative solutions are appreciated.
Replies: >>4459
>>4458
Assuming you tried those flags and they didn't work. Another search should find you this flag:
-dPassThroughJPEGImages
Replies: >>4486
>>4459
-dPassThroughJPEGImages does absolutely nothing, same for -dDetectDuplicateImages... dColorImageFilter=/FlateEncode & -dGrayImageFilter=/FlateEncode pass through all images as-is, which is completely useless.
I will say it again: I do not want to use ghostscript, I want alternatives.
Replies: >>4489
>>4486
>alternative
Not likely to fond one. Reason why trying to get gs to work is you can't use a dumb pdf tool. Since images are embedded and referred in the doc, the tool must understand/interpret pdf content in order to compare images and clean them up. gs is probably the one.
Those flags should work, can you upload an example pdf where that didn't work? (catbox)
Replies: >>4512
>>4489
>can you upload an example pdf where that didn't work? (catbox)
Sure thing, here you go: https://files.catbox.moe/pwnz9i.zip
Replies: >>4526
>>4512
You are right. Ghostscript didn't consider those images to be the same. I wonder if that only works across pages.
I am cooking something up with PoDoJo, that is the final solution.
Replies: >>4641
Deliver on >>4526, yes this is utter shit code.
Doesn't work on pdfjam (latex) produced pdfs. But for your sample pdfs, it works.
language: c++
/* 
 * License: Public domain
 * Author: Anonymous
 * To build:
 * g++ pdfimgdedup.cpp -lpodofo -lfreetype -lfontconfig -lz -lidn -lcrypto -lssl -ljpeg -lpthread -lpng16 -ltiff -lunistring -lm -lexpat -luuid -lbz2 -ldl -lharfbuzz -o pdfimgdedup
 */
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <podofo/podofo.h>
#include <string_view>
#include <map>
#include <unordered_map>

void print_help()
{
  printf("Usage: pdfimgdedup [inputfile] [outputfile]\n\n");
}

int64_t get_number(PoDoFo::PdfMemDocument &document, PoDoFo::PdfObject *pdfobj) {
	if (pdfobj->IsNumber()) {
		return pdfobj->GetNumber();
	}
	else if (pdfobj->IsReference()) {
		return get_number(document, document.GetObjects().GetObject(pdfobj->GetReference()));
	}
	return 0;
}

class image_obj {
	public:
	int64_t height;
	int64_t width;
	int64_t length;
	std::size_t data_hash;
	PoDoFo::PdfReference ref;

	image_obj(PoDoFo::PdfMemDocument &document, PoDoFo::PdfObject &pdfobj) {
		height = get_number(document, pdfobj.GetDictionary().GetKey( PoDoFo::PdfName("Height" ) ));
		width = get_number(document, pdfobj.GetDictionary().GetKey( PoDoFo::PdfName("Width" ) ));
		length = get_number(document, pdfobj.GetDictionary().GetKey( PoDoFo::PdfName("Length" ) ));
		char*    pBuffer;
		PoDoFo::pdf_long lLen;
		pdfobj.GetStream()->GetFilteredCopy( &pBuffer, &lLen );
		data_hash = std::hash<std::string_view>()(std::string_view(pBuffer, lLen));
		ref = pdfobj.Reference();
	}
}; 

bool operator==(const image_obj& img1, const image_obj& img2) {
	return img1.height == img2.height &&
		img1.width == img2.width &&
		img1.length == img2.length &&
		img1.data_hash == img2.data_hash;
}

template<> struct std::hash<image_obj> {
	std::size_t operator()(const image_obj& img) const noexcept {
		return img.data_hash;
	}
};

int is_image (PoDoFo::PdfObject *obj) {
	if (obj->IsDictionary()) {            
		PoDoFo::PdfObject* pObjType = obj->GetDictionary().GetKey( PoDoFo::PdfName::KeyType );
		PoDoFo::PdfObject* pObjSubType = obj->GetDictionary().GetKey( PoDoFo::PdfName::KeySubtype );
		if ((pObjType && pObjType->IsName() && ( pObjType->GetName().GetName() == "XObject")) &&
		    (pObjSubType && pObjSubType->IsName() && (pObjSubType->GetName().GetName() == "Image"))) {
		    return 1;
		}
	}
	return 0;
}

void dedup_imgs (PoDoFo::PdfMemDocument &document, 
		std::map<PoDoFo::PdfReference, PoDoFo::PdfReference> &imgrefs) {
	std::unordered_map<image_obj, PoDoFo::PdfReference> images;
	std::vector<PoDoFo::PdfReference> to_delete;

	PoDoFo::TCIVecObjects it = document.GetObjects().begin();
	while (it != document.GetObjects().end()) {
		if (is_image(*it)) {
			image_obj image(document, **it);
			if (images.count(image)) {
				imgrefs.insert({image.ref, images[image]});
				to_delete.push_back(image.ref);
			}
			else {
				images.insert({image, image.ref});
			}
			document.FreeObjectMemory(*it);
		}
		++it;
	}
	for (PoDoFo::PdfReference imgref : to_delete) {
		document.GetObjects().RemoveObject(imgref);
	}
}

void dedup_imgrefs (PoDoFo::PdfMemDocument &document, 
		std::map<PoDoFo::PdfReference, PoDoFo::PdfReference> &imgrefs) {
	int nCount = document.GetPageCount();
	for (int i=0; i<nCount; i++) {
		PoDoFo::PdfPage* pPage = document.GetPage(i);
		PoDoFo::PdfObject *xobj = pPage->GetResources()->GetDictionary().GetKey(PoDoFo::PdfName("XObject"));
		if (!xobj)
			continue;

		auto xobj_it = xobj->GetDictionary().begin();
		while (xobj_it != xobj->GetDictionary().end()) {
			if (xobj_it->second->IsReference()) {
				PoDoFo::PdfReference imgref = xobj_it->second->GetReference();
				if (imgrefs.count(imgref)) {
					PoDoFo::PdfReference fromref = imgrefs.at(imgref);
					xobj->GetDictionary().AddKey(xobj_it->first, PoDoFo::PdfObject(fromref));
				}
			}
			++xobj_it;
		}
	}
}

int main( int argc, char* argv[] )
{
  char*    pszInput;
  char*    pszOutput;

  if( argc != 3 )
  {
    print_help();
    exit( -1 );
  }

  pszInput  = argv[1];
  pszOutput = argv[2];

  try {
	std::map<PoDoFo::PdfReference, PoDoFo::PdfReference> imgrefs;
	PoDoFo::PdfMemDocument document(pszInput);
  	dedup_imgs(document, imgrefs);
	dedup_imgrefs(document, imgrefs);
	PoDoFo::PdfObject trailer(*(document.GetTrailer()));
	PoDoFo::PdfWriter writer( &(document.GetObjects()), &trailer);
	writer.SetWriteMode(PoDoFo::ePdfWriteMode_Clean);
	writer.Write(pszOutput);
  } catch( PoDoFo::PdfError & e ) {
      fprintf( stderr, "Error: An error %i ocurred during processing the pdf file.\n", e.GetError() );
      e.PrintErrorMsg();
      return e.GetError();
  }

  return 0;
}
Replies: >>4642 >>4652
>>4641
Evaluation:
$ ls -lh Test_10.pdf
1.8M Test_10.pdf

$ pdfimages -list Test_10.pdf
page   num  type   width height color comp bpc  enc interp  object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
   1     0 image     800   658  rgb     3   8  image  no         5  0   335   335  168K  11%
   1     1 smask     800   658  gray    1   8  image  no         5  0   335   335 12.4K 2.4%
   1     2 image     800   658  rgb     3   8  image  no         8  0   335   335  168K  11%
   1     3 smask     800   658  gray    1   8  image  no         8  0   335   335 12.4K 2.4%
   1     4 image     800   658  rgb     3   8  image  no        11  0   335   335  168K  11%
   1     5 smask     800   658  gray    1   8  image  no        11  0   335   335 12.4K 2.4%
   1     6 image     800   658  rgb     3   8  image  no        14  0   335   335  168K  11%
   1     7 smask     800   658  gray    1   8  image  no        14  0   335   335 12.4K 2.4%
   1     8 image     800   658  rgb     3   8  image  no        17  0   335   335  168K  11%
   1     9 smask     800   658  gray    1   8  image  no        17  0   335   335 12.4K 2.4%
   1    10 image     800   658  rgb     3   8  image  no        20  0   335   335  168K  11%
   1    11 smask     800   658  gray    1   8  image  no        20  0   335   335 12.4K 2.4%
   1    12 image     800   658  rgb     3   8  image  no        23  0   335   335  168K  11%
   1    13 smask     800   658  gray    1   8  image  no        23  0   335   335 12.4K 2.4%
   1    14 image     800   658  rgb     3   8  image  no        26  0   335   335  168K  11%
   1    15 smask     800   658  gray    1   8  image  no        26  0   335   335 12.4K 2.4%
   1    16 image     800   658  rgb     3   8  image  no        29  0   335   335  168K  11%
   1    17 smask     800   658  gray    1   8  image  no        29  0   335   335 12.4K 2.4%
   1    18 image     800   658  rgb     3   8  image  no        32  0   335   335  168K  11%
   1    19 smask     800   658  gray    1   8  image  no        32  0   335   335 12.4K 2.4%

$ ./pdfimgdedup Test_10.pdf test.pdf
<</ID[<66C8C1BDADAA772C4D5F07BA1C194374><66C8C1BDADAA772C4D5F07BA1C194374>]/Info 2 0 R/Root 1 0 R/Size 38>>

$ ls -lh test.pdf
183K test.pdf

$  pdfimages -list test.pdf
page   num  type   width height color comp bpc  enc interp  object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
   1     0 image     800   658  rgb     3   8  image  no         5  0   335   335  168K  11%
   1     1 smask     800   658  gray    1   8  image  no         5  0   335   335 12.4K 2.4%
   1     2 image     800   658  rgb     3   8  image  no         5  0   335   335  168K  11%
   1     3 smask     800   658  gray    1   8  image  no         5  0   335   335 12.4K 2.4%
   1     4 image     800   658  rgb     3   8  image  no         5  0   335   335  168K  11%
   1     5 smask     800   658  gray    1   8  image  no         5  0   335   335 12.4K 2.4%
   1     6 image     800   658  rgb     3   8  image  no         5  0   335   335  168K  11%
   1     7 smask     800   658  gray    1   8  image  no         5  0   335   335 12.4K 2.4%
   1     8 image     800   658  rgb     3   8  image  no         5  0   335   335  168K  11%
   1     9 smask     800   658  gray    1   8  image  no         5  0   335   335 12.4K 2.4%
   1    10 image     800   658  rgb     3   8  image  no         5  0   335   335  168K  11%
   1    11 smask     800   658  gray    1   8  image  no         5  0   335   335 12.4K 2.4%
   1    12 image     800   658  rgb     3   8  image  no         5  0   335   335  168K  11%
   1    13 smask     800   658  gray    1   8  image  no         5  0   335   335 12.4K 2.4%
   1    14 image     800   658  rgb     3   8  image  no         5  0   335   335  168K  11%
   1    15 smask     800   658  gray    1   8  image  no         5  0   335   335 12.4K 2.4%
   1    16 image     800   658  rgb     3   8  image  no         5  0   335   335  168K  11%
   1    17 smask     800   658  gray    1   8  image  no         5  0   335   335 12.4K 2.4%
   1    18 image     800   658  rgb     3   8  image  no         5  0   335   335  168K  11%
   1    19 smask     800   658  gray    1   8  image  no         5  0   335   335 12.4K 2.4%
ClipboardImage.png
[Hide] (71.4KB, 441x720)
>>4641
You actually came through, thank you so much! I just tested your program and it works across pages, too. You did an amazing job anon.
I ran the program on a large pdf ( https://files.catbox.moe/bnsbxg.zip ) and it printed me this warning:
WARNING: There are more objects (1152) in this XRef table than specified in the size key of the trailer directory (1044)!
<</ID[(�p�c
but seems to have compressed successfully. Should I be worried?
Replies: >>4653 >>4673
>>4652
I wouldn't as long as I keep the original file. If it opens and prints then it's good. Check pdfimages if something went wrong.
Replies: >>4654 >>4658
>>4653
Just checked, there may be a problem. The program doesn't handle XObject Forms. One of your images were referred to from Forms. The dedup_imgref function doesn't work on those. I may update it when I am free.
If you are curious, here is a section you can add to your ezine.
>be me
>fuck ghostscript not doing what it should
>look up pdf library
>imma hack together python shit
>no python library really deal with this
>fuck python
>found pajeet lang pdf library, fuck java, never taking it
>podofo looks nice
>fuck it doesn't actually parse objects, just abstracting some of it (because there are many ways a pdf can write its shit out and looks the same, see podofotxtextract)
>fucking screw ((( (((Adobe))) )))
>analyze how images are stored
>make plans:
>plan a: replace image xobjects with a reference. Not going to work, XObject only have image, forms and ps
>plan b: delete image xobjects, replace each xobject calls. Could work, but requires parsing Pdf content stream
>no fucking way to do it easily, feeling blackpilled
>look around pdf files, found per page xobject table
>lightbulb.jpg
>plan c: delete image xobjects, replace each xobject reference from resource table
>furiously type shit out, got hit by a thousand bugs
>try on pdf made by pdfjam, doesn't work
>found out pdflatex/pdfjam store pages in XObject Forms
>fuck it, I am shipping it out
That's why it doesn't support forms yet.
Replies: >>4658 >>5097
ClipboardImage.png
[Hide] (1.6MB, 1920x1039)
ClipboardImage.png
[Hide] (1.8MB, 1920x1039)
>>4653
>Check pdfimages if something went wrong.
Actually something did go wrong, see 1st pic related (right page). 2nd pic related is correct, I think it may have something to with soft shadows.

>>4654
>The program doesn't handle XObject Forms.
I have no idea what that is ¯\_(ツ)_/¯
>I may update it when I am free.
If you want to, sure, it would be very appreciated. No obligation though.
>If you are curious, here is a section you can add to your ezine.
Kek alright, I'll look into it.
Replies: >>4670 >>4673
>>4658
Itchy, got to finish what I started.
language: c++
/* 
 * License: Public domain
 * Author: Anonymous
 * To build:
 * g++ pdfimgdedup.cpp -lpodofo -lfreetype -lfontconfig -lz -lidn -lcrypto -lssl -ljpeg -lpthread -lpng16 -ltiff -lunistring -lm -lexpat -luuid -lbz2 -ldl -lharfbuzz -o pdfimgdedup
 *
 * Changelog:
 * Image reference are now replaced in images masks and XObject forms
 */
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <podofo/podofo.h>
#include <string_view>
#include <map>
#include <unordered_map>

void print_help()
{
  printf("Usage: podofotxtextract [inputfile] [outputfile]\n\n");
}

PoDoFo::PdfObject *deref_object (PoDoFo::PdfMemDocument &document, PoDoFo::PdfObject *pdfobj) {
	if (pdfobj->IsReference()) {
		return deref_object(document, document.GetObjects().GetObject(pdfobj->GetReference()));
	}
	else {
		return pdfobj;
	}
	return pdfobj;
}

int64_t get_number(PoDoFo::PdfMemDocument &document, PoDoFo::PdfObject *pdfobj) {
	return deref_object(document, pdfobj)->GetNumber();
}

inline PoDoFo::PdfObject *obj_dir_get (PoDoFo::PdfObject *obj, 
				const std::string key) {
	return obj->GetDictionary().GetKey(PoDoFo::PdfName(key));
}


class image_obj {
	public:
	int64_t height;
	int64_t width;
	int64_t length;
	std::size_t data_hash;
	PoDoFo::PdfReference ref;

	image_obj(PoDoFo::PdfMemDocument &document, PoDoFo::PdfObject &pdfobj) {
		height = get_number(document, obj_dir_get(&pdfobj, "Height"));
		width = get_number(document, obj_dir_get(&pdfobj, "Width"));
		length = get_number(document, obj_dir_get(&pdfobj, "Length"));
		char*    pBuffer;
		PoDoFo::pdf_long lLen;
		pdfobj.GetStream()->GetFilteredCopy( &pBuffer, &lLen );
		data_hash = std::hash<std::string_view>()(std::string_view(pBuffer, lLen));
		ref = pdfobj.Reference();
	}
}; 

bool operator==(const image_obj& img1, const image_obj& img2) {
	return img1.height == img2.height &&
		img1.width == img2.width &&
		img1.length == img2.length &&
		img1.data_hash == img2.data_hash;
}

template<> struct std::hash<image_obj> {
	std::size_t operator()(const image_obj& img) const noexcept {
		return img.data_hash;
	}
};

template<> struct std::hash<PoDoFo::PdfReference> {
	std::size_t operator()(const PoDoFo::PdfReference& ref) const noexcept {
		return ref.ObjectNumber();
	}
};

int is_xobj_of (PoDoFo::PdfObject *obj, const std::string &subtype) {
	if (obj->IsDictionary()) {            
		PoDoFo::PdfObject* pObjType = obj->GetDictionary().GetKey( PoDoFo::PdfName::KeyType );
		PoDoFo::PdfObject* pObjSubType = obj->GetDictionary().GetKey( PoDoFo::PdfName::KeySubtype );
		if ((pObjType && pObjType->IsName() && ( pObjType->GetName().GetName() == "XObject")) &&
		    (pObjSubType && pObjSubType->IsName() && (pObjSubType->GetName().GetName() == subtype))) {
		    return 1;
		}
	}
	return 0;
}

int is_image (PoDoFo::PdfObject *obj) {
	return is_xobj_of(obj, "Image");
}

int is_form (PoDoFo::PdfObject *obj) {
	return is_xobj_of(obj, "Form");
}

void dedup_imgs (PoDoFo::PdfMemDocument &document, 
		std::unordered_map<PoDoFo::PdfReference, PoDoFo::PdfReference> &imgrefs) {
	std::unordered_map<image_obj, PoDoFo::PdfReference> images;

	PoDoFo::TCIVecObjects it = document.GetObjects().begin();
	while (it != document.GetObjects().end()) {
		if (is_image(*it)) {
			image_obj image(document, **it);
			if (images.count(image)) {
				imgrefs.insert({image.ref, images[image]});
			}
			else {
				images.insert({image, image.ref});
			}
			document.FreeObjectMemory(*it);
		}
		++it;
	}
}

void check_replace_ref (PoDoFo::PdfObject *xobj_dict,
			const std::pair<const PoDoFo::PdfName,PoDoFo::PdfObject*> &to_check,
			std::unordered_map<PoDoFo::PdfReference, PoDoFo::PdfReference> &imgrefs) {
	PoDoFo::PdfObject *obj = to_check.second;
	if (obj->IsReference()) {
		PoDoFo::PdfReference imgref = obj->GetReference();
		if (imgrefs.count(imgref)) {
			PoDoFo::PdfReference fromref = imgrefs.at(imgref);
			xobj_dict->GetDictionary().AddKey(to_check.first, PoDoFo::PdfObject(fromref));
		}
	}

}

void dedup_xobjs (PoDoFo::PdfMemDocument &document, 
		std::unordered_map<PoDoFo::PdfReference, PoDoFo::PdfReference> &imgrefs) {
	PoDoFo::TCIVecObjects it = document.GetObjects().begin();
	while (it != document.GetObjects().end()) {
		if (is_form(*it)) {
			PoDoFo::PdfObject *resources = obj_dir_get(*it, "Resources");
			if (resources) {
			resources = deref_object(document, resources);
			PoDoFo::PdfObject *xobj = obj_dir_get(resources, "XObject");
				if (xobj) {
				auto xobj_it = xobj->GetDictionary().begin();
				while (xobj_it != xobj->GetDictionary().end()) {
					check_replace_ref(xobj, *xobj_it, imgrefs);
					++xobj_it;
				}
			}}
			document.FreeObjectMemory(*it);
		}
		else if (is_image(*it)) {
			PoDoFo::PdfObject *mask = obj_dir_get(*it, "Mask");
			PoDoFo::PdfObject *smask = obj_dir_get(*it, "SMask");
			if (mask && mask->IsReference()) {
				check_replace_ref(*it, {PoDoFo::PdfName("Mask"), mask}, imgrefs);
			}
			if (smask && smask->IsReference()) {
				check_replace_ref(*it, {PoDoFo::PdfName("SMask"), smask}, imgrefs);
			}
			document.FreeObjectMemory(*it);
		}
		++it;
	}
}

void dedup_pages (PoDoFo::PdfMemDocument &document, 
		std::unordered_map<PoDoFo::PdfReference, PoDoFo::PdfReference> &imgrefs) {
	int nCount = document.GetPageCount();
	for (int i=0; i<nCount; i++) {
		PoDoFo::PdfPage* pPage = document.GetPage(i);
		PoDoFo::PdfObject *xobj = obj_dir_get(pPage->GetResources(), "XObject");
		if (!xobj)
			continue;

		auto xobj_it = xobj->GetDictionary().begin();
		while (xobj_it != xobj->GetDictionary().end()) {
			check_replace_ref(xobj, *xobj_it, imgrefs);
			++xobj_it;
		}
	}
}

void dedup_imgrefs (PoDoFo::PdfMemDocument &document, 
		std::unordered_map<PoDoFo::PdfReference, PoDoFo::PdfReference> &imgrefs) {
	dedup_pages(document, imgrefs);
	dedup_xobjs(document, imgrefs);
}

void delete_img_obj (PoDoFo::PdfMemDocument &document, 
		std::unordered_map<PoDoFo::PdfReference, PoDoFo::PdfReference> &imgrefs) {
	for (auto rit = imgrefs.begin(); rit != imgrefs.end(); ++rit) {
		document.GetObjects().RemoveObject(rit->first);
	}
}

int main( int argc, char* argv[] )
{
  char*    pszInput;
  char*    pszOutput;

  if( argc != 3 )
  {
    print_help();
    exit( -1 );
  }

  pszInput  = argv[1];
  pszOutput = argv[2];

  try {
	std::unordered_map<PoDoFo::PdfReference, PoDoFo::PdfReference> imgrefs;
	PoDoFo::PdfMemDocument document(pszInput);
  	dedup_imgs(document, imgrefs);
	dedup_imgrefs(document, imgrefs);
	delete_img_obj(document, imgrefs);
	PoDoFo::PdfObject trailer(*(document.GetTrailer()));
	PoDoFo::PdfWriter writer( &(document.GetObjects()), &trailer);
	writer.SetWriteMode(PoDoFo::ePdfWriteMode_Clean);
	writer.Write(pszOutput);
  } catch( PoDoFo::PdfError & e ) {
      fprintf( stderr, "Error: An error %i ocurred during processing the pdf file.\n", e.GetError() );
      e.PrintErrorMsg();
      return e.GetError();
  }

  return 0;
}
Replies: >>4673
>>4670
Perfect, this fixes the issue in >>4658. Many thanks anon! The warning in >>4652 is still printed verbatim but I guess that's not a serious issue, as the resulting PDF looks fine.
f339012cf214b57bfec3ef1c43b5ed850a8adeeb1abf782e41cfbcc51205f377.png
[Hide] (332.1KB, 720x1018)
>>4654
As promised, I added your pasta to the newest issue of Sleepy Station (uploading now), which has been compressed effectively thanks to your handy script. Terry must be smiling down on you right now.
Replies: >>5098
>>5097
Nice, appreciate it.
not sure if this is the right thread for video editing questions (incase i start editing my crappy gaymes in the furture)
but how do you apply arkangel lowpoly styled censorship on a video? what is this filter called? im editing a video for rumble (since pr0n is not allowed there) and the traditional black image cover is boring and generic

how do you match tiktok/instagram text with combined round edges per line and colored border (on photoshop there is an option to change fonts but the image text is too simple)
using a notepad as annotations while making how-to videos looks amateurish and looks 2008ish i want something modern

do i need to run android emulator with lucky patcher for editing videos like this? or can i do this with adobe apps? i dont use social media i just want my videos to look that way since most of the stuff i see on YT is too generic
sorry if this question sounds downright stupid i dunno which light video editor to choose and i made this post in a hurry (i wanna do something useful as a NEET since i never uploaded/created anything for the web)
Replies: >>5268 >>5431
>>5267
Use a search engine, there are fuck ton of options. Shotcut, kdenlive, blender, etc
Bitchin'_fast_3D.jpg
[Hide] (280.7KB, 800x1051)
>libaom 3.2 encodes 720p video at 8 fps on an FX 8350
What black magic is this.
Replies: >>5423
how the heck do you downsize a big 1mb animated gif file to 180kb? im trying to make a banner for a chan (lossy compression is perfectly fine)
also do i need to select any options/plugins on GIMP since i wanna crop then edit the gif frame by frame while allowing it to move just fine (what software do you guys use?)

>>5410
kek my old XP computer never had any hardware acceleration cards whatsoever i remember the time i broke my pc multiple times and the mobo got fried
Replies: >>5425 >>5431 >>6453
>>5423
For each frame reduces color depth, make less frame, you can batch process with imagemagick. Combine with ffmpeg.
Replies: >>5472
>>5267
>how do you apply arkangel lowpoly styled censorship on a video?
What the fuck is that even? Show an example.
>how do you match tiktok/instagram text with combined round edges per line and colored border
Again, what the fuck are you talking about? Do you want subtitles in the form of black boxes with rounded edges having white text inside?
>or can i do this with adobe apps?
Just use Shotcut on your computer, it doesn't seem like you're doing anything that crazy and Shotcut handles most common video editing tasks.

>>5423
>how the heck do you downsize a big 1mb animated gif file to 180kb?
There are multiple tricks you can do in GIMP:
<Filters -> Animation -> Optimize (Difference)
This effectively stores pixels that are common between frames only once. Use this for "static-ish" GIFs.
<Image -> Mode -> Indexed if it's already Indexed choose RGB then choose Indexed again
This reduces the bit depth of your GIF by reducing the number of colors. For "Maximum number of colors" use any of the following values: 256, 128, 64, 32, 16, 8. Experiment with the "Color dithering" options.
<manually  remove frames
<scale down the GIF (~240p resolution should be fine, or less)
Replies: >>5472
JEW_usah_ban-button_banner_indexed16_optimized.gif
[Hide] (121.2KB, 498x188)
>>5425 alright i think i figured it out myself (google did help a bit) no command lines/terminal needed
managed to get it to 500kb with the edits merge'd this should be more than enough (i only noticed this post after i finished the .xcf lol)

>how did you optimize the size
it was auto shrinked by GIMP when i exported it but however i DID click on the filter -/ animation -/ optimize as gif button the second time (no real difference on the first and second :P)

>shrink to 240p and remove frames
nah this resolution should be good enough it only has 8 frames no need to trim anything

ok i just re-exported it for the third time since i havent posted it yet and it worked (i set the index to 16 and now its at 128kb thanks anon)
heres the final result incase you want to see it (picrel i am not that great using this program) welp time to turn on the Y-fone hopefully i still have load left mwahaha
i created this on the pinktop with WinPE i have to admit the anydesk is pretty gud and the weak celeron processed it quickly without lag (kek this was previously used for photoshop before the screen broke)

>>5431
>how do you apply this kind of censorship give examples https://www.youtube.com/watch?v=g5JVycfW3bc
as you can see on 0:45 to 1:00 the translucent polygons move slow but change shape rapidly perhaps i can mimic this effect on a video editor (not sure if censor ninja app supports this filter)
i dont wanna get banned for posting pr0n on rumble (not sure if bitchute allows this either) so i have to get creative real quick (and dear god no im not gonna use pornhub/xvideos either since they support BLM and almost crashed my browser due to ads multiple times)

>do you want black boxes with round corners (if nothing else works maybe ill just use a custom shape and transform it even though its very inconvenient with the help of other tools)
yep this is just what i needed (but on the app you can turn/rotate the text sideways freely instead of straight horizontal) (this is the only thing missing left)
on vivavideo/filmora mobile (used this before on online classes lel) i can do this but the edit area is too small and my emulator is broken at the moment
i dont wanna use my mic since (( creatorfags )) can potentially identify me pretty quickly IRL just by using audio cues OSNIT style (even though i dont use social media at all)

>shotcut
looks minimalistic and simple like bandicut ill check it out (not sure is CPU only will cause lag since im gonna need crack for vm)
Replies: >>5485
>>5472
>now its at 128kb thanks anon
Anytime anon.
>the translucent polygons move slow but change shape rapidly
That looks too complex, I'm not sure you can do that in Shotcut... What you can do is a simple blur, a simple pixelate, or the "spot remover" effect:
https://forum.shotcut.org/t/censoring-areas/11434/7 (scroll up to see the other 2 effects).
There's also an old tutorial here: https://www.youtube.com/watch?v=B1Tyjs-BdIg
>yep this is just what i needed
Shotcut has a rich text tool you can use. You'll get a nice rotated black box with text in it, but no rounded corners... Your other option would be to simply create the text box in GIMP and import it into Shotcut where it can be rotated and positioned.
>not sure is CPU only will cause lag since im gonna need crack for vm
I don't understand what you're trying to say here. Shotcut is free, just download it on your computer and you're good to go. Also I think it uses CPU by default when rendering so even toasters can run it.
Replies: >>5488
>>5485 thanks for the help i appreciate it
i was talking about the bandicrack also i might need multiple video editing apps just to get the job done hopefully my storage does not fill up (i only asked this in advance ill come back here after screen recording the video with OBS)
>>5423
>how the heck do you downsize a big 1mb animated gif file to 180kb?
imagemagick + downsize script
http://www.fmwconcepts.com/imagemagick/downsize/index.php
Replies: >>6939
thoughts on this guide? /GAG/ globohomo art general i just found it recently
http://archive.4plebs.org/pol/thread/389808616/
hmm i want to make my own dystopian anti-furfag comic with this perhaps this should be enough to wake up the cuckchanners its not too late we can still stop agenda 2030
any good GIMP guides? its 2022 and companies are leveling up in en masse i gotta keep up with the season cuz why not
aplay_(4).jpg
[Hide] (182.5KB, 1827x1028)
aplay_(5).jpg
[Hide] (127KB, 1258x760)
>>6453
Thanks, man. I was looking for a animated gif conversion process
How does libaom 3.5.0 perform under realtime constraints on a post-2017 CPU?
Does it deliver somewhat acceptable quality for livestreaming at a reasonable bitrate?
VMbook_legionnaire_sticker.png
[Hide] (97.7KB, 900x670)
VMLabs_rumble_avatar.png
[Hide] (135.7KB, 400x400)
2020_refresh_(1).PNG
[Hide] (101.2KB, 1920x1080)
>>7256 forgot my image feel free to put this on the offtopic thread sorry if this is the wrong place
FINALLY after all these days (85 uptime) i fucking did it it actually didnt crash the core isolation setting really paid off i finished my session holy shit i feel really good wrestling my adhd all the tasks are done PHEW now where was i? 60 days wihtout any gaming feels really draining due to my ram all filled up but this upgrade should solve the problem
dunno if this counts as OC but did i do good? how do i convert this thing into a sticker for my legion? any settings i should change on my printer or the image viewer?
im gonna put this jak at the back of my laptop (im gonna make a thread on 4chan /g/ after the ram upgrade tomorrow) mwahaha just for the kicks since its all botspam there i wanna liven up that place once in a while
also take this free wallpaper if there are any winfags here why is windows so rude? right after i enabled my wifi this thing just updooted after i restart my system even though i told it to wait a few more days (this happened on next startup dont worry)
Replies: >>7266
>>7264
Use a search engine, first result "diy print sticker"
G.I._Joe__The_Rise_of_Cobra_(2009)_BluRay_v2_720p_(fzmovies.net)_7fffc2c683269cf7cc0ba766ee734116-mkv.mp4
[Hide] (21.5MB, 1280x532, 02:34)
gem_soyjak_turn_this_metallic_for_destro_c56.png
[Hide] (423.5KB, 600x658)
how the fuck did 123movies detect developer tools? in the end i stopped using that ad filled shithole before VM potentially crashed
(the infected link itself i could not decode scripts) hxxps://www1.123moviesfree.icu/movie/g-i-joe-the-rise-of-cobra/watching.html
(original sauce of watermarked file) hxxps://www.fzmovies.net/movie-G.I.%20Joe:%20The%20Rise%20of%20Cobra--hmp4.htm

why the heck does audio stuttering happen on shotcut? whenever i play for a few seconds in winPE and how do i zoom in the seekbar itself for precise editing? (man i love opensource so far i did not get errors despite missing MS files though my vcpus did reach 100 during export)
initally i was just looking for youtube video for the [you and what army scene] but all i got was a low quality TV rip im surprised nobody memified this gem of a clip yet (i also included the nanite injection scene and the laser prison scene incase you need those as well)
so here it is my first edited video did i do good? also i found a way to hide the winPE taskbar just by fiddling the registry though i do need to kill explorer.exe first (hmm making a batch script to auto apply registry shoudnt be too hard since a lot of games use fake full screen and its still annoyingly there)
[New Reply]
132 replies | 52 files
Connecting...
Show Post Actions

Actions:

Captcha:

Select the solid/filled icons
- news - rules - faq -
jschan 1.4.1