Pana$onic battery message

RANT: Bought a new Panasonic video camera which came with a small battery. I bought a couple of “compatible” batteries and a charger for $50 online which seemed to work fine for a day or so. Then the camera said “This battery cannot be used” and shut off. Both batteries didn’t suddenly develop issues. I did some looking online and Panasonic created some circuitry to tell them when a 3rd party battery is being used:
http://av.jpn.support.panasonic.com/support/global/cs/info/dsc_battery.html

This was allegedly to “protect” their customers. Somehow I don’t buy that.

It is certainly their right to build their cameras to only support their own batteries. I get that. Except they charge about 6 times the amount for one battery. I guess they assume if I’m willing to pay $1000 for a camera, I wouldn’t balk at $120 for a battery. But it is a LOT more customer friendly to make their cameras the focus, and let customers tell others how great the camera is instead of trying to squeeze extra dollars out of us for accessories.

I’ve had no trouble using 3rd party batteries on my older camera, so didn’t anticipate it on this one. Now I’ll have to find a reputable dealer and buy known Panasonic batteries.

Another thing, even the Panasonic shopping website says the large battery is out of stock. I can’t use the small battery to shoot a whole jazz gig. Sheesh!

Amazon is listed as a dealer, and their price for one Panasonic brand battery is $118. I’ll try that one.

NOTE: The brands that currently fail on the new HC-WXF1 video camera are Powerextra and Wasabi. Neither brand claims to work with the new camera, but they do say their batteries work like the VW-VBT380 which Panasonic says is the large battery for this camera. I had to return both of the 3rd party batteries.

NOTE: I learned from some comments on YouTube that I could use a “powerbank”, so purchased an Anker PowerCore II 20000. The camera power cord has a USB connection on the power end, so this attaches to the powerbank and works very nicely for powering the camera for several hours, and it thinks it is attached to wall power. Leave the onboard battery attached in case the powerbank loses power or gets turned off.

Running minidlna on Ubuntu

I have a dumb TV. It’s still quite nice, just no streaming anything to it. I am in the process of picking a device to do the streaming and want to have a folder on my Ubuntu PC that holds the media.

I installed a service called minidlna which is supposed to allow streaming of media. However, it didn’t like the permissions on my chosen folder.
The path is /media/jw/DRIVE2/general.

I had a few problems setting it up:


jw@FooPC:~$ sudo service minidlna restart
* Restarting DLNA/UPnP-AV media server minidlna
[2014/07/23 21:03:30] minidlna.c:594: error: Media directory "/media/jw/drive2/general" not accessible [Permission denied]

I first pointed it to a folder in my home folder and it liked that just fine, but not the 2nd drive that holds the media.

So I tried setting the user as me in the conf file and in the default file. But eventually I had to set the user as “root” to make it work.

HOW TO SET IT UP
The service is controlled by 2 files:
/etc/default/minidlna (sets WHO the service runs as)
/etc/minidlna.conf (sets WHICH FOLDERS to use AND who is using the service)

Here is how to set up the folder locations in the minidlna.conf file
(I didn’t find the A,P,V part very useful, but show an example of how it is used.)

# Specify the user name or uid to run as.
user=root
.
.
# If you want to restrict a media_dir to a specific content type, you can
# prepend the directory name with a letter representing the type (A, P or V),
# followed by a comma, as so:
# * "A" for audio (eg. media_dir=A,/var/lib/minidlna/music)
# * "P" for pictures (eg. media_dir=P,/var/lib/minidlna/pictures)
# * "V" for video (eg. media_dir=V,/var/lib/minidlna/videos)
media_dir=/media/jw/DRIVE2/general
media_dir=V,/media/jw/DRIVE3/MOVIES
media_dir=/media/jw/DRIVE3/Tonys
media_dir=/media/jw/DRIVE3/TOONS

Now we set up the minidlna file:


sudo gedit /etc/default/minidlna

# User and group the daemon should run as
USER="root"
#GROUP="minidlna"

I restarted the service and this time there was no error about permissions.


sudo service minidlna restart

I’m probably going to get a WD TV Live box and see if that can see the media share. I’ll update as I go.

UPDATE:
I did get the WD TV Live box and love it. I’m able to stream movies and pics from my computer to the big screen, and it comes with apps like Netflix.

Update 2019:
Got the newer Roku Ultra for ease of use, and future-proofing with 4K.

Correcting for audio/video sync issues with the ffmpeg program’s ITSOFFSET switch

The ffmpeg program has numerous “switches” that help to adjust and convert audio and video files. Some of them are not explained very well in the documentation, and many websites have confusing postings by well-meaning people trying to make use of the switches. I will try to explain how to use a couple of these switches to correct common sync problems with videos. It will take some time to learn, but is very powerful once you understand it.

The itsoffset switch is used to nudge (forward or backward) the start time of either an audio or video “stream”. A typical video camera will record one video stream and one audio stream which are merged into one file. On my camera, they merge into an MTS high-def formatted file. But sometimes during a conversion to another file format (such as mp4), the audio and video will not remain in sync and the itsoffset switch can be used to adjust them.

