How to modify an flv video encoded at the wrong aspect ratio, so flowplayer will play it in fullscreen mode without it appearing either stretched or squashed.
Ideally, the perfect solution should be reencoded a video to the proper aspect ratio. However, for long videos, such as movies, a simple workaround can be a preferable alternative to the many hours that reencoding may require.
This approach works for x264 mp4 videos with mp3 audio wrapped into an flv. With modification, though, the approach should apply to videos created with different encoders and audios.
The downloadable freeware tools required are: FLVExtractCL.exe, MP4Box.exe/libgpac.dll, ffmpeg.exe, and yamdi.exe.
The procedure sequence is:
1. FLVExtract to demux a movie.flv file into separate movie.264 and audio files.
2. MP4box to add a PAR aspect ratio flag to the movie.264 file and save it as movie.mp4.
3. ffmpeg to mux the movie.mp4 and the audio file into a new flv.
4. yamdi to add/replace metadata assigning width and height values to 0.
5. The final step is to specify bufferLength: "0" in the flowplayer script configuration.
Here is an example "convert flv.bat" script I used to change a 23.976 fps video encoded at 720x480, (aspect ratio of 1.5) but needing correction to an aspect ratio of 2.333.
PAR conversion calculation = 2.333/1.5 = 1.555:1 = 14:9 (determine closest integer ratio and edit into the bat file.)
Put all the files in the same folder, compose and then run the bat file.
-----------------folder contents-------------------
convert flv.bat
ffmpeg.exe
FLVExtractCL.exe
libgpac.dll
movie.flv
MP4Box.exe
yamdi.exe
-------------------end of folder--------------------
--------------convert flv.bat contents------------
:: Demux flv into separate video and audio files, 264 and mp3 for example.
FLVExtractcl -v -a movie.flv
:: Set PAR aspect ratio flag. par=width:height ratio integers and -fps to the fps of movie.flv
:: When the bat file runs, verify that the displayed video fps and encoding fps are equal.
mp4box -add movie.264#1:par=14:9 -fps 23.976 -nodrop movie.mp4
:: Remux video and audio to a new flv
ffmpeg -i movie.mp4 -vcodec copy -i movie.mp3 -acodec copy temp.flv
:: Set metadata height and width to 0. Final output to movie2.flv.
yamdi -i temp.flv -o movie2.flv
:: Delete intermediate files
del movie.264
del movie.mp3
del movie.mp4
del temp.flv
:: Pause to keep dos window open to check for errors if conversion fails.
pause
---------------------end of bat---------------------
Conversion success can be verified with a downloadable freeware flv viewer such as FLV Player 2.0.
This is part of the script for flowplayer I use to play corrected videos in fullscreen without the stretching or squashing associated with the originals. The expected video aspect ratio is seen with properly assigned black borders top/bottom or left/right.
<script>
flowplayer("player", "flowplayer-3.1.4.swf",
{clip: {
url: "movie2.flv",
scaling: "fit", bufferLength: "0"
}});
</script>
Why this procedure works is somewhat a mystery but I've applied it to all 50+ movies in my Intranet library without any failures.
lol