Render Multimedia in Pure C
nullprogram.com
nullprogram.com
#!/usr/bin/perl
# Output is a PPM file : try snowflake | xloadimage stdin
# see http://cam.pm.org/christmasppc-summary.shtml#Pete_Clay for explanation
$w= 100
;$w*=5; ;$W=$w*
$w; q--; $p=atan2(1,0)* 2;3; @P=
("\000"x3)x( $W); BEGIN{$";sub
S{$_.='fhoq' }sub K{$_.='s'.((
$n ++)) .(( '' .'' .'{' ))
;}; sub Y{$_ .= $_[0 ]}; S;K
;Y(''. '$k/=2;$'. '' .'l/=2}'); S;K;0;
Y( '$k/=3;$l/=3;$k+=$j/4}fhoqh{'. ''
.'cevq"P6\a$jq$j\a255\a",q@P}');S;K;Y('$g=$c/3;e}');
S;K; Y(q.$g=$. .'c/-3;' .'e}');S ;K;Y('$'. 'g'.
'=' .'$c*2' .'/3}' );;s/v /vag/x; sub
p{$P [$x+$w/2+ int($y)* $w+$W/2] ="\377"x3 }sub
r{$z=$x*cos($t)+$y*sin($t);$y=$x*sin($t)-$y*cos($t);
$x =$z};tr/a-z/n-za-m/;s/d/$"/gx; $x
++;$y= 4;eval$_}; s/ /japh/;sub T{;$a=
$_[ 0]; ;$b= (( $a&( ($a |(+
$a <<1) )<< 1) )>> 2)|( $a
>>3);if($b){ $_[0 ]=""}else{$_
[0]="f$a;p;" }};; for(1..20000
*10 ){$_ =int(rand(20)) ;T$_ ;0;
eval$_} u#byPJC
#JA PH#
Ironically on the DOS systems (and early home computers) I learnt on it was really easy to display images from programs as the framebuffer was at a known memory address and you could just write to it. Windowing systems make that a bit harder, and very little of this is really portable.I remember doing lots of animation and random graphics stuff in DOS using mode 13, the usual stuff at the time, plasma etc. 320 x 200 was more than enough for this kind of fun. Good times, simple times!
./yourprogram -a >(ffmpeg -f rawaudio ..other audio opts.. -i - ..encoding options.. audio.m4a) -v >(ffmpeg -f rawvideo ..video opts.. -i - ..encoding options.. video.m4v)
ffmpeg -i audio.m4a -i video.m4v -c:a copy -c:v copy out.mp4
The >() syntax is a bash extension, supported also by zsh, and replaces the argument with a file path to a pipe that's connected to the process within the ()'s stdin. Similarly you can use <() to replace the arg with a pipe connected to the process's stdout. One thing I use it for sometimes is to compare directory contents: vimdiff <(ls -1 dir1 | cut -d/ -f2-)<(ls -1 dir2 | cut -d/ -f2-)
There are better tools for this specific task, but for a quick and dirty compare on a machine where you only have vim and bash, it's hard to beat.All C, up to Media Cleaner Pro 4, migrating to C++ with Cleaner 5, with some Altivec (oh, what a joyous SIMD ISA) on the Mac side.
[1] http://vis.lbl.gov/NERSC/HowTos/mpeg/help/tools/mpeg_encode....
That's most of the article. It can be found in the "frame" and "ppm_*" functions in the program.
Nice clean classical C style there in my opinion.
[1] jsoftware.com