Code Monkey home page Code Monkey logo

ffpb's Introduction

ffpb stars

Not smart. Not comprehensive. Not guaranteed to work.

Source PyPI AppVeyor Format License Changelog Downloads

ffpb is an FFmpeg progress formatter. It will attempt to display a nice progress bar in the output, based on the raw ffmpeg output, as well as an adaptative ETA timer.

Showcase

https://github.com/althonos/ffpb/raw/master/static/showcase.v1.gif

(yes, my laptop can't encode shit)

Usage

ffpb is is not even self-aware. Any argument given to the ffpb command is transparently given to the ffmpeg binary on your system, without any form of validation. So if you know how to use the FFmpeg CLI, you know how to use ffpb !

Using as a library

ffpb can be used as a library: use the ffpb.main function:

ffpb.main(argv=None, stream=sys.stderr, encoding=None, tqdm=tqdm):
argv
The arguments to pass to ffmpeg, as an argument list.
stream
The stream to which to write the progress bar and the output messages.
encoding
The encoding of the terminal, used to decode the ffmpeg output. Defaults to locale.getpreferredencoding(), or UTF-8 is locales are not available.
tqdm
The progress bar factory to use. A subclass of tqdm.tqdm is expected. Check althonos/ffpb#19 to see how you can use this to wrap ffpb in your own UI.

Installation

Install from PyPI:

$ pip install --user ffpb

Alternatively, download a development version from the GitHub master branch:

$ pip install https://github.com/althonos/ffpb/archive/master.zip

Or if you use an Arch-based distro, download from the AUR

ffpb's People

Contributors

althonos avatar dependabot-preview[bot] avatar emericg avatar nex4rius avatar sergeykasmy avatar sidneys avatar vslavik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ffpb's Issues

Progress bar not showing when converting audio to video.

I run the following command for converting an M4A audio file to an MKV video file, using a single image for the entire video duration:

ffpb -loop 1 -framerate 1 -i "image.png" -i "audio.m4a" -c:v libx264 -preset medium -crf 0 -c:a copy -shortest "video.mkv"

FFPB will show a progress bar for a phase, but for the second phase it will not show.

Does not accept trailing `?` to a map

Conversion failed when -map 0:2? -map 0:3? -map 0:4?—or -map 0:2\? -map 0:3\? -map 0:4\? if running from a Shell script.

Accepted if straight running ffmpeg command, but not when issuing ffpb command.

No longer woking with FFmpeg 5.1.2

ffpb ceases to work properly with FFmpeg 5.1.2

Progress bar no longer showing up. Instead, something like this is displayed: _filename_: 3612 seconds [00:05, 715.26 seconds/s]

ffpb not working for some extensions

Hi. ffpb results in this traceback when I try to convert from .m4a to .mp3.

$ ffpb -i test.m4a test.mp3
Exception in thread STDOUT/ERR thread for pid 8681:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ritiek/.local/lib/python3.7/site-packages/sh.py", line 1540, in wrap
    fn(*args, **kwargs)
  File "/home/ritiek/.local/lib/python3.7/site-packages/sh.py", line 2484, in output_thread
    done = f.read()
  File "/home/ritiek/.local/lib/python3.7/site-packages/sh.py", line 2943, in read
    self.write_chunk(chunk)
  File "/home/ritiek/.local/lib/python3.7/site-packages/sh.py", line 2918, in write_chunk
    self.should_quit = self.process_chunk(chunk)
  File "/home/ritiek/.local/lib/python3.7/site-packages/sh.py", line 2839, in process
    return handler(chunk)
  File "/home/ritiek/.local/lib/python3.7/site-packages/sh.py", line 1624, in fn
    return handler(chunk, *args)
  File "/home/ritiek/.local/lib/python3.7/site-packages/ffpb.py", line 89, in __call__
    self.progress(line)
  File "/home/ritiek/.local/lib/python3.7/site-packages/ffpb.py", line 129, in progress
    total=self.duration * self.fps,
TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'

and no progress bar is shown although it does invoke ffmpeg and the output file test.mp3 works as expected.

I also tried to convert from .mp4 to .mkv and the progress bar indeed gets displayed but for some reason it fails for .m4a to .mp3.

ffpb = WinError 2

C:\Users\kubinka0505>ffpb
'ffpb' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\kubinka0505>pip install ffpb
Collecting ffpb
  Using cached ffpb-0.4.1-py2.py3-none-any.whl (6.2 kB)
Collecting tqdm~=4.25
  Downloading tqdm-4.64.0-py2.py3-none-any.whl (78 kB)
     ---------------------------------------- 78.4/78.4 KB 874.5 kB/s eta 0:00:00
Collecting colorama
  Using cached colorama-0.4.4-py2.py3-none-any.whl (16 kB)
Installing collected packages: colorama, tqdm, ffpb
Successfully installed colorama-0.4.4 ffpb-0.4.1 tqdm-4.64.0

C:\Users\kubinka0505>ffpb
Unexpected exception: [WinError 2] Nie można odnaleźć określonego pliku

C:\Users\kubinka0505>py -V
Python 3.7.6

I've just installed ffpb and this dropped. Any solutions?

Bogus error if ffmpeg can't write

$ ffpb -hide_banner -i 'foo.mp4' -vf 'subtitles=filename=foo.srt:force_style=Fontsize=28' -c:a copy 'foo-cc.mp4'
Traceback (most recent call last):
  File "/usr/local/bin/ffpb", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/ffpb.py", line 173, in main
    print(notifier.lines[-1].decode(sys.stdin.encoding), file=stream)
TypeError: decode() argument 1 must be string, not None

The underlying problem was that FFmpeg can't write output file:

$ touch foo-cc.mp4
touch: cannot touch 'foo-cc.mp4': Permission denied

advance use for api

Hi
I want to send a progress bar percent and time estimation to my frontend app.
is it possible to get that in another python app and send it via socket to the frontend app?
could you demonstrate how?

Setting log level too low breaks progress bar

When the log level is set to warning or lower, ffpb fails to either a) display a progress bar or b) warn that the log level setting will prevent the progress bar from being displayed. Setting the log level to info, verbose, debug, and trace all correctly display the progress bar.

