This method using FFMPEG PC version to acheive.
slow_to_normal_1.bat
"%~dp0ffmpeg.exe" -y -i %1 -vn -af "asetrate=48000*4" "%~dpn1.wav" "%~dp0ffmpeg.exe" -y -i %1 -an -c:v copy "%~dpn1.h264" "%~dp0ffmpeg.exe" -y -r 120 -i "%~dpn1.h264" -i "%~dpn1.wav" -c:v copy -c:a aac -b:a 320k "%~dpn1-remux-4x.mp4" del "%~dpn1.h264" "%~dpn1.wav"
slow_to_normal_2.bat
"%~dp0ffmpeg.exe" -hide_banner -y -itsscale 0.25 -i %1 -c:v copy -af "asetrate=48000*4,atempo=1" -c:a aac -b:a 320k "%~dpn1-4x.mp4"
Procedure:
As Xperia 1 record slow motion viedo, the format is MP4(30fps H.264 AVC + 48kHz 150kbps AAC), and speed is 0.25x.
For video, to keep all the frame and not to re-encode, need to modify frame rate only. The bad news is there are only two way to keep all the frames, one is bitstream mode, the other is itsscale.
For the bitstream mode, it need to extrect H264 to raw file, and use "-r" to re-assign timestamps. This method will not modify frame.
For audio stream, since AAC cannot speed up to 192khz, i choose re-assign 48kHz as 192kHz audio, and save it to wav. Since best AAC frequency is 96k, FFMPEG will auto resample to 96kHz.
For easier way, choose itsscale 0.25 times, re-assign audio rate (asetrate) and assign tempo. If tempo not assign, output file will be kind of weired. But this method will keep video FPS is not constant, i don't know what will happend so i like method 1 more.
reference:
- https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
- https://stackoverflow.com/questions/45462731/using-ffmpeg-to-change-framerate/68973714#68973714
快速用中文紀錄一下。兩種方法,一種用bitstream去硬幹掉時間戳記,有著固定的FPS,代價是比另外一個做法多一倍原檔案容量。另一個作法比較新,直接調整影片的戳記,但不知為何音軌不會動到,所以還要再重新指派頻率,然後不設定tempo他播放時又怪怪的,所以要指定tempo。
輸出屆時會是120fps的影片,算是拯救不小心按成慢動作的作法。
可惜沒有在手機上就快速處理完的做法。
沒有留言:
張貼留言