Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

If you're in the furry fandom, more often than not you heard of the videos of a certain Big Blue Fox by the name of BBF TV HD. They're by a German video editor who works at RTL, and of when he and the Eurofurance crew visits a furry convention. It's a great way to get an idea of what a con is, or if you missed it, what happened.

I pulled most of the videos from his site, and every so often I tweak the encode settings to mencoder to do it... except mencoder doesn't do bframes right. I switched over to ffmpeg (not avconvert from the rogue libav gang; the original ffmpeg)... which doesn't have a nice status line.

Thankfully ffmpeg hit 1.0 and got a -progress option, which gives a nice status readout. Too bad my build outputs to a file, md5 code, or a pipe.. aka an opened file descriptor. Forget named pipes, it'll recreate 'em as a file.

After some hacking around... I have this! The settings in the ffmpeg command match that for a 2nd Gen AppleTV, but I also have info for the 3rd Gen/iPhone 5/iPad 4. I name this version atv-enc.pl. It takes two arguments: atv-enc.pl input output

EDIT: Whoops, a few bugs crept in with the bar. Fixed, and enhanced a bit.

#!/usr/bin/perl use POSIX qw(mkfifo); use Fcntl; use IO::Handle; use strict; $|=1; print "############\n"; my %prog; my $infile=$ARGV[0]; my $outfile=$ARGV[1]; # get some stats my $frametotal,$fwide,$fhigh; open(IN,"ffprobe -show_streams '$infile' 2>/dev/null |") || die "$infile: $!"; while(<IN>) { chomp; $frametotal=$1 if(/^nb_frames=(\d+)/); $fwide=$1 if(/^width=(\d+)/); $fhigh=$1 if(/^height=(\d+)/); last if(/^\[\/STREAM\]/); } close(IN); my @acmd; @acmd=("-acodec","libfaac","-ac","2","-ab","160k"); my @vcmd=qw/-c:v libx264 -vprofile main -preset slow -tune film -level + 3.1 -crf 28 -threads 0/; if($fwide > 1280 || $fhigh > 720) { @vcmd=(@vcmd,"-vf","scale=min(1280\\,iw):-1"); } pipe(IN, OUT); # We read from IN, ffmpeg writes to OUT. OUT->autoflush(1); # Autoflush on, close-on-exec off my $val=fcntl(OUT,F_GETFD,0) || die "Error: fcntl GET: $!"; $val &= ~FD_CLOEXEC; fcntl(OUT,F_SETFD,$val) || die "Error: fcntl SET: $!"; my $fd=fileno OUT; my @cmd=("ffmpeg","-progress","pipe:$fd","-v","panic", "-i",$infile, @acmd,@vcmd,@metadata,$outfile); my $pid=fork(); # Fork the kid unless($pid) { die "Can't fork! $!" unless defined $pid; close(IN); exec @cmd or die "Can't exec! $!"; } # parent. close(OUT); while(<IN>) { chomp; my ($a,$b)=split /=/; $prog{$a}=$b; if($a eq "progress") { my $pcent=$prog{"frame"}/$frametotal*100; my $hcent=int($pcent/2); my $bar="[".("#" x $hcent).(" " x (50-$hcent))." ] "; $bar .=sprintf("%.2f",$pcent)."% fps=".$prog{"fps"}; print "\r$bar"; } } print "\nWaiting for finish...\n"; waitpid($pid,0);

Information doesn't want to be free. It wants to be feline.

In reply to ffmpeg console progress bar by strredwolf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-29 12:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found