ffmpeg – Convert Adobe Flash FLV Files to MP4 Files

Simple Conversion of FLV to MP4 using FFMPEG

ffmpeg chews the input buffers – use -nostdin flag to fix it


find . -regextype posix-extended -iregex ".*.avi|.*.flv" -type f | while IFS= read -r file;
do
   fn="${file}";
   echo "###$fn###";
   dest="${fn%.*}.mp4";
   echo "###$dest###";
   if [ -f "$dest" ];then
      rm "$dest";
   fi;
   ffmpeg -nostdin -v 0 -i "$fn" -acodec copy -vcodec copy -copyts "$dest";
done;

Convert FLV to MP4 through container copy

– only works if video content is H264 and audio AAC or MP3

ffmpeg -i input.flv -acodec copy -vcodec copy -copyts output.mp4

Transcode FLV to MP4

ffmpeg -i input.flv -copyts output.mp4

Re-encode Audio

ffmpeg -i input.ext -vcodec copy -acodec libfaac -ab 128k -copyts output.mp4

# Copy Directory FLV TO MP4 – Version 1

for f in *.flv; do
    fn="${f%.*}";
    ffmpeg -i "$f" -acodec copy -vcodec copy -copyts "$fn.mp4";
done;

Copy Directory FLV TO MP4 – Version 2

for f in *.flv; do a=$(echo $f|sed -e 's/.flv/.mp4/ig');
    echo $a;
    ffmpeg -i "$f" -acodec copy -vcodec copy -copyts "$a";
done;

I found this: http://www.linuxquestions.org/questions/linux-mobile-81/androidg1-and-video-converted-via-ffmpeg-h263-687163/

It says you want particular prefixes for the Android, something like:

ffmpeg -i source-video.avi -s 480x320 -vcodec mpeg4 -acodec libfaac -ac 1 -ar 16000 -r 13 -ab 32000 -aspect 3:2 output-video.G1.mp4

My ffmpeg didn’t want -aspect 3:2 and you can omit it.

Convert directory tree from FLV to mp4

convert FLV files in tree to mp4 – preserve already existing files and MP4

find . -name "*.flv" -type f -exec ffmpeg -n -i '{}' -acodec copy -vcodec copy -copyts '{}.mp4' \;

convert directory tree from AVI,FLV to mp4

find . -regextype posix-extended -iregex ".*.avi|.*.flv" -type f -exec ffmpeg -n -i '{}' '{}.mp4' \;

-regextype posix-extended -iregex “.*.txt|.*.mp4”


for f in *; do fn="${f%.*}";echo "fn=$fn,f=$f"; done;

for f in \*.flv.mp4; do fn="${f%.*}";echo "$fn,f=$f"; done;

Remove FLV.MP4 double extensions

for f in *.flv.mp4; do fn="${f%.*}";fn="${fn%.*}";mv "$f" "$fn.mp4"; done;

References

1. http://fog.ccsf.edu/~gboyd/cs160b/online/7-loops2/whileread.html
2. http://superuser.com/questions/483597/converting-flv-to-mp4-using-ffmpeg-and-preserving-the-quality