Ik heb een bash script gemaakt dat drie keer user input vraagt. Het is de bedoeling dat twee commando's voor ffmpeg via dat script wat handiger te gebruiken worden. Bovendien hoef ik de boel dan niet te onthouden of via history die commando's weer op te zoeken.
De opdrachten maken via ffmpeg eerst uit een video van mijn videocamera een uitsnede (een clip) vanaf een bepaald moment en van een bepaalde duur. Dan vervolgens wordt de afspeelsnelheid van die korte clip stevig teruggebracht en heb ik een slow motion replay. Vroeger kon ik dat direct in de Openshot video editor via de eigenschappen. Maar dat is niet meer zo, zowel niet op mijn laptop als op de desktop waar ik sinds kort op werk. Er is daar een bug van, waarin Openshot aangeeft dat het programma daarvoor ffmpeg gebruikt en aanbeveelt om dat soort dingen rechtstreeks in ffmpeg te doen.
Nou hou ik wel van scripts maken en nou dan maar eens voor het eerst MET user input.
De twee basis commando's zijn
ffmpeg -ss 00:01:12 -t 00:00:09 -i TEST.MPG -acodec copy -vcodec copy clip-output-file.mp4
en
ffmpeg -i clip-output-file.mp4 -vf "setpts=2.0*PTS" output-slow.mp4
Die resulteren op zich in een nette slow motion video. Niks mis zover.
Het script wat ik gemaakt heb is als volgt:
#!/bin/sh
# Script to create a slow motion clip from a MPG video with ffmpeg. Find start point of the clip in hh:mm:ss and the length of the clip in hh:mm:ss.
echo "This script will change a clip to a slow motion clip. It will ask for the start point in hh:mm:ss format first, then clip duration "
echo "Output will be to a file output-slow.mp4 "
# Ask file name of original video
echo "Give the file name of the original video (must be MPG!!) "
read NAME
# Ask start point
echo "Enter start point of the clip in hh:mm:ss "
read START
# Ask clip length
echo "Enter clip length in hh:mm:ss "
read LENGTH
# creating the clip
ffmpeg -ss $START -t $LENGTH -i $NAME -acodec copy -vcodec copy clip-output-file.mp4
# setting slow motion speed at 1/2 speed
ffmpeg -i clip-output-file.mp4 -vf "setpts=2.0*PTS" output-slow.mp4
Dan krijg ik vervolgens de output:
This script will change a clip to a slow motion clip. It will ask for the start point in hh:mm:ss format first, then clip duration
Output will be to a file output-slow.mp4
Give the file name of the original video (must be MPG!!)
TEST.MPG
Enter start point of the clip in hh:mm:ss
00:01:10
Enter clip length in hh:mm:ss
00:00:09
ffmpeg version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
built on Jun 12 2012 16:37:58 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Input #0, mpeg, from 'TEST.MPG':
Duration: 00:01:21.56, start: 0.114967, bitrate: 9541 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x576 [PAR 64:45 DAR 16:9], 9100 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0.1[0x80]: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
File 'clip-output-file.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'clip-output-file.mp4':
Metadata:
encoder : Lavf53.21.0
Stream #0.0: Video: mpeg2video, yuv420p, 720x576 [PAR 64:45 DAR 16:9], q=2-31, 9100 kb/s, 25 tbn, 25 tbc
Stream #0.1: Audio: ac3, 48000 Hz, stereo, 256 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press ctrl-c to stop encoding
[mp4 @ 0x8840bc0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1 >= 1
av_interleaved_write_frame(): Invalid argument
ffmpeg version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
built on Jun 12 2012 16:37:58 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x9d00260] moov atom not found
clip-output-file.mp4: Invalid data found when processing input
[/quote]
Dat loopt dus stuk. Ik denk dat de manier waarop ik die drie "user input" gegevens in het script heb verwerkt niet goed is - of niet goed voor ffmpeg. Bij afspelen van het bestand clip-output-file.mp4 komt VLC met een overeenkomstige foutboodschap. Dus gaat het bij de eerste opdracht al fout.
Deze video staat (zonder slow motion replays) al op Youtube. Kijk desgewenst hier: http://youtu.be/YNTWZvA7Mk4 Het tijdstip wat ik in de replay wil laten zien is de aanval rond 4:29 waarin een speler uit een vrije worp de bal krijgt en die onder water duwt. Dat mag niet en hij krijgt een vrije worp tegen. De slow motion replay, die ik met de losse opdrachten realiseerde, liet me zien dat de verdediger al - voordat de bal er was - de aanvaller aan het onderduwen was. Dat mag ook weer niet. Dus eigenlijk had die aanvaller ten onrechte een vrije worp tegen gekregen. Zo leer je weer wat, nietwaar.
Leuke klus zover. Maar wat doe ik hier nou fout?
met vriendelijke groeten,
Just Vecht