Skip to content

Commit 968af2d

Browse files
committed
rename filenames to be more consistent with what they actually represent
1 parent bba8964 commit 968af2d

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

main.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func main() {
1818
Usage:
1919
qvh devices
2020
qvh activate
21-
qvh record <outfile> <audiofile>
21+
qvh record <h264file> <wavfile>
2222
2323
Options:
2424
-h --help Show this screen.
@@ -54,17 +54,17 @@ The commands work as following:
5454

5555
rawStreamCommand, _ := arguments.Bool("record")
5656
if rawStreamCommand {
57-
outFilePath, err := arguments.String("<outfile>")
57+
h264FilePath, err := arguments.String("<h264file>")
5858
if err != nil {
5959
log.Error("Missing outfile parameter. Please specify a valid path like '/home/me/out.h264'")
6060
return
6161
}
62-
outFilePathAudio, err := arguments.String("<audiofile>")
62+
waveFilePath, err := arguments.String("<wavfile>")
6363
if err != nil {
6464
log.Error("Missing audiofile parameter. Please specify a valid path like '/home/me/out.raw'")
6565
return
6666
}
67-
record(outFilePath, outFilePathAudio)
67+
record(h264FilePath, waveFilePath)
6868
}
6969
}
7070

@@ -125,46 +125,46 @@ func activate() {
125125
log.Info(qtOutput)
126126
}
127127

128-
func record(outFilePath string, outFilePathAudio string) {
128+
func record(h264FilePath string, wavFilePath string) {
129129
activate()
130130
cleanup := screencapture.Init()
131131
deviceList, err := screencapture.FindIosDevices()
132132
defer cleanup()
133133
if err != nil {
134134
log.Fatal("Error finding iOS Devices", err)
135135
}
136-
log.Infof("Writing output to:%s", outFilePath)
136+
log.Infof("Writing video output to:'%s' and audio to: %s", h264FilePath, wavFilePath)
137137
dev := deviceList[0]
138138

139-
file, err := os.Create(outFilePath)
139+
h264File, err := os.Create(h264FilePath)
140140
if err != nil {
141-
log.Debugf("Error creating file:%s", err)
142-
log.Errorf("Could not open file '%s'", outFilePath)
141+
log.Debugf("Error creating h264File:%s", err)
142+
log.Errorf("Could not open h264File '%s'", h264FilePath)
143143
}
144-
audioFile, err := os.Create(outFilePathAudio)
144+
wavFile, err := os.Create(wavFilePath)
145145
if err != nil {
146-
log.Debugf("Error creating file:%s", err)
147-
log.Errorf("Could not open file '%s'", outFilePath)
146+
log.Debugf("Error creating wav file:%s", err)
147+
log.Errorf("Could not open wav file '%s'", wavFilePath)
148148
}
149149

150-
writer := coremedia.NewAVFileWriter(bufio.NewWriter(file), bufio.NewWriter(audioFile))
150+
writer := coremedia.NewAVFileWriter(bufio.NewWriter(h264File), bufio.NewWriter(wavFile))
151151

152152
defer func() {
153-
stat, err := audioFile.Stat()
153+
stat, err := wavFile.Stat()
154154
if err != nil {
155155
log.Fatal("Could not get wav file stats", err)
156156
}
157-
err = coremedia.WriteWavHeader(int(stat.Size()), audioFile)
157+
err = coremedia.WriteWavHeader(int(stat.Size()), wavFile)
158158
if err != nil {
159-
log.Fatalf("Error writing wave header %s might be invalid. %s", outFilePathAudio, err.Error())
159+
log.Fatalf("Error writing wave header %s might be invalid. %s", wavFilePath, err.Error())
160160
}
161-
err = audioFile.Close()
161+
err = wavFile.Close()
162162
if err != nil {
163-
log.Fatalf("Error closing wave file. '%s' might be invalid. %s", outFilePathAudio, err.Error())
163+
log.Fatalf("Error closing wave file. '%s' might be invalid. %s", wavFilePath, err.Error())
164164
}
165-
err = file.Close()
165+
err = h264File.Close()
166166
if err != nil {
167-
log.Fatalf("Error closing h264 file '%s'. %s", outFilePath, err.Error())
167+
log.Fatalf("Error closing h264File '%s'. %s", h264FilePath, err.Error())
168168
}
169169

170170
}()

screencapture/coremedia/avfilewriter.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ var startCode = []byte{00, 00, 00, 01}
1010
//AVFileWriter writes nalus into a file using 0x00000001 as a separator (h264 ANNEX B) and raw pcm audio into a wav file
1111
//Note that you will have to call WriteWavHeader() on the audiofile when you are done to write a wav header and get a valid file.
1212
type AVFileWriter struct {
13-
outFileWriter io.Writer
14-
audioFileWriter io.Writer
15-
outFilePath string
13+
h264FileWriter io.Writer
14+
wavFileWriter io.Writer
15+
outFilePath string
1616
}
1717

1818
//NewAVFileWriter binary writes nalus in annex b format to the given writer and audio buffers into a wav file.
1919
//Note that you will have to call WriteWavHeader() on the audiofile when you are done to write a wav header and get a valid file.
20-
func NewAVFileWriter(outFileWriter io.Writer, audioFileWriter io.Writer) AVFileWriter {
21-
return AVFileWriter{outFileWriter: outFileWriter, audioFileWriter: audioFileWriter}
20+
func NewAVFileWriter(h264FileWriter io.Writer, wavFileWriter io.Writer) AVFileWriter {
21+
return AVFileWriter{h264FileWriter: h264FileWriter, wavFileWriter: wavFileWriter}
2222
}
2323

2424
//Consume writes PPS and SPS as well as sample bufs into a annex b .h264 file and audio samples into a wav file
@@ -58,19 +58,19 @@ func (avfw AVFileWriter) writeNalus(bytes []byte) error {
5858
}
5959

6060
func (avfw AVFileWriter) writeNalu(naluBytes []byte) error {
61-
_, err := avfw.outFileWriter.Write(startCode)
61+
_, err := avfw.h264FileWriter.Write(startCode)
6262
if err != nil {
6363
return err
6464
}
65-
_, err = avfw.outFileWriter.Write(naluBytes)
65+
_, err = avfw.h264FileWriter.Write(naluBytes)
6666
if err != nil {
6767
return err
6868
}
6969
return nil
7070
}
7171

7272
func (avfw AVFileWriter) consumeAudio(buffer CMSampleBuffer) error {
73-
_, err := avfw.audioFileWriter.Write(buffer.SampleData)
73+
_, err := avfw.wavFileWriter.Write(buffer.SampleData)
7474
if err != nil {
7575
return err
7676
}

0 commit comments

Comments
 (0)