The itsoffset switch is nearly always used in conjunction with the “map” switch, since this tells ffmpeg which stream you want to affect, and what streams you wish to merge into a new output file.

For our purposes, we will deal with just one input file that has two streams out of sync (the most common problem). We will use this one input file twice, once for its audio portion, and once for its video portion. We will use itsoffset and map to delay one of the streams, and then merge them back together into another file.

in-sync

There are a few different ways to accomplish the same result with minor variations, and I will try to demonstrate them. First I will demonstrate the syntax of the “map” and “itsoffset” switches and what they mean. Here is a picture to better clarify the description (click pic for better view):
ffcmd
Map syntax:
-map “input file number”:”stream number”
The input file number will be 0 or 1, and stream will be 0 (video) or 1 (audio)

An important side note on file numbering with ffmpeg: 0 is the first, 1 is the second

“-map 0:1” means first input file mentioned on the command-line and its stream 1 (audio)
“-map 1:0” means second input file and stream 0 (video)
“-map 1:1” means second input file and stream 1 (audio)

“Itsoffset” is used with a specific amount of time that you want to apply to a file. If the audio is off by 1 second, you might type -itsoffset 1.0 (or -itsoffset 00:00:01.0000). Itsoffset applies to both streams of a file, and we use “map” to split out the stream we want to change. This is why we have to specify the input file twice, once for the stream we don’t change, and once for the stream we do change.

I’ll talk more about how to find the correct time shortly.

“-itsoffset 1.0 -i clip.mts” means to apply a 1 second delay to the input file clip.mts

Also, it matters WHERE you put the itsoffset switch in the command-line.
 It applies to the input file that comes just after it.

Trial and Error with a small clip
Finding the correct adjustment time can be tricky. Sometimes it may be out of sync by a tiny amount like 0.150 seconds, but it makes all the difference in the world when you get it correct. Trial and error is the only way I know to get it, so working with a 1 minute clip instead of the whole video you can get a fast answer. Once you have the clip fixed the way you like, you can apply the settings to the whole video.

To extract just a 1 minute portion of a video, try this:

ffmpeg -ss 15:30 -i 00001.MTS -vcodec copy -acodec copy -t 1:00 clip.mts

(takes the video 00001.MTS, goes to fifteen minutes and thirty seconds [-ss 15:30] and then takes 1 minute [-t 1:00] from there and creates a new file called clip.mts. There is often more action in the middle of a video, so I chose to start there.)

So we take the short clip and use it to adjust the sync. Go ahead and create a clip so you can experiment with it.

Examples
The following examples move a stream by 2.0 seconds so you can better perceive the change (assuming that you follow the examples with a clip of your own).

The following commandlines all result the same thing, “delay the audio by 2 seconds”. This means that in the output file, you will see the video start and then 2 seconds later the audio will start. The differences are the location of “itsoffset” and what stream is mapped:

ffmpeg -i clip.mts -itsoffset 2.0 -i clip.mts -vcodec copy -acodec copy -map 0:0 -map 1:1 delay1.mts
Applies itsoffset to file “1” (because it is placed just before the 2nd input), and the map for file 1 points to stream 1 (audio)

ffmpeg -i clip.mts -itsoffset 2.0 -i clip.mts -vcodec copy -acodec copy -map 1:1 -map 0:0 delay2.mts
Applies itsoffset to file “1” (because it is placed just before the 2nd input), and the map for
file 1 points to stream 1 (audio). I just changed the order of which map came first, it doesn’t matter.

ffmpeg -itsoffset 2.0 -i clip.mts -i clip.mts -vcodec copy -acodec copy -map 0:1 -map 1:0 delay3.mts
Applies itsoffset to file “0” (because it is placed just before the 1st input), and the map for
file 0 points to stream 1 (audio). So I changed the location of itsoffset and the mapping.

ffmpeg -i clip.mts -itsoffset -2.0 -i clip.mts -vcodec copy -acodec copy -map 0:1 -map 1:0 delay4.mts
This one adjusts the video forward 2 seconds rather than delaying the audio, but accomplishes the same thing. I gave a negative 2.0 value to itsoffset. Itsoffset is just before file 1, and map for file 1 points to stream 0 (video). That is, instead of waiting two seconds to start the audio, we tell the video to nudge back two seconds.

*Note: “-vcodec copy -acodec copy” can be shortened to “-c:v copy -c:a copy” This command keeps the same video and audio format in the output file as was in the input file.

That’s it for experiments with the clip.

Now lets deal with the two most common sync problems. Remember that we are using the out of sync file as the input twice, splitting out just one stream from each input, applying a delay to one of the streams, and then merging the streams back into an output file.

aud-ahead

vid-ahead

CASE 1: Audio happens before video (aka “need to delay audio stream 1”):
ffmpeg -i clip.mp4 -itsoffset 0.150 -i clip.mp4 -vcodec copy -acodec copy -map 0:0 -map 1:1 output.mp4

