Flash Videos speichern / mit MPlayer abspielen

Aus wiki.archlinux.de
Wechseln zu: Navigation, Suche

Hier mal zwei kleine Shell Scripte mit denen man Flash-Videos, die gerade im Browser geladen werden, speichern oder z.B. mit MPlayer abspielen kann. Die beiden Scripte sind für Firefox ausgelegt. Für andere Browser müssen evtl. kleine Änderungen vorgenommen werden.


  • mit MPlayer abspielen
for f in $(file /proc/$(pidof plugin-container)/fd/* | gawk '/\/tmp\/Flash/ {print $1}'); do 
 mplayer ${f%:} 
done


  • speichern (das Zielverzeichnis SAVEDIR= muss natürlich angepasst werden)
SAVEDIR=/home/USER/downloads
for f in $(file /proc/$(pidof plugin-container)/fd/* | gawk '/\/tmp\/Flash/ {print $1}'); do 
  F=$(ls -l ${f%:} | awk '{print $11}')
  cp ${f%:} $SAVEDIR/${F#/tmp/}.flv
done
  • Automatisiert anhand der MD5-Summe
#!/bin/bash
#by echtor.net
#Speicherort
dir=/home/$USER
#player
player=vlc
now=$(date +"%H-%M-%S")
red="\e[0;31m"
green="\e[0;32m"
nc="\e[0m"
flash=$(lsof -n | grep Flash | awk '{print "/proc/" $2 "/fd/" $4}' | sed 's/.$//' | head -n1)
if [ "$flash" = "" ]
	then
	echo -e "[ $redError$nc ] Flashfile not found"
	exit
fi
##player

	if which $player >/dev/null 2>&1 ; then
	echo  "[ $now ] Play with $player? (y/n): "
	read -p "[ $now ] " play
	if [ $play = "y" ]; then
	$player $flash >/dev/null 2>&1
fi
	else
    	echo -e "[ $red$now$nc ] cant play movie, $player not found, aborting"
fi
##

##loop
while :;do
now=$(date +"%H-%M-%S")

var1=$(md5sum $flash | awk '{print $1}')
	sleep 2s
var2=$(md5sum $flash | awk '{print $1}')
	if [ $var1 = $var2 ]; then
	echo "[ $now ] Enter a Filename: "
	read -p "[ $now ] " name
	if [ "$name" = "" ]; then
	name=$var1
	fi
	echo "[ $now ] File name: $name"
	echo -e "[ $green$now$nc ] [$flash] done, move file to $dir/$name.flv"
	cp $flash $dir/$name.flv
 
##convert

	if which ffmpeg >/dev/null 2>&1 ; then
	echo "[ $now ] Convert with ffmpeg? (y/n): "
	read -p "[ $now ] " convert
	if [ "$convert" = "y" ]; then
	echo -e "[ $green$now$nc ] Converting movie..."
	ffmpeg -i $dir/$name.flv -sameq -y $dir/$name.avi >/dev/null 2>&1
	echo "[ $now ] Removing the flash file"
	rm $dir/$name.flv
	echo -e "[ $green$now$nc ] Done"
	fi
	break
	else
    	echo -e "[ $red$now$nc ] cant convert, ffmpeg not found, aborting"
	break
	fi
##
	else
	echo -e "[ $green$now$nc ] [$flash] buffering.."
	fi
done



Weblinks