Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
28th March 2014, 00:39 | #1 | Link |
Registered User
Join Date: Mar 2014
Posts: 14
|
FFMPEG - Adding splash image to front of video
I have tried many different ways to try to create a 10 second video file out of an image file and have used all the same switches and codecs as I used to encode my video file. However, when I concat the two using anything but complex_filter (which forces the video through another round of transcoding), the resulting video file is corrupt. I believe this is due to the inherent differences of the 10 second clip that ffmpeg created from the image, but there must be some way to get it to encode the exact same way as my video file.
Here is the command I am using to turn the image into a 10s video clip (I added a silent mp3 because I thought that an audio stream starting partway through the video was messing things up): Code:
ffmpeg -loop 1 -i splash.jpg -i silence.mp3 -c:v libx264 -preset slow -g 60 -r 29.97 -crf 16 -c:a libfdk_aac -b:a 256k -cutoff 18000 -t 5 tmpoutput1.mp4 Code:
ffmpeg -i input.f4v -c:v libx264 -preset slow -g 60 -r 29.97 -crf 16 -c:a libfdk_aac -b:a 256k -cutoff 18000 tmpoutput2.mp4 Code:
ffmpeg -i tmpoutput1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts tmpoutput1.ts Code:
ffmpeg -i "concat:tmpoutput1.ts|tmpoutput2.ts" -c copy output.mp4 Has anyone successfully added a full-frame splash graphic to the front of a video with ffmpeg before? I am using a brand new cross-compile of ffmpeg as I thought that might be the issue, but alas, the issue persists after the update. Thanks! |
28th March 2014, 01:10 | #2 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,340
|
1) It's recommended to use concat demuxer, which works at the stream level, instead of concat protocol which works at the container level
http://trac.ffmpeg.org/wiki/How%20to%20concatenate%20%28join,%20merge%29%20media%20files 2) When using x264, encoding with --stitchable may improve your chances of successfully appending segments. In ffmpeg libx264 it would be -x264-params stitchable 3) There is always a chance something may go wrong when appending segments for whatever reason. A foolproof way would be to join before with a script (eg. avisynth), and encode in 1 go with ffmpeg. ffmpeg can be compiled with avs support. Last edited by poisondeathray; 28th March 2014 at 01:18. |
28th March 2014, 01:39 | #3 | Link |
ангел смерти
Join Date: Nov 2004
Location: Lost
Posts: 9,556
|
Try it with:
Code:
ffmpeg .... <input and x264 options> -x264opts sps-id=X <other options> Edit: Ah, yes, I forgot about stitchable. With identical settings you won't need different sps-ids in that case. |
28th March 2014, 19:02 | #4 | Link |
Registered User
Join Date: Mar 2014
Posts: 5
|
Just tested what your advised. It works. Commands was:
Code:
ffmpeg -i seg01.mkv -c:v libx264 ... -x264opts sps-id=1 ... seg01-sps1.mkv ffmpeg -i seg02.mkv -c:v libx264 ... -x264opts sps-id=2 ... seg01-sps2.mkv ffmpeg -i seg03.mkv -c:v libx264 ... -x264opts sps-id=3 ... seg01-sps3.mkv for f in *.mkv; do ffmpeg -i "$f" -c copy -bsf:v h264_mp4toannexb -sn "$f".ts; done for f in *.ts; do echo "file '$f'" >> flist.txt; done ffmpeg -f concat -i flist.txt -c copy -sn concat.mkv Have one question about SPS ID's - they must be different for all segments or may be reused for segments where encoders params are the same? |
31st March 2014, 19:48 | #6 | Link |
Registered User
Join Date: Mar 2014
Posts: 14
|
Thanks so much for all of your helpful feedback! The answer was actually a very simple one. I did not explicitly set the profile (main), level (3.1), and pix_fmt (yuv420p) in my command line. This has never been a problem for me until trying to work with image files turned to video. For these image videos, ffmpeg autodetects the parameters as a 4:4:4 Predictive L3.1 instead of 4:2:0 Main L3.1. I only found out when I tried to upload my merged videos to be streamed and it only played audio, but trusty ol' VLC played it no problem while I was testing.
After adding those 3 parameters to the command to generate the image video file, I was able to merge the pieces using the basic concat method and did not have to transcode to get everything put together. |
Tags |
ffmpeg concat |
Thread Tools | Search this Thread |
Display Modes | |
|
|