Conversion of .MOV and .AVI files to .MP4 using VLC and ffmpeg
Here's How I Convert Apple Quicktime .MOV and Windows .AVI Video to .MP4
Introduction
Many Apple devices shoot video in H265 hvec, mpeg-h video format, and contain them in dual stream format where Stream 0 is H265 video and Stream 1 is MPEG AAC (mp4a) audio. The file container is .MOV. Other formats substitute H264 video for stream 0. The results is what they call "Quicktime". Other non Apple devices such as Sony Handycams and Mavicas store their video with a .AVI format. This container has JPEG video. For all these weird and outmoded formats, you can convert them to more modern MPEG-4 video and MP3 audio, or H264 video with MP3 audio. Choose your codecs from this list. This blog entry has examples of how to convert videos with VLC command line and ffmpg command line. If this blog entry is helpful or you know of a better way, please say so in the comments. -- Thanks Guys!
Convert it using MSDOS Batch Scripting and VLC player
for %%a in (*.mov) do cmd /c "C:\program files (x86)\VideoLan\VLC\vlc.exe" ^ -I dummy -vvv %%a ^ --stop-time=60 ^ --sout=#transcode{vcodec=h264,vb=7000,fps=25.000,size=4:3,width=722,height=578,^ vfilter=croppadd{croptop=2,cropbottom=0,cropleft=2,cropright=0,paddright=0},^ acodec=mp4a,ab=128,channels=2,samplerate=44100,deinterlace}^ :standard{access=file,mux=mp4,dst=%%~na.mp4} ^ vlc://quit
for %%a in (*.mov) do "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -I dummy -vvv %%a --sout=#transcode{vcodec=h264,vb=7000,acodec=mp3,ab=128,channels=4,deinterlace}:standard{access=file,mux=ts,dst=%%a.mp4} vlc://quit
Convert it using ffmpeg on Ubuntu 14.4 and Bourne Shell Scripting
First you need to install ffmpeg onto your ubuntu desktop.and
then use this cool bash script to automagically convert everything using the find command and some cool sed commands. Sed is used to replace spaces in the directories and filenames.
#! /bin/bash ## ## ALLMOVFILES=`find ./ -name "clip*.mov" -exec /bin/sed -e 's/\ /%20/g' '{}' ';'` ## ALLMOVFILES=`find ./ -name "clip*.mov" -exec echo '{}' | /bin/sed -e 's/\ /%20/g' ';'` OUTDIR="./H264-Video" ALLMOVFILES=`find ./ -name "MVI*.MOV" -exec echo '{}' ';' | /bin/sed -e 's/\ /%20/g'` for INFILE in ${ALLMOVFILES} do echo $INFILE FILENAME=`echo ${INFILE} | nawk -F "/" 'BEGIN { FS="/"; } { print $NF; }'` DIRS=`echo ${INFILE} | nawk -F "/" 'BEGIN { FS="/"; } { for (i=1;i<NF;i++) { print $i;} }'` echo "Split with awk: " $DIRS for dir in $DIRS do echo "dir:" $dir done echo "file:" $FILENAME ofile=`echo $FILENAME | /bin/sed -e 's/%20/\ /g'` ifile=`echo $INFILE | /bin/sed -e 's/%20/\ /g'` ofile=`echo $ofile | /bin/sed -e 's/MOV/mp4/g'` echo $ifile echo $ofile ffmpeg -i "${ifile}" -vcodec h264 -acodec aac -strict experimental -ab 128k -b:v 1024k -bufsize 1024k -r 20 "${OUTDIR}/${ofile}" done
Finally, this script will read the original date and time from the source QT file, and then apply it to the new H264 video file.
#! /bin/bash ## ## ALLMOVFILES=`find ./ -name "clip*.mov" -exec /bin/sed -e 's/\ /%20/g' '{}' ';'` ## ALLMOVFILES=`find ./ -name "clip*.mov" -exec echo '{}' | /bin/sed -e 's/\ /%20/g' ';'` OUTDIR="./H264-Video" ALLMOVFILES=`find ./ -name "MVI*.MOV" -exec echo '{}' ';' | /bin/sed -e 's/\ /%20/g'` for INFILE in ${ALLMOVFILES} do echo $INFILE FILENAME=`echo ${INFILE} | nawk -F "/" 'BEGIN { FS="/"; } { print $NF; }'` DIRS=`echo ${INFILE} | nawk -F "/" 'BEGIN { FS="/"; } { for (i=1;i<NF;i++) { print $i;} }'` echo "Split with awk: " $DIRS for dir in $DIRS do echo "dir:" $dir done echo "file:" $FILENAME ofile=`echo $FILENAME | /bin/sed -e 's/%20/\ /g'` ifile=`echo $INFILE | /bin/sed -e 's/%20/\ /g'` ofile=`echo $ofile | /bin/sed -e 's/MOV/mp4/g'` echo $ifile echo $ofile ## ffmpeg -i "${ifile}" -vcodec h264 -acodec aac -strict experimental -ab 128k -b:v 1024k -bufsize 1024k -r 24 "${OUTDIR}/${ofile}" let ix=1; timestamp="" timevals=`stat --format "%y" "${ifile}" | sed 's/[-:.]/ /g'` for tt in $timevals do if [ $ix -le 5 ]; then timestamp=${timestamp}${tt} fi if [ $ix -eq 6 ]; then timestamp=${timestamp}.${tt} fi let ix="ix+1" done echo $timestamp echo "${OUTDIR}/${ofile}" touch -a -m -t ${timestamp} "${OUTDIR}/${ofile}" done
Once you apply these timestamps, you can upload them to Apple iCloud.
read more.
Use VLC to Transcode a MOV container to straight mp4 video 2 Stream
REM REM MSDOS COMMAND LINE ON WINDOWS 7 WITH VLC - ONE LINER - WORD WRAPPED REM TRANSCODE AND CONVERT ONE 2 STREAM VIDEO TO A 2 STREAM VIDEO TO MP4V AND MP3 AUDIO REM RESHAPE VIDEO TO 4X3 PLUS CROP VIDEO SAVE AS TEST2.MP4 -- FIT ALL ON 1 LINE REM -- "C:\program files (x86)\VideoLan\VLC\vlc.exe" -I dummy -vvv IMG_6516.mov --stop-time=60 --sout=#transcode {vcodec=MP4V,vb=7000,fps=25.000,size=4:3,width=722,height=578,vfilter=croppadd {croptop=2,cropbottom=0,cropleft=2,cropright=0,paddright=0},acodec=mp3,ab=128,channels=2,samplerate=44100}:standard {access=file,mux=mp4,dst=test2.mp4} vlc://quit
Use VLC to Transcode / Convert a AVI Container to mp4 and mp3 Dual Video Stream
Using MSDOS for loop on all *.AVI, find them in a directory. Convert them all to mp4.
REM REM MSDOS COMMAND LINE ON WINDOWS 7 WITH VLC - ONE LINER - ^ WRAPPED REM TRANSCODE AND CONVERT ONE 2 STREAM AVI VIDEO TO A 2 STREAM VIDEO TO MP4V AND MP3 AUDIO REM RESHAPE VIDEO TO 4X3 PLUS CROP VIDEO SAVE AS NAME.MP4 -- MSDOS FOR LOOP REM -- for %%a in (*.AVI) do ( echo %%a "C:\program files (x86)\VideoLan\VLC\vlc.exe" -I dummy -vvv %%a --stop-time=60 --sout=#transcode^ {vcodec=MP4V,vb=7000,fps=25.000,size=4:3,width=640,height=424,^ vfilter=croppadd{croptop=2,cropbottom=0,cropleft=2,cropright=0,paddright=0},^ acodec=mp3,ab=128,channels=2,samplerate=44100}:standard{access=file,mux=mp4,dst=%%~na.mp4} vlc://quit )
Comments
Post a Comment