Sunday, 23 December 2012

Converting videos from H264 to MPEG4 with ffmpeg

Was putting old family videos to an old Screenplay Plus but it didn't support H264 codec so had to convert them to MPEG4, these are my notes on this process.

One-liner to identify files that are H264 encoded

IFS=$'\n';for f in `ls -1`;do echo $f;mplayer "$f" -identify -vo null -ao null -frames 0 2>&1 /dev/null |grep H264;done

Using ffmpeg to convert H264 to MPEG4

ffmpeg -i INPUT-FILENAME.mp4 -vcodec mpeg4 -vtag XVID -b 5000k -acodec libmp3lame -ab 192k OUTPUT-FILENAME.avi
 

 Invalid number of channels 6, must be <= 2

If you get above error then add -ac 2 to encode the output file in 2 channel stereo.

timebase not supported by MPEG 4 standard

If you get above error the add -r 25 to set the frame rate to a standard 25 frames per second.

No comments: