17

I am converting videos with extension "flv","avi","mp4","mkv", "mpg", "wmv", "asf", "webm","mov","3gp","3gpp" into "mp4" for a better quality.

Command I am using:

ffmpeg -i <server_path>/g9zyy2qg54qp1l5spo2-mergedFile.webm -strict -2 -vcodec libx264 -preset slow -vb 500k -maxrate 500k -bufsize 1000k -vf 'scale=-1:480 ' -threads 0 -ab 64k -s 640x480 -movflags faststart -metadata:s:v:0 rotate=0 <server_path>/g9zyy2qg54qp1l5spo2-mergedFile7.mp4

Videos are working fine everywhere except on Windows. No Video is working on window platform. I tried playing them on firefox, opera, even downloaded them and played on media player software but didn't work at all.

Can you please tell me codecs I should use that make the videos play on windows as well?

Curious Developer
  • 705
  • 3
  • 9
  • 29
  • 3
    possibly need to add -pix_fmt yuv420p for older players? – rogerdpack Jan 22 '16 at 19:53
  • @rogerdpack thanks for replying back. I have tried using your mentioned command as well. But it didn't work. My goal is to make a query that can make every video on my website play in all browsers on platforms, whether its on linux, unix, windows, or mac. Currently not all videos are playing on window browsers. – Curious Developer Jan 23 '16 at 05:12
  • I have created the above webm file by recording user's audio/video input via webRTC and merged the file into webm format. This file is running on window browser but after conversion to mp4 it is not running in the same browser as well. Though running fine on linux platform. – Curious Developer Jan 23 '16 at 05:42
  • where/how are you testing it in windows (which os/browser fails)? did your answer say you got it to work? What was the difference? For the record, you shouldn't need to use -strict -2 to encode to aac anymore, recent versions of fffmpeg have an "improved quality" aac encoder that is not experimental anymore. – rogerdpack Jan 23 '16 at 17:16
  • Yes, I have fixed the problem. I am using command "ffmpeg -fflags +genpts -i {$videoFile} -i {$audioFile} -strict -2 -r 24 {$mp4File}" to merge a video (.webm) and audio (.wav) file into 1 .mp4 file. This file is playing properly on window browsers as well as linux browsers. This file will then added to the above mentioned command to add more codecs, so that it will work on all platforms, window, ios, android. Though I checked only in window 7, i believe it will work on all windows. Earlier it wasn't working here as well. I am not using a recent version of ffmpeg. I am using version 2.2. – Curious Developer Jan 25 '16 at 04:51
  • So what is the difference in "final codec" between that and what you started with? was it just the fflags that was missing? – rogerdpack Jan 25 '16 at 13:16
  • The command I started with was perfect, except when I used to record videos from certain platform they were not opening/playing in window browsers. I thought if the main query need few more touches. But then I found that I can make changes in the process where I am fetching/making recorded videos. My Answer 2 have those commands. Fixing Answer 2 commands have fixed the whole problem. – Curious Developer Jan 27 '16 at 05:14

3 Answers3

27

My video gets played in Windows 10 after adding parameters about pix_fmt and resolution (width and height should be even number):

ffmpeg -i temp-%d.png -c:v libx264 -strict -2 -preset slow -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -f mp4 output.mp4

ppppplv
  • 421
  • 1
  • 5
  • 6
1

Use

"ffmpeg -i {$audioFile} -i {$videoFile} -map 1:0 -map 0:0 -strict -2 -vcodec libx264 -preset slow -vb 500k -maxrate 500k -bufsize 1000k -vf 'scale=-1:480 ' -threads 0 -ab 64k -s 640x480 -movflags +faststart -metadata:s:v:0 rotate=0 -fflags +genpts <server_path>/g9zyy2qg54qp1l5spo2-mergedFile7.mp4

(this uses the original command in your question)

Gyan
  • 85,394
  • 9
  • 169
  • 201
0

Found a fix here convert webm to mp4. Now after getting merged webm file I am converting it to mp4 using command "ffmpeg -fflags +genpts -i 1.webm -r 24 1.mp4". This mp4 file is playing in window browsers.

For the above process I have to use 2 ffmpeg commands. 1.To make merge audio/video file into 1 webm file and

"ffmpeg -i {$audioFile} -i {$videoFile} -map 0:0 -map 1:0 -strict -2 {$mergedFileName}"
  1. To make mp4 file.

    "ffmpeg -fflags +genpts -i {$mergedFile} -strict -2 -r 24 {$mp4File}"

Can I club above 2 commands which input audio & video files to give me single mp4 file?

Edit: I have clubbed the above 2 commands

 "ffmpeg -fflags +genpts -i {$videoFile} -i {$audioFile} -strict -2 -r 24 {$mp4File}" 

Its working well for me. The result mp4 video is playing in window 7 (chrome, firefox, opera) browsers. Also working in Linux (firefox, Opera ) browsers.

Community
  • 1
  • 1
Curious Developer
  • 705
  • 3
  • 9
  • 29
  • Sorry for confusion @Mulvya. I needed merging & conversion in the 2 commands mentioned above. I have already found the solution for playing videos in window browsers. Currently I am working on it and clubbed the above command as "ffmpeg -fflags +genpts -i {$videoFile} -i {$audioFile} -strict -2 -r 24 {$mp4File}" . This command is doing what the above 2 commands were doing, except it is not making webm file, which is good. So currently my problem is solved. I am testing it for more scenarios if it is working perfectly. – Curious Developer Jan 23 '16 at 08:11