The “itsoffset” in the above example is placed before file 1 (remember that linux counts from 0, so 0 is the first and 1 is the second), so when the mapping happens, it says “Take the video of file 0 and the audio of file 1, leave the video of file 0 alone and apply the offset to the audio of file 1 and merge them into a new output file”. The delay is only .15 seconds.

CASE 2: Video happens before audio (aka “need to delay video stream 0”):
ffmpeg -i clip.mp4 -itsoffset 0.150 -i clip.mp4 -vcodec copy -acodec copy -map 0:1 -map 1:0 output.mp4

The “itsoffset” in the above example is placed before file 1. When the mapping happens, it says “Take the audio of file 0 and the video of file 1, leave the audio of file 0 alone and apply the offset to the video of file 1 and merge them into a new output file”. The delay is only .15 seconds.

I hope this all made sense to you and helps clarify what can be a very confusing command-line.

Convert MTS video for YouTube

I have a Sony HandyCam that produces MTS digital videos. I am also a Linux user, Ubuntu flavor, and ran through hours and hours of trying a variety of programs to get these videos converted to a format acceptable to YouTube.

Some popular programs would not work at all after install, even after several attempts to get them to function, and other programs would fail to do what I needed. I ended up reinstalling the program “ffmpeg” from source and enabling just about every feature during the compile. Then I used two simple command-line methods to successfully process an MTS video into a YouTube-ready MP4 video. But there is also the problem that the camera itself splits files internally at 2GB. Since this can happen in the middle of a song, I had to be able to join the files together prior to extracting a clip.

To join files, I have to use an older free program called TsMuxer: http://www.videohelp.com/tools/tsMuxeR (In this program, click Add to put the first file in the list, then click Join to add more files to append.) I tried using “cat” to join them, but frequently had errors appear.

When trying to cut out a clip from two files (as shown in picture below), I find it is best to first join the large files, then cut out the clip, rather than clipping each and then trying to join them.

The first command to convert the file tells ffmpeg to take a specific clip of the video (which you figure out by watching the video), and excise it from the original. You need to note the beginning time, then the end time, and figure out how long the clip is that you want.

NOTE: If you want to convert the whole video, you can skip step 1.

1. ffmpeg -ss 00:01:33 -i 00001.MTS -vcodec copy -acodec -t 00:13:04 copy file.mts
This copies a clip of the specified portion of the file “00001.MTS” without re-encoding [starting at 1 minute 33 seconds and lasting for a duration of 13 minutes 4 seconds] NOTE: Duration (the “-t” option) is how long the clip lasts, not the time when it ends. This step is fast and results in a shorter MTS clip called “file.mts”. (NOTE: There seems to be some issue with the way that ffmpeg creates clips. Often, other programs have trouble with the clips, implying that there is something not quite right about how ffmpeg is creating the new file. Even ffmpeg has trouble combining such clips into a new file, compaining about PES packet size mismatch.)

2. ffmpeg -i file.mts -itsoffset 0.150 -i file.mts -map 1:0 -map 0:1 -c:v libx264 -c:a libfaac file2.mp4
There is sometimes a slight sync problem between the video and audio when converting to MP4, but there is a way to correct for it highlighted in blue above. This command takes the clip from above, and corrects the video delay that happens when encoding to mp4, splits the audio and video streams and remuxes them with the video delayed .15 seconds (the “-itsoffset 0.150” part). You may have to tweak the delay plus or minus some to get things synced the way you like. The input file has to be specified twice (“-i file.mts”) once for the video delay, once for splitting out the video and audio and re-combining them. The last bit (“-c:v libx264 -c:a libfaac”) tells it to use the video codec “libx264” for h264, and the audio codec “libfaac” for AAC, which is what YouTube likes for HD videos. If your video doesn’t need the sync correction, leave out the part in blue.

If your installation of ffmpeg says it doesn’t know about libx264, you may need to do a reinstall using the source code to get that option enabled. Or just try following the commands on this page: http://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide

The only issue I’ve found with this method is a bit of visual noise when people are moving around in the video. I’m open to suggestions on preventing that noise. It happens during the conversion to MP4, and is not part of the original video (MTS).

Also, to convert MTS files for burning to standard NTSC (American) DVD, this command works well:

ffmpeg -i 00000.MTS -target ntsc-dvd foo.mpg
(converts in about real time, automatically sets the bitrate, sets to AC3 audio and converts from h264 to mpeg2, which is what is required for making a dvd)
From FFMPEG docs: “Specify target file type (vcd, svcd, dvd, dv, dv50). Type may be prefixed with pal-, ntsc- or film- to use the corresponding standard. All the format options (bitrate, codecs, buffer sizes) are then set automatically.”

Lastly, convert the MP4 file to have quick loading on Youtube:

qt-faststart input.mp4 output.mp4

In this example, output.mp4 will be the one you post to Youtube.