Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Comment on

( #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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (12)
    As of 2015-07-30 21:49 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (273 votes), past polls