News:

The Latest electronic and computer Tips that work!

Main Menu

Convert Media Using FFmpeg

Started by branx86, September 19, 2018, 12:03:23 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

branx86

.AVI VIDEO TO .MPG
ffmpeg –i – Shawshank_Redemption.avi  Shawshank_Redemption.mpg

ffmpeg -i video.flv video.mpeg

.MP4 to .WMV:
ffmpeg –i  – video_name.wmv final_video_name.mp4

.AVI to .FLV:
ffmpeg –i  – original_video.avi –f flv final_video.flv

PAL format

ffmpeg –i  –original_video.avi –target pal-svcd final_video.mpg

NTSC format:

ffmpeg –i  –original_video.avi –target ntsc-svcd final_video.mpg

You can use the command to copy the video in any format.
ffmpeg –i  –origine.mp4 –c:v copy –c:a copy –final.mkv



copy the audio of a video
ffmpeg –i  –origine.mp4 –vn –acodec copy audio.aac


display your media file details
ffmpeg -i video.mp4


convert input.mp4 video file to output.mp3 audio file
ffmpeg -i input.mp4 -vn -ab 320 output.mp3

ffmpeg -i input.mp4 -vn -ar 44100 -ac 2 -ab 320 -f mp3 output.mp3

    -vn – Indicates that we have disabled video recording in the output file.
    -ar – Set the audio frequency of the output file. The common values used are  22050, 44100, 48000 Hz.
    -ac – Set the number of audio channels.
    -ab – Indicates the audio bitrate.
    -f – Output file format. In our case, it's mp3 format.

compress audio files using -ab flag in order to save some disk space
ffmpeg -i input.mp3 -ab 128 output.mp3

The list of various available audio bitrates are:

    96kbps
    112kbps
    128kbps
    160kbps
    192kbps
    256kbps
    320kbps


convert the first 50 seconds of given video.mp4 file to video.avi format
ffmpeg -i input.mp4  -t 50 output.avi

split the large video files into multiple smaller parts
ffmpeg -i input.mp4 -t 00:00:30 -c copy part1.mp4 -ss 00:00:30 -codec copy part2.mp4

Create join.txt file that contains the exact paths of the files that you want to join. All files should be same format (same codec). The path name of all files should be mentioned one by one like below.

/home/sk/myvideos/part1.mp4
/home/sk/myvideos/part2.mp4
/home/sk/myvideos/part3.mp4
/home/sk/myvideos/part4.mp4

Now, join all files using command:

$ ffmpeg -f concat -i join.txt -c copy output.mp4

The above command will join part1.mp4, part2.mp4, part3.mp4, and part4,mp4 files into a single file called "output.mp4".


Play Video
ffplay video.mp4
Play Audio
ffplay audio.mp3