Saturday, June 4

Project HB - 3. Convert, Crop, Silence



If you have not read Part 2, please read it here.




Running FFmpeg

Executing FFmpeg can be broken up into several distinct sections, though for this first run we will be doing the bare minimum required.


1. Convert Source Video to MP4


Parts of the command
    • ffmpeg
      • This tells your shell that you want to run the program "ffmpeg" and everything after the space is what you want to tell ffmpeg.
    • -i !SourceMovie!.MOV
      • -i tells ffmpeg that the next part is a filename, and to use that file as an input
      • ie: input file "!SourceMovie!.MOV"
    • out.1.mp4
      • The filename that is at the end of the line is what ffmpeg uses to save your newly created file.

Running FFmpeg


FFmpeg - Done


What this has done, is converted every frame of the source video, into a H264 encoded MP4 file. Now almost any media player capable of play H264 files can play this one. Also the output file has shrank from the original's 21,118,114 bytes to only 6,602,656 bytes. Less then 25% of the original's file size.
  • Video:
    • MPEG4 Video (H264)
    • 720x1280
    • 29.97fps
    • 3222kbps
  • Audio
    • AAC
    • 44100Hz
    • mono
    • 72kbps


2. Crop video

Parts of the command
  • ffmpeg
    • This tells your shell that you want to run the program "ffmpeg" and everything after the space is what you want to tell ffmpeg.
  • -i !SourceMovie!.MOV
    • -i tells ffmpeg that the next part is a filename, and to use that file as an input
    • ie: input file "!SourceMovie!.MOV"
  • -filter_complex "[0:v] crop=in_w:in_h-200"
    • -filter_complex
      • this tells FFmpeg that you want to make some changes to the input file
    • "      "
      • everything inside the quotation marks are the arguments for the filters
    • [0:v]
      • "0" declares we will be using input file 0, or the first input file
      • "v" declares we will be using the video portion of the input file
    • crop=in_w:in_h-200
      • crop=
        • is the filter we want to use
        • options
          • crop=width:height
          • crop=width:height:x:y
      • in_w
        • width of the input file
      • in_h-200
        • subtract 200px from the height of the input file
  • out.2a.mp4
    • The filename that is at the end of the line is what ffmpeg uses to save your newly created file.
<--- Original           Cropped ---> 

Interestingly enough, when I was filming this clip, I had my phone set on rotation lock, and accidentally recorded this video with the camera think it was in landscape mode. The reason why this becomes a little bit of an issue is: Most modern video players are smart enough to check the rotation of the video and try to play the video properly. Even FFmpeg does a good job of passing the rotation setting of the input through too the output video.

This means even though it appears that the source video is portrait mode, the data for the video is actually landscape mode. So when it comes time to crop the video you need to think that the width is actually the height, and the height is actually the width.

 Crop version 2.


We are cropping the input file. The output will be 400px shorter and 60px narrower then the source. We are going to be keeping the video data that starts at 60px from the left and 320px from the top. This will crop some unnecessary text, and some of the shadow from the original file.

Result

I am left with a dancing rodent, and the words "Happy Birthday". Exactly the part that I wanted from the source video.


3. Making a silent video

All you need to do to make the final output video have no sound: Is to add "-an" before the output filename.




Continue with ...

Part 2 - The SetupPart 4 - ???

0 comments :

Post a Comment