Here is the command I ran:

ffpb -loglevel error -i $file -c:v libvpx -crf 4 -b:v 5000k -auto-alt-ref 0 ${file%.*}.webm

Unexpected exception: 'utf-8' codec can't decode byte 0xc3 in position 0: unexpected end of data

I keep getting the following error: Unexpected exception: 'utf-8' codec can't decode byte 0xc3 in position 0: unexpected end of data no matter what I do. If I run it directly with ffmpeg, then there's no error whatsoever.

I installed v0.3.0 to check if the error was seen there but it's not. This is a problem with v0.4.0 only.
If there's a way I can debug the code to figure out what's happening.

PS: I installed ffpb through pip3 on Ubuntu 20.04

Permission to embed your software into FFenmass.

I'm having trouble using ffpb as an import as it does not properly invoke KeyboardException when triggered.

I am asking permission to modify your code from ffpb.py and embed it into FFenmass.

Both FFenmass and ffpb are under MIT license, but I figured would be better to directly ask you.

Errors after installing/doesn't work.

I got

Warning the script tqdm is installed in '/home/lenovo/.local/bin' which is not on PATH.

Warning the script ffpb is installed in '/home/lenovo/.local/bin' which is not on PATH.

Successfully installed ffpb-0.4.1 tqdm-4-60.0

When I type ffpb it doesn't seem to be installed

Cannot parse while doing a first pass output to null

When passing the first pass arguments to ffmpeg (-pass 1 -f null /dev/null), there is no time/speed recorded for the analysis:

Input #0, matroska,webm, from '2021-03-18 19-23-22.mkv':                                                                                                                                                                                      
  Metadata:                                                                                                                                                                                                                                   
    ENCODER         : Lavf58.45.100                                                                                                                                                                                                           
  Duration: 01:55:39.95, start: 0.000000, bitrate: 2828 kb/s                                                                                                                                                                                  
    Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 852x480, 60 fps, 60 tbr, 1k tbn, 120 tbc (default)                                                                                                                      
    Metadata:                                                                                                                                                                                                                                 
      DURATION        : 01:55:39.950000000                                                                                                                                                                                                    
    Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)                                                                                                                                                                            
    Metadata:                                                                                                                                                                                                                                 
      title           : Track1                                                                                                                                                                                                                
      DURATION        : 01:55:39.864000000                                                                                                                                                                                                    
    Stream #0:2: Audio: aac (LC), 44100 Hz, stereo, fltp                                                                                                                                                                                      
    Metadata:                                                                                                                                                                                                                                 
      title           : Track2                                                                                         
      DURATION        : 01:55:39.864000000                                                                             
Stream mapping:                                                                                                        
  Stream #0:0 -> #0:0 (h264 (native) -> vp9 (libvpx-vp9))                                                                                                                                                                                     
Press [q] to stop, [?] for help                                                                                        
[libvpx-vp9 @ 0x560317566b80] v1.9.0    
Output #0, null, to '/dev/null':                                                                                                                                                                                                                Metadata:                                                                                                                                                                                                                                       encoder         : Lavf58.45.100                                                                                                                                                                                                               Stream #0:0: Video: vp9 (libvpx-vp9), yuv420p, 852x480, q=-1--1, 512 kb/s, 60 fps, 60 tbn, 60 tbc (default)                                                                                                                               
    Metadata:                           
      DURATION        : 01:55:39.950000000                                                                             
      encoder         : Lavc58.91.100 libvpx-vp9                                                                                                                                                                                              
    Side data:                          
      cpb: bitrate max/min/avg: 742000/256000/512000 buffer size: 0 vbv_delay: N/A
frame=52437 fps=384 q=0.0 Lsize=N/A time=00:00:00.00 bitrate=N/A speed=   0x    

This goes on for as long as the frames are being processed.

ffpb doesn't seem to be able to report on this, and just sits at 0% for the entirety of the first pass:

