I'm having trouble with a usually working ffmpeg script for encoding mp4 and more to wmv. The goal is to keep it like the original, except for the resolution (smaller) and the format (wmv).
When it usually works for a lot of videos, on some of them it doesn't... and i would like to understand and avoid that.
I tried several things, forcing the framerate for the output, using -vsync 2 option, -vsync 0 also.. noone of that fixed the issue.
An other thing, worth adding, is that the fps value from media info is good (24 fps) on the output like the input, but through the M$ windows explorer, it says 30 frames per sec, and when you play the video you see that the text that was matching the input doesn't match the output any more (because of the fps mismatching).
Below the script i use :
ffmpeg -threads auto -i input.mp4 -s 480*320 -b:v 1000k -vcodec msmpeg4 -acodec wmav2 -f asf output.wmv
Here is the ffmpeg log :
ffmpeg version 3.4.1-1~16.04.york0 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.5) 20160609
configuration: --prefix=/usr --extra-version='1~16.04.york0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version='1~16.04.york0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './test_2k-24__hq_960x540.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41isomavc1
creation_time : 2019-05-27T14:37:50.000000Z
Duration: 01:28:52.80, start: 0.000000, bitrate: 1232 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 960x540, 1091 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc (default)
Metadata:
creation_time : 2019-05-27T14:37:50.000000Z
handler_name : L-SMASH Video Handler
encoder : AVC Coding
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 137 kb/s (default)
Metadata:
creation_time : 2019-05-27T14:37:50.000000Z
handler_name : L-SMASH Audio Handler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> msmpeg4v3 (msmpeg4))
Stream #0:1 -> #0:1 (aac (native) -> wmav2 (native))
Press [q] to stop, [?] for help
Output #0, asf, to '/nas/copiedetravail/test_2k-24__hq_960x540.mp4.wmv':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41isomavc1
WM/EncodingSettings: Lavf57.83.100
Stream #0:0(und): Video: msmpeg4v3 (msmpeg4) (MP43 / 0x3334504D), yuv420p(progressive), 480x320, q=2-31, 1000 kb/s, 24 fps, 1k tbn, 24 tbc (default)
Metadata:
creation_time : 2019-05-27T14:37:50.000000Z
handler_name : L-SMASH Video Handler
encoder : Lavc57.107.100 msmpeg4
Side data:
cpb: bitrate max/min/avg: 0/0/1000000 buffer size: 0 vbv_delay: -1
Stream #0:1(und): Audio: wmav2 (a[1][0][0] / 0x0161), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2019-05-27T14:37:50.000000Z
handler_name : L-SMASH Audio Handler
encoder : Lavc57.107.100 wmav2
[msmpeg4 @ 0x5648e407cb60] warning, clipping 1 dct coefficients to -127..127
Last message repeated 31 times
frame= 228 fps=0.0 q=2.0 size= 291kB time=00:00:09.45 bitrate= 252.4kbits/s speed=18.9x
[msmpeg4 @ 0x5648e407cb60] warning, clipping 2 dct coefficients to -127..127
[msmpeg4 @ 0x5648e407cb60] warning, clipping 1 dct coefficients to -127..127
Last message repeated 1 times
[msmpeg4 @ 0x5648e407cb60] warning, clipping 2 dct coefficients to -127..127
[msmpeg4 @ 0x5648e407cb60] warning, clipping 1 dct coefficients to -127..127
[msmpeg4 @ 0x5648e407cb60] warning, clipping 2 dct coefficients to -127..127
[msmpeg4 @ 0x5648e407cb60] warning, clipping 1 dct coefficients to -127..127
[msmpeg4 @ 0x5648e407cb60] warning, clipping 2 dct coefficients to -127..127
Last message repeated 1 times
[msmpeg4 @ 0x5648e407cb60] warning, clipping 1 dct coefficients to -127..127
[msmpeg4 @ 0x5648e407cb60] warning, clipping 2 dct coefficients to -127..127
Last message repeated 1 times
[msmpeg4 @ 0x5648e407cb60] warning, clipping 1 dct coefficients to -127..127
[msmpeg4 @ 0x5648e407cb60] warning, clipping 2 dct coefficients to -127..127
Last message repeated 5 times
[msmpeg4 @ 0x5648e407cb60] warning, clipping 1 dct coefficients to -127..127
Last message repeated 2 times
frame= 449 fps=449 q=2.0 size= 663kB time=00:00:18.98 bitrate= 286.2kbits/s speed= 19x
frame= 629 fps=418 q=1.6 size= 1307kB time=00:00:26.16 bitrate= 409.2kbits/s speed=17.4x
[msmpeg4 @ 0x5648e407cb60] warning, clipping 1 dct coefficients to -127..127
Last message repeated 30 times
[msmpeg4 @ 0x5648e407cb60] warning, clipping 2 dct coefficients to -127..127
[msmpeg4 @ 0x5648e407cb60] warning, clipping 1 dct coefficients to -127..127
Last message repeated 7 times
[msmpeg4 @ 0x5648e407cb60] warning, clipping 2 dct coefficients to -127..127
[msmpeg4 @ 0x5648e407cb60] warning, clipping 1 dct coefficients to -127..127
Last message repeated 2 times
[msmpeg4 @ 0x5648e407cb60] warning, clipping 2 dct coefficients to -127..127
[msmpeg4 @ 0x5648e407cb60] warning, clipping 1 dct coefficients to -127..127
Last message repeated 34 times
[msmpeg4 @ 0x5648e407cb60] warning, clipping 2 dct coefficients to -127..127
[msmpeg4 @ 0x5648e407cb60] warning, clipping 1 dct coefficients to -127..127
Last message repeated 1 times
frame= 821 fps=410 q=2.0 size= 1960kB time=00:00:34.26 bitrate= 468.7kbits/s speed=17.1x
[msmpeg4 @ 0x5648e407cb60] warning, clipping 2 dct coefficients to -127..127
[msmpeg4 @ 0x5648e407cb60] warning, clipping 1 dct coefficients to -127..127
Last message repeated 71 times
[msmpeg4 @ 0x5648e407cb60] warning, clipping 2 dct coefficients to -127..127
[msmpeg4 @ 0x5648e407cb60] warning, clipping 1 dct coefficients to -127..127
Last message repeated 82 times
frame= 1026 fps=409 q=2.0 size= 2695kB time=00:00:42.96 bitrate= 513.8kbits/s speed=17.1x
[msmpeg4 @ 0x5648e407cb60] warning, clipping 1 dct coefficients to -127..127
Last message repeated 102 times
frame= 1202 fps=400 q=1.6 size= 3754kB time=00:00:50.13 bitrate= 613.4kbits/s speed=16.7x
......
frame=127987 fps=301 q=2.0 Lsize= 753842kB time=01:28:52.77 bitrate=1158.0kbits/s speed=12.6x
video:650704kB audio:83244kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.710554%
EDIT : My workaround was to encode to MPEG, doing this, i'm able to read my file and the frame rate is same as source. If someone knows why it couldn't keep the original framerate in wmv, i'm still interested to know.