4

I am trying to convert a MPEG4 video to AMV via ffmpeg. I've searched through web about the appropriate formatand and also tried to check another AMV video parametrs. So I've found that there should be bitrate for sound 22050 for sound with adpcm_ima_amv sound format, pixel format should be probably yuvj420p and the video size should be probably 160x120. So I've created a video with the same size and tried various types of commands, following at last:

ffmpeg.exe -i "c:\source160x120.mp4" -c:v amv -c:a adpcm_ima_amv -pix_fmt yuvj420p -vstrict -1 -s 160x120 -ar 22050 -b:a 40400 "c:\destination.amv"

However I am still getting following errors:

Only mono is supported Error initializing output stream 0:1 -- Error
while opening encoder for output stream #0:1 - maybe incorrect
parameters such as bit_rate, rate, width or height

I've also tried to change it to mono as following but there were just got even more errors:

ffmpeg.exe -i "c:\source160x120.mp4" -c:v amv -c:a adpcm_ima_amv -pix_fmt yuvj420p -vstrict -1 -s 160x120 -ar 22050 -b:a 40400 -af pan="mono| c0=FL" "c:\destination.amv"

The errors:

[Parsed_pan_0 @ 000002914a4d3cc0] Pure channel mapping detected: 0
[swscaler @ 000002914a60e9c0] deprecated pixel format used, make sure you did set range correctly
[amv @ 000002914a436c00] Invalid audio frame size. Got 1024, wanted 1378
[amv @ 000002914a436c00] Invalid audio block align. Got 520, wanted 697
[amv @ 000002914a436c00] Try -block_size 1378
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
Conversion failed!

Do you know, what I am missing in the command or how I could make it work? I am quite new in ffmpeg.

Thanks for the help!

. . . . .

Btw: One AMV video that I tried to copy by ffmpeg to find out how it is made get following result during copying if it helps:

scale/rate is 0/0 which is invalid. (This file has been generated by broken software.) Last message repeated 1 times Guessed Channel Layout for Input Stream #0.1 : mono Input #0, avi, from '..\1.8_Test-2.amv': Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: amv, yuvj420p(pc, bt470bg/unknown/unknown), 160x120, 16 fps, 16 tbr, 16 tbn, 16 tbc Stream #0:1: Audio: adpcm_ima_amv ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 88 kb/s File 'test1.amv' already exists. Overwrite? [y/N] y Output #0, amv, to 'test1.amv': Metadata: encoder : Lavf58.76.100 Stream #0:0: Video: amv, yuvj420p(pc, bt470bg/unknown/unknown), 160x120, q=2-31, 16 fps, 16 tbr, 16 tbn, 16 tbc Stream #0:1: Audio: adpcm_ima_amv ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 88 kb/s Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help [amv @ 0000021460f90800] Invalid audio packet size (698 != 697)rate= 40.4kbits/s speed=1.04e+04x Last message repeated 136 times frame= 992 fps=0.0 q=-1.0 Lsize= 5031kB time=00:01:02.00 bitrate= 664.7kbits/s speed= 122x video:4339kB audio:675kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.315401%

2 Answers 2

1
ffmpeg -i input.mp4 -ac 1 -ar 22050 -r 25 -block_size 882 output.amv
  • Audio channel layout must be mono (-ac 1).
  • Audio sample rate must be 22050 (-ar 22050).
  • Frame rate must be divisible by the audio sample rate (22050). So frame rate (-r) can be 10, 14, 15, 18, 21, 25, 30, etc.
  • -block_size depends on frame rate. The console output will tell you what to use. Example message: Try -block_size 1378.
2
  • 1
    Thanks for the quick help! Your parameters worked so the video was converted, checked on the player that it was converted for and it looks like it works includint timing and all! The command that was successfully used is following: ffmpeg.exe -i "c:\input160x120.mp4" -c:v amv -c:a adpcm_ima_amv -pix_fmt yuvj420p -vstrict -1 -s 160x120 -ac 1 -ar 22050 -r 25 -block_size 882 "c:\output.amv" Commented May 14, 2021 at 20:19
  • Btw. there also helped me following command although it is not probably fully correct: ffprobe -i "test1.amv" -request_sample_fmt adpcm_ima_amv Commented May 14, 2021 at 20:29
3

Thanks for the quick help!

Your parameters worked so the video was converted, checked on the player that it was converted for and it looks like it works includin timing and all!

The command that was successfully used is following:

ffmpeg.exe -i "c:\input160x120.mp4" -c:v amv -c:a adpcm_ima_amv -pix_fmt yuvj420p -vstrict -1 -s 160x120 -ac 1 -ar 22050 -r 25 -block_size 882 "c:\output.amv"

4
  • No need for -c:v amv -c:a adpcm_ima_amv -pix_fmt yuvj420p. All that will be selected automatically. -vstrict -1 isn't doing anything.
    – llogan
    Commented May 14, 2021 at 20:59
  • Well, just tried it as following: ffmpeg.exe -i "c:\input160x120.mp4" -s 160x120 -ac 1 -ar 22050 -r 25 -block_size 882 "c:\output.amv" and it wrote following errors: [amv @ 000001de51bf1000] Heights which are not a multiple of 16 might fail with some decoders, use vstrict=-1 / -strict -1 to use 120 anyway. [amv @ 000001de51bf1000] If you have a device that plays AMV videos, please test if videos with such heights work with it and report your findings to [email protected] Video encoding failed. I've checked that with that -vstrict -1 option and it worked. Commented May 14, 2021 at 21:55
  • So there also worked following for me according to your next suggestion: ffmpeg.exe -i "c:\input160x120.mp4" -s 160x120 -ac 1 -ar 22050 -r 25 -block_size 882 -vstrict -1 "c:\output.amv" but didn't found out why it is so needed. Brief checked some online documentation and found nothing so quickly. Maybe will check it later. Btw. am I suggesting correctly that the block size is sample rate / frame rate? Is there somewhere some web where is the problematic described some friendly and deeper way? Commented May 14, 2021 at 22:06
  • Just bought a video player for $18.99 (amazon.com/dp/B0CJQYHVH1) and your command finally made me able to convert a video that plays on it
    – qwertzguy
    Commented Oct 25, 2023 at 7:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .