KoblentsBlog Photography
Contact About
Published Feb 28, 2017
Handy little script to concatenate video files. Probably wouldn't recommend it with dissimilar files, though.
123456789101112
#!/bin/bash

if [[ -z $1 || -z $2 ]]; then
        echo "Must supply at least two arguments.";
        return 1;
fi

ext=`echo $1 | sed -e "s/.*\.//"`;

ffmpeg -f concat -safe 0 \
       -i <(for f in "$@"; do echo "file '$PWD/$f'"; done) \
       -c copy output.$ext
 
Published Feb 26, 2017
Had an annoying bug that didn't seem to show up on google... so maybe this will resolve some issues.
I have a makefile where a build is attempted, but because the build tool is buggy, sometimes it fails for no reason. So I invoke it with a timeout, then test to see if it errored out, and if so I rerun the build. The error code in bash is $?; but inside of a makefile the $ needs to be escaped, so I write
if [ $$? -ne 0]; then
.
However, if you need to stick this into a makefile #define block, you need to escape the escaped $. If you don't, you'll get this error: -ne: unary operator expected. So you'll have to do this:
if [ $$$$? -ne 0 ]; then
in order to escape things properly.
 
Published Feb 21, 2017
I had an issue where a video file had embedded (soft) subtitles with an error, and I wanted to edit the subtitles. Since it's just a stream in the file, it's really easy - at least for an mkv container.
All you need to do is extract the subtitles, edit them in your editor of choice, then add the stream back in. Previously, I removed the subtitle stream from the file entirely then added the edited one back; the updated version simply uses the video and audio from the original file, and the subtitles from the edited srt file, to make the new video output.
123
ffmpeg -i <video.mkv> -an -vn -map 0:2 -c:s:0 srt <sub.srt>
vi <sub.srt>
ffmpeg -i <video.mkv> -i sub.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s copy <video_output.mkv>
 
 
« Newest January 2017 »
© Copyright Koblents.com, 2012-2017