Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Manipulating video, audio or image file using ImageMagick & FFmpeg

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 1.82k
    Comment on it

    We can customize our video, audio or image file with help of tools like FFmpeg , ImageMagick

    FFmpeg is very useful command-line tool that converts audio or video formats.

    ImageMagick is a tool which can be used to edit, create, compose, or convert bitmap images.


    1. Command to change the orientation of a video.
    2. ffmpeg -i inputvideo -vf "transpose=1" outputvideo The above command will rotate the input video clockwise 90 degree Other parameters for transpose are as below:
      1. For 90 degree anti clockwise and vertical flip (which is default) put transpose = 0.
      2. For 90 degree clockwise put transpose = 1.
      3. For 90 degree anti clockwise put transpose = 2.
      4. For 90 degree clockwise and vertical flip transpose = 3.

    3. Cutting video file into a smaller clips
    4. You can use the time offset parameter (-ss) to specify the start time stamp in HH:MM:SS.ms format while the -t parameter is for specifying the actual duration of the clip in seconds.

      ffmpeg -i <input.mp4> -ss 00:00:50.0 -codec copy -t 20 <output.mp4>
      

    5. Converting videos from .mov format to .mp4 format.
    6. For converting videos in .mov format into .mp4 we use a command as below:

      Make sure the path of FFmpeg tool is also wirten before writing the below line.

      ffmpeg -i <input> -c:v libx264 -profile:v baseline -filter:v scale=640:-1 -c:a libfaac -ar 44100 -ac 2 -b:a 128k -movflags faststart <output>
      

      Note: One should be very careful of spaces while writing the commands. Also make sure that what- ever options we want to implement on the output file we should place it after the input option (i.e. -i input).


    7. Creating cropped thumbnail without changing the Aspect Ratio of thumbnail with black background that will fill the sides of the thumbnail.
    8. Aspect Ratio can be defined as an attribute of an image that describes the proportionality between the width and height of an image. This is a done using ImagicMagic command as below:

      convert <inputfile>  \( +clone -background black -rotate 90 -size 240x140 \) -gravity north -compose Src -composite <outputfile>
      

    9. Cutting video file into a smaller clip
    10. We can use the time offset parameter (-ss) to specify the start time stamp in HH:MM:SS.ms format while the -t parameter is for specifying the actual duration of the clip in seconds.

      ffmpeg -i <input.mp4> -ss 00:00:50.0 -codec copy -t 20 <output.mp4>
      

    11. Remove the audio component from a video
    12. Use the -an parameter to disable the audio portion of a video stream.

      ffmpeg -i video.mp4 -an mute-video.mp4
      

    13. Getting the audio from video
    14. The -vn switch extracts the audio portion from a video and we are using the -ab switch to save the audio as a 256kbps MP3 audio file.

      ffmpeg -i myVideo.mp4 -vn -ab 256 myAudio.mp3
      

    15. Get an image frame from a video
    16. The following command will extract the video frame at the 25s mark and saves it as a 700px wide JPEG image.

      ffmpeg -ss 00:00:15 -i video.mp4 -vf scale=800:-1 -vframes 1 image.jpg
      

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: