Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell script version? #1

Open
kpanic23 opened this issue Feb 8, 2021 · 16 comments
Open

Shell script version? #1

kpanic23 opened this issue Feb 8, 2021 · 16 comments
Assignees
Labels
enhancement New feature or request

Comments

@kpanic23
Copy link

kpanic23 commented Feb 8, 2021

Do you have by any chance planned to make the batch file available also as a shell script for use on Linux or MacOS?
I'd try converting it myself, but to be honest: I don't understand half of the advanced CMD.EXE magic you're using... 😁

@viler-int10h
Copy link
Owner

Yep, that'd be a good thing to have. I probably should've started with something more cross-platform (python?), but I plan to port it at some point once it's more or less finalized to avoid maintaining two versions. :)

@viler-int10h viler-int10h added the enhancement New feature or request label Feb 8, 2021
@viler-int10h viler-int10h self-assigned this Feb 8, 2021
@caiiiycuk
Copy link

As a potential solution is it possible to generate command sequences instead of actually running ffmpeg? I think in that case we can run this script using dosbox/wine and get output sequence to execute natively?

@caiiiycuk
Copy link

I tried this approach, but ffmpeg discards every command. Script generates this

ffmpeg -hide_banner -loglevel error -stats -y-f lavfi -i "color=s=1024x1024, format=gray, geq='lum=if(lte((X-W)^2+(Y-H)^2, 1024*1024), 255, 0)', scale=110:110:flags=lanczos"-filter_complex "color=c=black:s=1600x1200[black];color=c=#ffffff:s=1600x1200, format=rgb24[bg];[0] split=4 [tl][c2][c3][c4];[c2] transpose=1 [tr];[c3] transpose=3 [br];[c4] transpose=2 [bl];[bg][tl] overlay=0:0:format=rgb [p1];[p1][tr] overlay=1600-110:0:format=rgb [p2];[p2][br] overlay=1600-110:1200-110:format=rgb [p3];[p3][bl] overlay=x=0:y=1200-110:format=rgb , scale=iw*2:ih*2:flags=gauss, pad=iw+8:ih+8:4:4:black, lenscorrection=k1=0.08:k2=0.08:i=bilinear, crop=iw-8:ih-8, scale=iw/2:ih/2:flags=gauss, negate, eq=1.2 [alpha];[black][alpha] alphamerge" -frames:v 1 TMPbezel.png

If I run it I have:

Unrecognized option 'y-f'.
Error splitting the argument list: Option not found

If I replcae it with -y -f I have:

[swscaler @ 0x7fffb49bce98] [Eval @ 0x7fffb49bc7c0] Undefined constant or missing '(' in 'filter_complex'
[swscaler @ 0x7fffb49bce98] Unable to parse option value "filter_complex"
[lavfi @ 0x55d422131800] Error initializing filter 'scale' with args '110:110:flags=lanczos-filter_complex'
color=s=1024x1024, format=gray, geq='lum=if(lte((X-W)^2+(Y-H)^2, 1024*1024), 255, 0)', scale=110:110:flags=lanczos-filter_complex: Invalid argument

Do you think it's ffmpeg have different argument parsing on Windows/Linux or what?

--

ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil      56. 31.100 / 56. 31.100
libavcodec     58. 54.100 / 58. 54.100
libavformat    58. 29.100 / 58. 29.100
libavdevice    58.  8.100 / 58.  8.100
libavfilter     7. 57.100 /  7. 57.100
libavresample   4.  0.  0 /  4.  0.  0
libswscale      5.  5.100 /  5.  5.100
libswresample   3.  5.100 /  3.  5.100
libpostproc    55.  5.100 / 55.  5.100

@viler-int10h
Copy link
Owner

FFmpeg's argument parsing should be the same as far as I know. In that example, it looks like your commandline generation is stripping out leading tabs (which normally occur after a newline escaped by a caret), so the "-y" and "-f" stick together, and the same goes for the ":flags=lanczos" and the next line's "-filter_complex".

@officialcjunior
Copy link

+1 for this issue.
Awesome project, by the way.
:)

@makew0rld
Copy link

@viler-int10h I was poking around, and a Python translation of this script appears to exist already, in this fork, specifically this file.

I am not sure if it's complete, although it looks like it is. Maybe @vegardsjo (the author) could chime in.

@makew0rld
Copy link

On first test the script has some issues, for example not handling file paths with spaces. I am interested in improving this script. Not sure what the best way to do that would be, with PRs to the forked repo, or a PR to this repo, etc.

@slhck
Copy link

slhck commented Jul 9, 2021

I would create the PRs against the fork.

@vegardsjo
Copy link

Hi @makeworld-the-better-one, I actually forgot that I ported this to python 😅.

It is mostly complete, the only thing that is missing is cropping. I couldn't figure out what the output of the cropdetect command should be, so I couldn't know how to parse it ... I've also not done extensive testing, so I don't know if it would produce exactly the same results as the batch script (I don't know batch; the script was translated by guesswork).

I tend to avoid filenames/paths with spaces so I didn't encounter this problem, however I think it would be easy to fix.

Feel free to make PRs to my fork, and, if @viler-int10h wishes, I can make a PR to this repo.

@makew0rld
Copy link

@vegardsjo Hey, thanks for getting back to me! I'll look into getting the cropping working if I can. Test results would be nice as well. I've noticed there are test cases in this repo, maybe those can be used.

I probably should've tested before making my significant alterations, but the good news is that my improvements make the whole process 60% faster! I'm working on improving things further, and will make a PR once that is done. The end goal of this PR is to only end up with a single ffmpeg command at the end, which would be very handy.

@slhck
Copy link

slhck commented Jul 19, 2021

That sounds great!

While you're at it, I think it would be useful to do the ffmpeg command creation as a list of strings. You can always extend that list. This way, you can simply pass them to a subprocess command and you don't have to worry about spaces in filenames, etc. You can also concatenate filterchains in advance and join them by ;, etc. You can see examples of that here: https://github.com/slhck/ffmpeg-normalize/blob/master/ffmpeg_normalize/_media_file.py#L226

@morgant
Copy link

morgant commented Sep 3, 2021

@viler-int10h & @makeworld-the-better-one, I have fixed the cropdetect filter parsing and submitted a PR to @vegardsjo's fork: vegardsjo#1.

@jasonm23
Copy link

jasonm23 commented Jul 3, 2022

Ooof really wish I'd read this thread sooner, I just spent the last 4 hours porting to Bash script.

I'll check it works and but, I think I'll just switch to vegardsjo's fork.

@jasonm23
Copy link

jasonm23 commented Jul 3, 2022

removed

@jasonm23
Copy link

jasonm23 commented Jul 3, 2022

So it occurred to me, if I want to see better progress report I can use ffpb in place of ffmpeg however, (I think) that'll be tough to use from python.

I'll keep going with the bash script version, as it can use ffpb without breaking a sweat.

I think I'll be able to finish it tomorrow. I'll post again when I get some test results.

@cdkw2
Copy link

cdkw2 commented Jun 21, 2024

+1 for the issue. Hows the development going on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

10 participants