2021-03-18 19-23-22.mkv:   0%|                                | 0/416340 [03:56<?, ? frames/s]

Which, it doesn't fail to pass any arguments, etc. so it's technically working, it just can't get any info from ffmpeg to display. Is there something that I'm missing that could be passed to enable status on firstpass analysis?

Isnt transparent in a ffmpeg pipe

ffmpeg-bar -y -i h:\3.mov -pix_fmt yuv422p -vcodec mpeg2video -non_linear_quant 1 -flags ^+ildct^+ilme -top 1 -dc 10 -intra_vlc 1 -r 25 -qmax 12 -lmin 1^QP2LAMBDA -vtag xd5c -rc_max_vbv_use 1 -rc_min_vbv_use 1 -g 12 -b:v 50000k -minrate 50000k -maxrate 50000k -bufsize 8000k -acodec pcm_s16le -ar 48000 -bf 2 -ac 2 -f mxf - ^| bmxtranswrap.exe -t avid --pstc --clip clip --project pro --import clip -o test -
ERROR
ERROR (libMXF): 'mxf_file_read(mxfFile, (uint8_t
)key, 16) == 16' failed, in ......\mxf\mxf_file.c:543
ERROR (libMXF): 'mxf_read_k(mxfFile, &tkey)' failed, in ......\mxf\mxf_partition.c:708
ERROR: Failed to find and read header partition
Warning: Open error 'MXF_RESULT_INVALID_FILE' near ......\src\mxf_reader\MXFFileReader.cpp:312
ERROR: Failed to open MXF file '': invalid or not an MXF file
Worked with ffmpeg
Chears

Crash on unexpected output

Simply the script log:

 led@ledomi-pc  ~/Downloads/Louise L. Hay megerősítések/input   home ●  for f in c/*.mp4; do mkdir -p ../vcd/"`dirname "$f"`"; ffpb -i "$f" -target pal-vcd ../vcd/"$f".mpg; done 
c/A titok c. film  2006, eredeti magyar szinkron [360p].mp4 | ╢███████████████████████████████████████████████████████████████████╟ 100% (0:05:47 / 0:05:47)
c/A titok c. film  2006, eredeti magyar szinkron [360p].mp4 — ╢████████████████████████████████████████████████████████████████████╟ 100% (0:05:47 / 0:05:47
Exception in thread STDOUT/ERR thread for pid 7142:
Traceback (most recent call last):
  File "/usr/lib64/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/home/led/.local/lib64/python3.5/site-packages/sh.py", line 1540, in wrap
    fn(*args, **kwargs)
  File "/home/led/.local/lib64/python3.5/site-packages/sh.py", line 2484, in output_thread
    done = f.read()
  File "/home/led/.local/lib64/python3.5/site-packages/sh.py", line 2943, in read
    self.write_chunk(chunk)
  File "/home/led/.local/lib64/python3.5/site-packages/sh.py", line 2918, in write_chunk
    self.should_quit = self.process_chunk(chunk)
  File "/home/led/.local/lib64/python3.5/site-packages/sh.py", line 2839, in process
    return handler(chunk)
  File "/home/led/.local/lib64/python3.5/site-packages/sh.py", line 1624, in fn
    return handler(chunk, *args)
  File "/home/led/.local/lib64/python3.5/site-packages/ffpb.py", line 94, in __call__
    if char not in '\r\n':
TypeError: 'in <string>' requires string as left operand, not bytes


At this point ffmpeg runs in background, but the only thing on the console I can see is this error message, not the process.
I recommend as a hotfix catching errors at top level, and putting ffmpeg to the controlling terminal instead.

Progress does not show if first input is long

``Progress is printed like the following:
input_file/input_url: 0%| | 0/30480 [00:00<?, ? frames/s]

But when the first input is long, the progress gets printed off-screen.

For instance, I used youtube-dl to extract the constituent URLS for a youtube video to cut it shorter without downloading.
Then, I ran:
ffpb -ss "$start_cut" -i "$url1" -ss "$start_cut" -i "$url2" -t "$time_diff" $video_args out.mp4

And the first url ended up being over 800 characters long, causing the progress to not be shown on the screen.

It would be preferable if the progress were printed to a new line if it would otherwise be printed off-screen.

Thank you.

Cant run ffpb.py, Attribute Error

This is the command i ran:

./ffpb.py -i family.guy.s16e08.720p.web.x264-tbs.mkv -s hd480 -c:v libx264 -crf 23 -c:a aac -strict -2 file.mkv

This is my error:

Traceback (most recent call last):
File "./ffpb.py", line 41, in
class AbsoluteTimeETA(progressbar.AbsoluteETA):
AttributeError: 'module' object has no attribute 'AbsoluteETA'

AttributeError: 'module' object has no attribute 'AbsoluteETA'

Run in Terminal Linux

Sorry to ask, but is it possible run ffpb with ffmpeg with Ubuntu 16.04 Xenial Xerus through Terminal Mode (SSH)? If so, can you explain how to install and run it? And really really sorry again, because I am very noob in Linux OS. Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.